Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion doc/if_pyth.jax
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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|)
Expand Down Expand Up @@ -730,6 +734,10 @@ vim.Function オブジェクト *python-Function*
使って Python の式を評価して、その値を Vim script に渡すことができます。
|pyxeval()| も使用可能です。

オプションの {locals} 辞書を使用して、評価にローカル変数を挿入できます。これ
は、vim.eval |python-eval| が def 関数内でローカル変数を見つけられない
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

自分の英語力不足でどっちか判断つかなかったのでコメントだけ。
"vim.eval |python-eval| will not find locals in a def func." の "in def func" の "in" がこの文節にかかってるならこのままで良いのですが、直前の "locals" にかかってるなら「def 関数内のローカル変数を〜」という感じの訳の方が良さげだなあと。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

後者がしっくりきそうなのでそちらの訳にします 👍

vim9script で特に役立ちます。

Python での "None" は v:none に変換されます。

==============================================================================
Expand Down
10 changes: 9 additions & 1 deletion en/if_pyth.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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.

==============================================================================
Expand Down