diff --git a/doc/if_pyth.jax b/doc/if_pyth.jax index 046356f82..bbcf6ed1f 100644 --- a/doc/if_pyth.jax +++ b/doc/if_pyth.jax @@ -1,4 +1,4 @@ -*if_pyth.txt* For Vim バージョン 9.1. Last change: 2024 May 16 +*if_pyth.txt* For Vim バージョン 9.1. Last change: 2024 Nov 06 VIMリファレンスマニュアル by Paul Moore @@ -196,6 +196,10 @@ vim.eval(str) *python-eval* [{'cmd': '/^eval_expr(arg, nextcmd)$/', 'static': 0, 'name': ~ 'eval_expr', 'kind': 'f', 'filename': './src/eval.c'}] ~ + NOTE: vim9script では、def 関数内のローカル変数は Python の評価では見 + えません。ローカル変数を Python の評価に渡すには、|py3eval()| 等を呼び + 出すときに {locals} 辞書を使用します。 + vim.bindeval(str) *python-bindeval* |python-eval| と似ていますが、特殊なオブジェクトを返します (|python-bindeval-objects| 参照)。これを使うと Vim のリスト (|List|) @@ -730,6 +734,10 @@ vim.Function オブジェクト *python-Function* 使って Python の式を評価して、その値を Vim script に渡すことができます。 |pyxeval()| も使用可能です。 +オプションの {locals} 辞書を使用して、評価にローカル変数を挿入できます。これ +は、vim.eval |python-eval| が def 関数内のローカル変数を見つけられない +vim9script で特に役立ちます。 + Python での "None" は v:none に変換されます。 ============================================================================== diff --git a/en/if_pyth.txt b/en/if_pyth.txt index 623684152..0b6140f25 100644 --- a/en/if_pyth.txt +++ b/en/if_pyth.txt @@ -1,4 +1,4 @@ -*if_pyth.txt* For Vim version 9.1. Last change: 2024 May 16 +*if_pyth.txt* For Vim version 9.1. Last change: 2024 Nov 06 VIM REFERENCE MANUAL by Paul Moore @@ -201,6 +201,10 @@ vim.eval(str) *python-eval* [{'cmd': '/^eval_expr(arg, nextcmd)$/', 'static': 0, 'name': ~ 'eval_expr', 'kind': 'f', 'filename': './src/eval.c'}] ~ + NOTE: In vim9script, local variables in def functions are not visible + to to python evaluations. To pass local variables to python evaluations, + use the {locals} dict when calling |py3eval()| and friends. + vim.bindeval(str) *python-bindeval* Like |python-eval|, but returns special objects described in |python-bindeval-objects|. These python objects let you modify (|List| @@ -741,6 +745,10 @@ To facilitate bi-directional interface, you can use |pyeval()| and |py3eval()| functions to evaluate Python expressions and pass their values to Vim script. |pyxeval()| is also available. +You can inject local variables into the evaluation using the optional {locals} +dict. This can be particularly useful in vim9script where vim.eval +|python-eval| will not find locals in a def func. + The Python value "None" is converted to v:none. ==============================================================================