summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-12 13:53:50 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-12 13:53:50 +0200
commit8aad88d8de256e58f04054eb7230c9613e26502f (patch)
treecb9b0add2649f499fe2b95c94ae92bd9e6569f8f /runtime
parent97b0075b0d733cc58c29247b09e7887b9991d7bf (diff)
patch 8.1.1326: no test for listener with partialv8.1.1326
Problem: No test for listener with partial. Solution: Add a test. Add example to help.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/eval.txt23
1 files changed, 19 insertions, 4 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 0b71c44dab..c1123ab6fa 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -6323,7 +6323,8 @@ listener_add({callback} [, {buf}]) *listener_add()*
Returns a unique ID that can be passed to |listener_remove()|.
The {callback} is invoked with a list of items that indicate a
- change. Each list item is a dictionary with these entries:
+ change. The list cannot be changed. Each list item is a
+ dictionary with these entries:
lnum the first line number of the change
end the first line below the change
added number of lines added; negative if lines were
@@ -6349,7 +6350,21 @@ listener_add({callback} [, {buf}]) *listener_add()*
added zero
col first column with a change or one
- The {callback} is invoked just before the screen is updated.
+ The entries are in the order the changes was made, thus the
+ most recent change is at the end. One has to go through the
+ list from end to start to compute the line numbers in the
+ current state of the text.
+
+ When using the same function for multiple buffers, you can
+ pass the buffer to that function using a |Partial|.
+ Example: >
+ func Listener(bufnr, changes)
+ " ...
+ endfunc
+ let bufnr = ...
+ call listener_add(function('Listener', [bufnr]), bufnr)
+
+< The {callback} is invoked just before the screen is updated.
To trigger this in a script use the `:redraw` command.
The {callback} is not invoked when the buffer is first loaded.
@@ -10984,10 +10999,10 @@ expressions |expr-lambda|.
Example: >
function Something(key, value = 10)
- echo a:key .. ": " .. value
+ echo a:key .. ": " .. a:value
endfunction
call Something('empty') "empty: 10"
- call Something('key, 20) "key: 20"
+ call Something('key', 20) "key: 20"
The argument default expressions are evaluated at the time of the function
call, not definition. Thus it is possible to use an expression which is