cl-neovim icon indicating copy to clipboard operation
cl-neovim copied to clipboard

Errors when result of `:Lisp` contains apostrophe `'`

Open HiPhish opened this issue 5 years ago • 2 comments

Calling the :Lisp ex-command in Neovim with an argument that evaluates to a string containing an apostrophe (') throws errors. For example, executing :Lisp (print "That is nice") works fine, but :Lisp (print "That's nice") does not.

The issue is the way output is echoed, you use (nvim:command (format nil "echo '~A'" output)) and if the output contains an apostrophe it breaks everything. We need to either escape the apostrophe by doubling it, or used a different API function.

I propose the latter in my PR https://github.com/adolenc/cl-neovim/pull/14 by using the nvim:out-write function. The output still needs to be formatted through "~A~&" to put a terminating linefeed at the end, or else the output won't show. Using ~& ensures that no additional linefeed will be created if the string already ends in one.

HiPhish avatar Dec 18 '18 19:12 HiPhish

The PR looks good, I wonder why I used echo in the first place...

Maybe this is more of a note to myself, but I do remember there being one other bug with the lisp interface that I never got around to fixing; if you just use :Lisp (print "test") before the lisp client is bootstrapped, it would not want to bootstrap it; you would have to trick it by calling some dummy command that didn't contain any strings first. I also remember being able to reproduce it with the python client, but I'll have to try it with the newer version of neovim first, maybe this was already fixed.

adolenc avatar Dec 18 '18 23:12 adolenc

Maybe this is more of a note to myself, but I do remember there being one other bug with the lisp interface that I never got around to fixing; if you just use :Lisp (print "test") before the lisp client is bootstrapped, it would not want to bootstrap it; you would have to trick it by calling some dummy command that didn't contain any strings first.

Yes, I noticed that as well while working with the API client the last couple of days. I'm running Neovim 0.3.0 and 0.3.1 on Kubuntu, it happens with both.

HiPhish avatar Dec 18 '18 23:12 HiPhish