diff runtime/doc/eval.txt @ 16648:a7f06505ad39 v8.1.1326

patch 8.1.1326: no test for listener with partial commit https://github.com/vim/vim/commit/8aad88d8de256e58f04054eb7230c9613e26502f Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 12 13:53:50 2019 +0200 patch 8.1.1326: no test for listener with partial Problem: No test for listener with partial. Solution: Add a test. Add example to help.
author Bram Moolenaar <Bram@vim.org>
date Sun, 12 May 2019 14:00:07 +0200
parents 4790302965fc
children 04c2614af21c
line wrap: on
line diff
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -6323,7 +6323,8 @@ listener_add({callback} [, {buf}])			*li
 		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}])			*li
 		    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