Wednesday, May 25, 2016

Re: Channel commands: special characters, quotes and escaping

2016-05-25 14:19 GMT+03:00 'Jan Bundesmann' via vim_use
<vim_use@googlegroups.com>:
>> I think this should also work:
>>
>> ["ex", 'call feedkeys("ggOHello, world!\\e")']
> Nope, it does not. Channel log says:
> 82.925983 RECV on 0: '["ex", 'call feedkeys("ggOHello, world!\\e")']'
> 82.926009 ERR on 0: Decoding failed - discarding input
>
>> Keep in mind this is in Python. And in Python a backslash inside a
>> single quoted string has a special meaning, unlike Vim.
> I still think, it's somehow related to the handler. Or is this, too, written in Python?
>
> Out of curiousity, I tried the same but with a simple socket, established via "netcat".

I have no idea why Bram said about Python. Unless you stated otherwise
messages in channel are in JSON and JSON has no single quoted literal
strings, so your example *must* fail because it is not a valid JSON.
There are also other modes, but if I understand `:h channel-commands`
correctly you will have to write handlers for ex, etc yourself if you
use another mode.

> ["ex", "call feedkeys(\"ggOHello, world!\\e\")"] works
> ["ex", 'call feedkeys("ggOHello, world!\\e")'] does not
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment