Skip to content

Commit

Permalink
Merge remote-tracking branch 'vim/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
splhack committed Feb 28, 2016
2 parents 349f039 + 0f526f5 commit 9787680
Show file tree
Hide file tree
Showing 59 changed files with 828 additions and 1,901 deletions.
2 changes: 0 additions & 2 deletions Filelist
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ SRC_DOS_UNIX = \
src/if_python3.c \
src/if_py_both.h \
src/if_ruby.c \
src/if_sniff.h \
src/if_tcl.c \
src/proto/if_cscope.pro \
src/proto/if_lua.pro \
Expand Down Expand Up @@ -455,7 +454,6 @@ SRC_EXTRA = \
$(SRC_VMS) \
README_os390.txt \
src/Make_mint.mak \
src/if_sniff.c \
src/infplist.xml \
src/link.390 \
src/os_beos.c \
Expand Down
98 changes: 62 additions & 36 deletions runtime/doc/channel.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*channel.txt* For Vim version 7.4. Last change: 2016 Feb 23
*channel.txt* For Vim version 7.4. Last change: 2016 Feb 27


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -74,7 +74,7 @@ In T1 you should see:
=== socket opened === ~

You can now send a message to the server: >
echo ch_sendexpr(channel, 'hello!')
echo ch_evalexpr(channel, 'hello!')
The message is received in T1 and a response is sent back to Vim.
You can see the raw messages in T1. What Vim sends is:
Expand All @@ -101,7 +101,7 @@ Instead of giving a callback with every send call, it can also be specified
when opening the channel: >
call ch_close(channel)
let channel = ch_open('localhost:8765', {'callback': "MyHandler"})
call ch_sendexpr(channel, 'hello!', {'callback': 0})
call ch_sendexpr(channel, 'hello!')
==============================================================================
3. Opening a channel *channel-open*
Expand Down Expand Up @@ -130,6 +130,8 @@ Use |ch_status()| to see if the channel could be opened.
overwritten. Therefore set "mode" first and the part specific
mode later.

Note: when writing to a file or buffer NL mode is always used.

*channel-callback*
"callback" A function that is called when a message is received that is
not handled otherwise. It gets two arguments: the channel
Expand Down Expand Up @@ -169,7 +171,7 @@ Use |ch_status()| to see if the channel could be opened.
msec at least.

"timeout" The time to wait for a request when blocking, E.g. when using
ch_sendexpr(). In milliseconds. The default is 2000 (2
ch_evalexpr(). In milliseconds. The default is 2000 (2
seconds).
*out-timeout* *err-timeout*
"out-timeout" Timeout for stdout. Only when using pipes.
Expand Down Expand Up @@ -198,6 +200,7 @@ Once done with the channel, disconnect it like this: >
When a socket is used this will close the socket for both directions. When
pipes are used (stdin/stdout/stderr) they are all closed. This might not be
what you want! Stopping the job with job_stop() might be better.
All readahead is discarded, callbacks will no longer be invoked.

When the channel can't be opened you will get an error message. There is a
difference between MS-Windows and Unix: On Unix when the port doesn't exist
Expand All @@ -211,15 +214,15 @@ If there is an error reading or writing a channel it will be closed.
4. Using a JSON or JS channel *channel-use*

If mode is JSON then a message can be sent synchronously like this: >
let response = ch_sendexpr(channel, {expr})
let response = ch_evalexpr(channel, {expr})
This awaits a response from the other side.

When mode is JS this works the same, except that the messages use
JavaScript encoding. See |js_encode()| for the difference.

To send a message, without handling a response or letting the channel callback
handle the response: >
call ch_sendexpr(channel, {expr}, {'callback': 0})
call ch_sendexpr(channel, {expr})
To send a message and letting the response handled by a specific function,
asynchronously: >
Expand Down Expand Up @@ -260,8 +263,9 @@ On read error or ch_close(), when using a socket, the string "DETACH" is sent,
if still possible. The channel will then be inactive. For a JSON and JS mode
channel quotes are used around DETACH, otherwise there are no quotes.

It is also possible to use ch_sendraw() on a JSON or JS channel. The caller
is then completely responsible for correct encoding and decoding.
It is also possible to use ch_sendraw() and ch_evalraw() on a JSON or JS
channel. The caller is then completely responsible for correct encoding and
decoding.

==============================================================================
5. Channel commands *channel-commands*
Expand Down Expand Up @@ -327,7 +331,7 @@ It will send back the result of the expression:
[-2, "last line"] ~
The format is:
[{number}, {result}]
*E915*

Here {number} is the same as what was in the request. Use a negative number
to avoid confusion with message that Vim sends. Use a different number on
every request to be able to match the request with the response.
Expand Down Expand Up @@ -360,7 +364,7 @@ Leave out the fourth argument if no response is to be sent:
6. Using a RAW or NL channel *channel-raw*

If mode is RAW or NL then a message can be send like this: >
let response = ch_sendraw(channel, {string})
let response = ch_evalraw(channel, {string})
The {string} is sent as-is. The response will be what can be read from the
channel right away. Since Vim doesn't know how to recognize the end of the
Expand All @@ -374,18 +378,18 @@ first NL. This can also be just the NL for an empty response.
If no NL was read before the channel timeout an empty string is returned.

To send a message, without expecting a response: >
call ch_sendraw(channel, {string}, 0)
call ch_sendraw(channel, {string})
The process can send back a response, the channel handler will be called with
it.

To send a message and letting the response handled by a specific function,
asynchronously: >
call ch_sendraw(channel, {string}, {callback})
call ch_sendraw(channel, {string}, {'callback': 'MyHandler'})
This {string} can also be JSON, use |json_encode()| to create it and
|json_decode()| to handle a received JSON message.

It is not possible to use |ch_sendexpr()| on a raw channel.
It is not possible to use |ch_evalexpr()| or |ch_sendexpr()| on a raw channel.

==============================================================================
7. More channel functions *channel-more*
Expand All @@ -397,7 +401,7 @@ are:
"closed" The channel was closed.

TODO:
To objain the job associated with a channel: ch_getjob(channel)
To obtain the job associated with a channel: ch_getjob(channel)

To read one message from a channel: >
let output = ch_read(channel)
Expand Down Expand Up @@ -444,14 +448,17 @@ If you want to handle both stderr and stdout with one handler use the
"callback" option: >
let job = job_start(command, {"callback": "MyHandler"})
You can send a message to the command with ch_sendraw(). If the channel is in
JSON or JS mode you can use ch_sendexpr().
You can send a message to the command with ch_evalraw(). If the channel is in
JSON or JS mode you can use ch_evalexpr().

There are several options you can use, see |job-options|.
For example, to start a job and write its output in buffer "dummy": >
let logjob = job_start("tail -f /tmp/log",
\ {'out-io': 'buffer', 'out-name': 'dummy'})
sbuf dummy
TODO:
To run a job and read its output once it is done: >
let job = job_start({command}, {'exit-cb': 'MyHandler'})
func MyHandler(job, status)
let channel = job_getchannel()
Expand Down Expand Up @@ -508,7 +515,7 @@ See |job_setoptions()| and |ch_setoptions()|.
*job-err-cb*
"err-cb": handler Callback for when there is something to read on
stderr.
TODO: *job-close-cb*
*job-close-cb*
"close-cb": handler Callback for when the channel is closed. Same as
"close-cb" on ch_open().
*job-exit-cb*
Expand All @@ -527,28 +534,47 @@ TODO: *job-term*
"term": "open" Start a terminal and connect the job
stdin/stdout/stderr to it.

TODO: *job-in-io*
"in-io": "null" disconnect stdin
*job-in-io*
"in-io": "null" disconnect stdin TODO
"in-io": "pipe" stdin is connected to the channel (default)
"in-io": "file" stdin reads from a file
"in-file": "/path/file" the file to read from
"in-io": "file" stdin reads from a file TODO
"in-io": "buffer" stdin reads from a buffer TODO
"in-name": "/path/file" the name of he file or buffer to read from
"in-buf": number the number of the buffer to read from TODO

TODO: *job-out-io*
"out-io": "null" disconnect stdout
*job-out-io*
"out-io": "null" disconnect stdout TODO
"out-io": "pipe" stdout is connected to the channel (default)
"out-io": "file" stdout writes to a file
"out-file": "/path/file" the file to write to
"out-io": "file" stdout writes to a file TODO
"out-io": "buffer" stdout appends to a buffer
"out-buffer": "name" buffer to append to

TODO: *job-err-io*
"err-io": "out" same type as stdout (default)
"err-io": "null" disconnect stderr
"err-io": "pipe" stderr is connected to the channel
"err-io": "file" stderr writes to a file
"err-file": "/path/file" the file to write to
"err-io": "buffer" stderr appends to a buffer
"err-buffer": "name" buffer to append to
"out-name": "/path/file" the name of the file or buffer to write to
"out-buf": number the number of the buffer to write to TODO

*job-err-io*
"err-io": "out" same as stdout TODO
"err-io": "null" disconnect stderr TODO
"err-io": "pipe" stderr is connected to the channel (default)
"err-io": "file" stderr writes to a file TODO
"err-io": "buffer" stderr appends to a buffer TODO
"err-name": "/path/file" the name of the file or buffer to write to
"err-buf": number the number of the buffer to write to TODO

When the IO mode is "buffer" and there is a callback, the text is appended to
the buffer before invoking the callback.

The name of the buffer is compared the full name of existing buffers. If
there is a match that buffer is used. Otherwise a new buffer is created.
Use an empty name to always create a new buffer. |ch_getbufnr()| can then be
used to get the buffer number.

For a new buffer 'buftype' is set to "nofile" and 'bufhidden' to "hide". If
you prefer other settings, create the buffer first and pass the buffer number.

When the buffer written to is displayed in a window and the cursor is in the
first column of the last line, the cursor will be moved to the newly added
line and the window is scrolled up to show the cursor if needed.

Undo is synced for every added line.

==============================================================================
11. Controlling a job *job-control*
Expand Down
69 changes: 49 additions & 20 deletions runtime/doc/eval.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*eval.txt* For Vim version 7.4. Last change: 2016 Feb 23
*eval.txt* For Vim version 7.4. Last change: 2016 Feb 27


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -1818,6 +1818,11 @@ call( {func}, {arglist} [, {dict}])
any call {func} with arguments {arglist}
ceil( {expr}) Float round {expr} up
ch_close( {channel}) none close {channel}
ch_evalexpr( {channel}, {expr} [, {options}])
any evaluate {expr} on JSON {channel}
ch_evalraw( {channel}, {string} [, {options}])
any evaluate {string} on raw {channel}
ch_getbufnr( {channel}, {what}) Number get buffer number for {channel}/{what}
ch_getjob( {channel}) Job get the Job of {channel}
ch_log( {msg} [, {channel}]) none write {msg} in the channel log file
ch_logfile( {fname} [, {mode}]) none start logging channel activity
Expand Down Expand Up @@ -2692,6 +2697,38 @@ ch_close({channel}) *ch_close()*
Close {channel}. See |channel-close|.
{only available when compiled with the |+channel| feature}

ch_evalexpr({channel}, {expr} [, {options}]) *ch_evalexpr()*
Send {expr} over {channel}. The {expr} is encoded
according to the type of channel. The function cannot be used
with a raw channel. See |channel-use|.
*E917*
{options} must be a Dictionary. It must not have a "callback"
entry.

ch_evalexpr() waits for a response and returns the decoded
expression. When there is an error or timeout it returns an
empty string.

{only available when compiled with the |+channel| feature}

ch_evalraw({channel}, {string} [, {options}]) *ch_evalraw()*
Send {string} over {channel}.
Works like |ch_evalexpr()|, but does not encode the request or
decode the response. The caller is responsible for the
correct contents. Also does not add a newline for a channel
in NL mode, the caller must do that. The NL in the response
is removed.
See |channel-use|.

{only available when compiled with the |+channel| feature}

ch_getbufnr({channel}, {what}) *ch_getbufnr()*
Get the buffer number that {channel} is using for {what}.
{what} can be "err" for stderr, "out" for stdout or empty for
socket output.
Returns -1 when there is no buffer.
{only available when compiled with the |+channel| feature}

ch_getjob({channel}) *ch_getjob()*
Get the Job associated with {channel}.
If there is no job calling |job_status()| on the returned Job
Expand Down Expand Up @@ -2767,18 +2804,13 @@ ch_readraw({channel} [, {options}]) *ch_readraw()*
ch_sendexpr({channel}, {expr} [, {options}]) *ch_sendexpr()*
Send {expr} over {channel}. The {expr} is encoded
according to the type of channel. The function cannot be used
with a raw channel. See |channel-use|. *E912*

{options} must be a Dictionary.
When "callback" is a Funcref or the name of a function,
ch_sendexpr() returns immediately. The callback is invoked
when the response is received. See |channel-callback|.

Without "callback" ch_sendexpr() waits for a response and
returns the decoded expression. When there is an error or
timeout it returns an empty string.
with a raw channel. See |channel-use|. *E912*

When "callback" is zero no response is expected.
{options} must be a Dictionary. The "callback" item is a
Funcref or the name of a function it is invoked when the
response is received. See |channel-callback|.
Without "callback" the channel handler is invoked, otherwise
any received message is dropped.

{only available when compiled with the |+channel| feature}

Expand Down Expand Up @@ -4561,6 +4593,8 @@ json_encode({expr}) *json_encode()*
Vim values are converted as follows:
Number decimal number
Float floating point number
Float nan "NaN"
Float inf "Infinity"
String in double quotes (possibly null)
Funcref not possible, error
List as an array (possibly null); when
Expand All @@ -4571,13 +4605,9 @@ json_encode({expr}) *json_encode()*
v:true "true"
v:none "null"
v:null "null"
Note that using v:none is permitted, although the JSON
standard does not allow empty items. This can be useful for
omitting items in an array:
[0,,,,,5] ~
This is much more efficient than:
[0,null,null,null,null,5] ~
But a strict JSON parser will not accept it.
Note that NaN and Infinity are passed on as values. This is
missing in the JSON standard, but several implementations do
allow it. If not then you will get an error.

keys({dict}) *keys()*
Return a |List| with all the keys of {dict}. The |List| is in
Expand Down Expand Up @@ -7396,7 +7426,6 @@ scrollbind Compiled with 'scrollbind' support.
showcmd Compiled with 'showcmd' support.
signs Compiled with |:sign| support.
smartindent Compiled with 'smartindent' support.
sniff Compiled with SNiFF interface support.
spell Compiled with spell checking support |spell|.
startuptime Compiled with |--startuptime| support.
statusline Compiled with support for 'statusline', 'rulerformat'
Expand Down
3 changes: 1 addition & 2 deletions runtime/doc/help.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*help.txt* For Vim version 7.4. Last change: 2016 Feb 22
*help.txt* For Vim version 7.4. Last change: 2016 Feb 27

VIM - main help file
k
Expand Down Expand Up @@ -165,7 +165,6 @@ Interfaces ~
|if_mzsch.txt| MzScheme interface
|if_perl.txt| Perl interface
|if_pyth.txt| Python interface
|if_sniff.txt| SNiFF+ interface
|if_tcl.txt| Tcl interface
|if_ole.txt| OLE automation interface for Win32
|if_ruby.txt| Ruby interface
Expand Down
Loading

0 comments on commit 9787680

Please sign in to comment.