patch 9.1.0831: 'findexpr' can't be used as lambad or Funcref

Problem:  'findexpr' can't be used for lambads
          (Justin Keyes)
Solution: Replace the findexpr option with the findfunc option
          (Yegappan Lakshmanan)

related: #15905
closes: #15976

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 027cf08..6b26475 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt*	For Vim version 9.1.  Last change: 2024 Oct 28
+*eval.txt*	For Vim version 9.1.  Last change: 2024 Nov 02
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -2027,10 +2027,6 @@
 		can only be used in autocommands.  For user commands |<bang>|
 		can be used.
 
-					*v:cmdcomplete* *cmdcomplete-variable*
-v:cmdcomplete	When evaluating 'findexpr': if 'findexpr' is used for cmdline
-		completion the value is |v:true|, otherwise it is |v:false|.
-
 						*v:collate* *collate-variable*
 v:collate	The current locale setting for collation order of the runtime
 		environment.  This allows Vim scripts to be aware of the
@@ -2228,8 +2224,7 @@
 
 					*v:fname* *fname-variable*
 v:fname		When evaluating 'includeexpr': the file name that was
-		detected.  When evaluating 'findexpr': the argument passed to
-		the |:find| command.  Empty otherwise.
+		detected.  Empty otherwise.
 
 					*v:fname_in* *fname_in-variable*
 v:fname_in	The name of the input file.  Valid while evaluating:
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index e221fe3..7a554db 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt*	For Vim version 9.1.  Last change: 2024 Oct 28
+*options.txt*	For Vim version 9.1.  Last change: 2024 Nov 02
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -439,10 +439,11 @@
 ":setlocal" on a global option might work differently then.
 
 						*option-value-function*
-Some options ('completefunc', 'imactivatefunc', 'imstatusfunc', 'omnifunc',
-'operatorfunc', 'quickfixtextfunc', 'tagfunc' and 'thesaurusfunc') are set to
-a function name or a function reference or a lambda function.  When using a
-lambda it will be converted to the name, e.g. "<lambda>123".  Examples:
+Some options ('completefunc', 'findfunc', 'imactivatefunc', 'imstatusfunc',
+'omnifunc', 'operatorfunc', 'quickfixtextfunc', 'tagfunc' and 'thesaurusfunc')
+are set to a function name or a function reference or a lambda function.  When
+using a lambda it will be converted to the name, e.g. "<lambda>123".
+Examples:
 >
 	set opfunc=MyOpFunc
 	set opfunc=function('MyOpFunc')
@@ -3552,36 +3553,36 @@
 	  eob		EndOfBuffer		|hl-EndOfBuffer|
 	  lastline	NonText			|hl-NonText|
 
-						*'findexpr'* *'fexpr'* *E1514*
-'findexpr' 'fexpr'	string	(default "")
+						*'findfunc'* *'ffu'* *E1514*
+'findfunc' 'ffu'	string	(default empty)
 			global or local to buffer |global-local|
 			{not available when compiled without the |+eval|
 			feature}
-	Expression that is evaluated to obtain the filename(s) for the |:find|
+	Function that is called to obtain the filename(s) for the |:find|
 	command.  When this option is empty, the internal |file-searching|
 	mechanism is used.
 
-	While evaluating the expression, the |v:fname| variable is set to the
-	argument of the |:find| command.
+	The value can be the name of a function, a |lambda| or a |Funcref|.
+	See |option-value-function| for more information.
 
-	The expression is evaluated only once per |:find| command invocation.
-	The expression can process all the directories specified in 'path'.
+	The function is called with two arguments.  The first argument is a
+	|String| and is the |:find| command argument.  The second argument is
+	a |Boolean| and is set to |v:true| when the function is called to get
+	a List of command-line completion matches for the |:find| command.
+	The function should return a List of strings.
 
-	The expression may be evaluated for command-line completion as well,
-	in which case the |v:cmdcomplete| variable will be set to |v:true|,
-	otherwise it will be set to |v:false|.
+	The function is called only once per |:find| command invocation.
+	The function can process all the directories specified in 'path'.
 
-	If a match is found, the expression should return a |List| containing
-	one or more file names.  If a match is not found, the expression
+	If a match is found, the function should return a |List| containing
+	one or more file names.  If a match is not found, the function
 	should return an empty List.
 
-	If any errors are encountered during the expression evaluation, an
+	If any errors are encountered during the function invocation, an
 	empty List is used as the return value.
 
-	Using a function call without arguments is faster |expr-option-function|
-
 	It is not allowed to change text or jump to another window while
-	evaluating 'findexpr' |textlock|.
+	executing the 'findfunc' |textlock|.
 
 	This option cannot be set from a |modeline| or in the |sandbox|, for
 	security reasons.
@@ -3589,18 +3590,18 @@
 	Examples:
 >
 	    " Use glob()
-	    func FindExprGlob()
-		let pat = v:cmdcomplete ? $'{v:fname}*' : v:fname
+	    func FindFuncGlob(cmdarg, cmdcomplete)
+		let pat = a:cmdcomplete ? $'{a:cmdarg}*' : a:cmdarg
 		return glob(pat, v:false, v:true)
 	    endfunc
-	    set findexpr=FindExprGlob()
+	    set findfunc=FindFuncGlob
 
 	    " Use the 'git ls-files' output
-	    func FindGitFiles()
+	    func FindGitFiles(cmdarg, cmdcomplete)
 		let fnames = systemlist('git ls-files')
-		return fnames->filter('v:val =~? v:fname')
+		return fnames->filter('v:val =~? a:cmdarg')
 	    endfunc
-	    set findexpr=FindGitFiles()
+	    set findfunc=FindGitFiles
 <
 		*'fixendofline'* *'fixeol'* *'nofixendofline'* *'nofixeol'*
 'fixendofline' 'fixeol'	boolean	(default on)
diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt
index 0f7453a..a43d28f 100644
--- a/runtime/doc/quickref.txt
+++ b/runtime/doc/quickref.txt
@@ -1,4 +1,4 @@
-*quickref.txt*  For Vim version 9.1.  Last change: 2024 Oct 22
+*quickref.txt*  For Vim version 9.1.  Last change: 2024 Nov 02
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -707,7 +707,7 @@
 'fileignorecase'  'fic'     ignore case when using file names
 'filetype'	  'ft'	    type of file, used for autocommands
 'fillchars'	  'fcs'     characters to use for displaying special items
-'findexpr'	  'fexpr'   expression to evaluate for |:find|
+'findfunc'	  'ffu'     function to be called for the |:find| command
 'fixendofline'	  'fixeol'  make sure last line in file has <EOL>
 'fkmap'		  'fk'	    obsolete option for Farsi
 'foldclose'	  'fcl'     close a fold when the cursor leaves it
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 1ae1ff6..79d9daf 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -267,9 +267,9 @@
 'fenc'	options.txt	/*'fenc'*
 'fencs'	options.txt	/*'fencs'*
 'fex'	options.txt	/*'fex'*
-'fexpr'	options.txt	/*'fexpr'*
 'ff'	options.txt	/*'ff'*
 'ffs'	options.txt	/*'ffs'*
+'ffu'	options.txt	/*'ffu'*
 'fic'	options.txt	/*'fic'*
 'fileencoding'	options.txt	/*'fileencoding'*
 'fileencodings'	options.txt	/*'fileencodings'*
@@ -278,7 +278,7 @@
 'fileignorecase'	options.txt	/*'fileignorecase'*
 'filetype'	options.txt	/*'filetype'*
 'fillchars'	options.txt	/*'fillchars'*
-'findexpr'	options.txt	/*'findexpr'*
+'findfunc'	options.txt	/*'findfunc'*
 'fixendofline'	options.txt	/*'fixendofline'*
 'fixeol'	options.txt	/*'fixeol'*
 'fk'	options.txt	/*'fk'*
@@ -6510,7 +6510,6 @@
 closure	eval.txt	/*closure*
 cmdarg-variable	eval.txt	/*cmdarg-variable*
 cmdbang-variable	eval.txt	/*cmdbang-variable*
-cmdcomplete-variable	eval.txt	/*cmdcomplete-variable*
 cmdline-arguments	vi_diff.txt	/*cmdline-arguments*
 cmdline-changed	version5.txt	/*cmdline-changed*
 cmdline-completion	cmdline.txt	/*cmdline-completion*
@@ -10942,7 +10941,6 @@
 v:charconvert_to	eval.txt	/*v:charconvert_to*
 v:cmdarg	eval.txt	/*v:cmdarg*
 v:cmdbang	eval.txt	/*v:cmdbang*
-v:cmdcomplete	eval.txt	/*v:cmdcomplete*
 v:collate	eval.txt	/*v:collate*
 v:colornames	eval.txt	/*v:colornames*
 v:completed_item	eval.txt	/*v:completed_item*
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 66f98e1..5f92503 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -41652,7 +41652,7 @@
 
 'completeitemalign'	Order of |complete-items| in Insert mode completion
 			popup
-'findexpr'		Vim expression to obtain the results for a |:find|
+'findfunc'		Vim function to obtain the results for a |:find|
 			command
 'winfixbuf'		Keep buffer focused in a window
 'tabclose'		Which tab page to focus after closing a tab page