gustavo-hms / luar

Script Kakoune using Lua
GNU Lesser General Public License v3.0
47 stars 3 forks source link

Confusion in the doc #13

Closed sucrecacao closed 3 years ago

sucrecacao commented 3 years ago

I dont' understand when caling lua replace the selection and when it echo the return value, both case are shown in the readme.

gustavo-hms commented 3 years ago

Hi, @sucrecacao !

Thanks for pointing out the inconsistencies.

Echoing was the plugin's behaviour until 80ae7e4a61e3bcc06d40cfb033c6cd585f4c6232 changed it to replace the selections instead. I've updated the docs but, as you pointed out, I missed some places in the README. I will fix it soon.

The rationale behind this change was to make some kind of quick editing easier, to the point they could be made from the prompt itself. You can see some examples here.

sucrecacao commented 3 years ago

I see, it is actually a very cool feature. I'm afraid updating my luar will break some of my snippet. Is this still possible to make luar only echo the return statement? Maybe it should be two seperate fonction, lua and luas or one argument lua -change-sels ?

gustavo-hms commented 3 years ago

If you just return without any value, nothing happens:

lua %{
    return
}

The above code doesn't replace your selections by an empty string. It's a no-op. So I guess it's unlikely that you have some snippet that would break (unless you do have a snippet that explicitly echoes something to the prompt using return).

And, since you still can echo something using the kak module (e.g. kak.echo("Bonjour!")), I think having two different commands is an unnecessary complication.

But maybe I should make an announcement in the Kakoune forum to make users aware of the change...