diff --git a/doc/options.jax b/doc/options.jax index 5fb00a79a..977a57206 100644 --- a/doc/options.jax +++ b/doc/options.jax @@ -1,4 +1,4 @@ -*options.txt* For Vim バージョン 9.1. Last change: 2024 Oct 22 +*options.txt* For Vim バージョン 9.1. Last change: 2024 Nov 06 VIMリファレンスマニュアル by Bram Moolenaar @@ -469,10 +469,11 @@ Note: 将来的に、より多くのグローバルオプションが |global-lo れない。 *option-value-function* -いくつかのオプション('completefunc', 'imactivatefunc', 'imstatusfunc', -'omnifunc', 'operatorfunc', 'quickfixtextfunc', 'tagfunc', 'thesaurusfunc')は -関数名もしくは関数への参照もしくはラムダ関数を設定する。ラムダを使う場合は内部 -名へ変換される、例えば "123"。例: +いくつかのオプション ('completefunc', 'findfunc', 'imactivatefunc', +'imstatusfunc', 'omnifunc', 'operatorfunc', 'quickfixtextfunc', 'tagfunc' +および 'thesaurusfunc') は関数名もしくは関数への参照もしくはラムダ関数を設定す +る。ラムダを使う場合は内部名へ変換される、例えば "123"。 +例: > set opfunc=MyOpFunc set opfunc=function('MyOpFunc') @@ -3538,7 +3539,7 @@ Note 1番目の形式では、行全体がオプション指定に使われる 英数字、'-'、'_' のみ使用できる。 *'fillchars'* *'fcs'* -'fillchars' 'fcs' 文字列 (既定では "vert:|,fold:-,eob:~") +'fillchars' 'fcs' 文字列 (既定では "vert:|,fold:-,eob:~,lastline:@") グローバル/ウィンドウについてローカル |global-local| ウィンドウのステータス行、垂直分割の区切り、特殊行を埋める文字。 これはコンマで区切られた項目のリストである。各項目には、名前、コロン、 @@ -3575,26 +3576,32 @@ Note 1番目の形式では、行全体がオプション指定に使われる eob EndOfBuffer |hl-EndOfBuffer| lastline NonText |hl-NonText| - *'findexpr'* *'fexpr'* *E1514* -'findexpr' 'fexpr' 文字列 (既定では "") + *'findfunc'* *'ffu'* *E1514* +'findfunc' 'ffu' 文字列 (既定では "") グローバル/バッファについてローカル |global-local| {|+eval| 機能つきでコンパイルされたときのみ有効} - |:find| コマンドのファイル名を取得するために評価される式。このオプショ - ンが空の場合、内部の |file-searching| メカニズムが使用される。 + |:find| コマンドのファイル名を取得するために呼び出される関数。このオプ + ションが空の場合、内部の |file-searching| メカニズムが使用される。 - 式の評価中、|v:fname| 変数は |:find| コマンドの引数に設定される。 + 値には関数名、|lambda| または |Funcref| を指定できる。 + 詳細については |option-value-function| を参照。 - 式は、|:find| コマンドの呼び出しごとに 1 回だけ評価される。 - 式は、'path' で指定されたすべてのディレクトリを処理できる。 + 関数は 2 つの引数で呼び出される。最初の引数は |String| で、|:find| コ + マンドの引数である。2 番目の引数は |Boolean| で、関数が呼び出されて + |:find| コマンドのコマンドライン補完にマッチしたリストを取得した時に + |v:true| に設定される。 + 関数は文字列のリストを返す必要がある。 - マッチした場合、式は 1 つ以上のファイル名を含む |List| を返す必要があ - る。マッチしない場合、式は空のリストを返す必要がある。 + 関数は、|:find| コマンドの呼び出しごとに 1 回だけ呼び出される。 + 関数は、'path' で指定されたすべてのディレクトリを処理できる。 - 式の評価中にエラーが発生した場合、空のリストが戻り値として使用される。 + マッチした場合、関数は 1 つ以上のファイル名を含む |List| を返す必要が + ある。マッチしない場合、関数は空のリストを返す必要がある。 - 引数なしの関数呼び出しを使用すると高速になる |expr-option-function| + 関数の呼び出し中にエラーが発生した場合、空のリストが戻り値として使用さ + れる。 - 'findexpr' の評価中にテキストを変更したり、別のウィンドウにジャンプし + 'findfunc' の実行中にテキストを変更したり、別のウィンドウにジャンプし たりすることはできない。|textlock| セキュリティ上の理由から、このオプションを |modeline| または |sandbox| @@ -3603,17 +3610,18 @@ Note 1番目の形式では、行全体がオプション指定に使われる 例: > " glob() を使う - func FindExprGlob() - return glob(v:fname, v:false, v:true) + 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 " 'git ls-files' の出力を使う - 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' 切替 (既定ではオン) diff --git a/en/options.txt b/en/options.txt index 229ce13fd..f9189e59a 100644 --- a/en/options.txt +++ b/en/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 9.1. Last change: 2024 Oct 22 +*options.txt* For Vim version 9.1. Last change: 2024 Nov 06 VIM REFERENCE MANUAL by Bram Moolenaar @@ -439,10 +439,11 @@ Note: In the future more global options can be made |global-local|. Using ":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. "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. "123". +Examples: > set opfunc=MyOpFunc set opfunc=function('MyOpFunc') @@ -3514,7 +3515,7 @@ A jump table for the options with a short description can be found at |Q_op|. Only alphanumeric characters, '-' and '_' can be used. *'fillchars'* *'fcs'* -'fillchars' 'fcs' string (default "vert:|,fold:-,eob:~") +'fillchars' 'fcs' string (default "vert:|,fold:-,eob:~,lastline:@") global or local to window |global-local| Characters to fill the statuslines, vertical separators and special lines in the window. @@ -3552,32 +3553,36 @@ A jump table for the options with a short description can be found at |Q_op|. 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. - 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 + 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 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. @@ -3585,17 +3590,18 @@ A jump table for the options with a short description can be found at |Q_op|. Examples: > " Use glob() - func FindExprGlob() - return glob(v:fname, v:false, v:true) + 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)