From 9cb39dcb7aa193c845271f1034cbdf86bd417f2c Mon Sep 17 00:00:00 2001 From: h-east Date: Sat, 1 Nov 2025 16:27:12 +0900 Subject: [PATCH] Update userfunc.{txt,jax} --- doc/userfunc.jax | 19 ++++++++++++++----- en/userfunc.txt | 15 ++++++++++++--- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/doc/userfunc.jax b/doc/userfunc.jax index 6e768984b..abdb6eb71 100644 --- a/doc/userfunc.jax +++ b/doc/userfunc.jax @@ -1,4 +1,4 @@ -*userfunc.txt* For Vim バージョン 9.1. Last change: 2025 Oct 12 +*userfunc.txt* For Vim バージョン 9.1. Last change: 2025 Oct 28 VIM リファレンスマニュアル by Bram Moolenaar @@ -182,10 +182,10 @@ ! が付いていると、関数が存在していなくてもエラーが発生 しない。 *:retu* *:return* *E133* -:retu[rn] [expr] 関数から戻る。"[expr]" が与えられた場合、それは評価さ - れ関数の結果として返される。"[expr]" が与えられない場 - 合、数値 0 が返される。関数が明示的な ":return" を伴わ - ずに終了した場合、数値 0 が返される。 +:retu[rn] [expr] 関数から戻る。[expr] が与えられた場合、それは評価され + 関数の結果として返される。[expr] が与えられない場合、 + 数値 0 が返される。関数が明示的な ":return" を伴わずに + 終了した場合、数値 0 が返される。 :def 関数内で到達不可能なコードが `:return` の後に続く 場合、 *E1095* が与えられる。 @@ -422,6 +422,15 @@ Note `system()` を呼ぶ前で "Outfile" 削除がスケジュールされて 範囲は使えない。関数として追加の引数付きの部分適用は使えるが、辞書は使えない。 *E1300* +|:def| 関数では、ラムダ式を |:defer| とともに使用できる。例: > + + def Fn() + set lazyredraw + defer () => { + set lazyredraw& + }() + enddef +< ============================================================================== 4. 自動的に読み込まれる関数 ~ diff --git a/en/userfunc.txt b/en/userfunc.txt index 5b3605a14..aa8ed9ec8 100644 --- a/en/userfunc.txt +++ b/en/userfunc.txt @@ -1,4 +1,4 @@ -*userfunc.txt* For Vim version 9.1. Last change: 2025 Oct 12 +*userfunc.txt* For Vim version 9.1. Last change: 2025 Oct 28 VIM REFERENCE MANUAL by Bram Moolenaar @@ -189,9 +189,9 @@ See |:verbose-cmd| for more information. With the ! there is no error if the function does not exist. *:retu* *:return* *E133* -:retu[rn] [expr] Return from a function. When "[expr]" is given, it is +:retu[rn] [expr] Return from a function. When [expr] is given, it is evaluated and returned as the result of the function. - If "[expr]" is not given, the number 0 is returned. + If [expr] is not given, the number 0 is returned. When a function ends without an explicit ":return", the number 0 is returned. @@ -449,6 +449,15 @@ or altering execution outside of deferred functions. No range is accepted. The function can be a partial with extra arguments, but not with a dictionary. *E1300* +In a |:def| function, a lambda can be used with |:defer|. Example: > + + def Fn() + set lazyredraw + defer () => { + set lazyredraw& + }() + enddef +< ============================================================================== 4. Automatically loading functions ~