Skip to content

Commit 8844e09

Browse files
authored
Merge pull request #1279 from vim-jp/hh-update-builtin
Update builtin.{txt,jax} only autocmd_{add,delete,get)
2 parents a505a29 + 767da1b commit 8844e09

File tree

2 files changed

+320
-9
lines changed

2 files changed

+320
-9
lines changed

doc/builtin.jax

Lines changed: 161 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
組み込み関数 *builtin-functions*
88

9-
Note: 式の評価はコンパイル時に無効することができる。そうした場合は、組み込み関
10-
数は利用できない。|+eval||no-eval-feature| を参照。
9+
Note: 式の評価はコンパイル時に無効することができる。その場合、組み込み関数は使
10+
用できない。|+eval||no-eval-feature| を参照。
11+
12+
使用目的別に分類された関数については、|function-list| を参照。
1113

1214
1. 概要 |builtin-function-list|
1315
2. 詳細 |builtin-function-details|
@@ -64,6 +66,9 @@ assert_true({actual} [, {msg}])
6466
atan({expr}) 浮動小数点数 {expr}のアークタンジェント
6567
atan2({expr1}, {expr2}) 浮動小数点数 {expr1} / {expr2} のアークタン
6668
ジェント
69+
autocmd_add({acmds}) 真偽値 自動コマンドとグループのリストを追加
70+
autocmd_delete({acmds}) 真偽値 自動コマンドとグループのリストを削除
71+
autocmd_get([{opts}]) リスト 自動コマンドのリストを返す
6772
balloon_gettext() 文字列 バルーン内のカレントテキストを得る
6873
balloon_show({expr}) なし {expr} をバルーン内に表示
6974
balloon_split({msg}) リスト {msg} をバルーンで使われるように分割す
@@ -981,9 +986,161 @@ atan2({expr1}, {expr2}) *atan2()*
981986

982987
|method| としても使用できる: >
983988
Compute()->atan2(1)
984-
<
985-
{|+float| 機能を有効にしてコンパイルしたときのみ有効}
986989
990+
991+
autocmd_add({acmds}) *autocmd_add()*
992+
自動コマンドと自動コマンドグループを追加する。
993+
994+
引数 {acmds} は、各項目が以下のオプション項目を持つ辞書のリス
995+
トである:
996+
bufnr バッファローカルな自動コマンドを追加するための
997+
バッファ番号。この項目を指定した場合、
998+
"pattern" 項目は無視される。
999+
cmd この自動コマンドイベントに対して実行する Ex コ
1000+
マンド
1001+
event 自動コマンドイベント名。|autocmd-events| を参
1002+
照。これは、単一のイベント名の文字列またはイベ
1003+
ント名のリストのどちらかである。
1004+
group 自動コマンドグループ名。|autocmd-groups| を参
1005+
照。グループが存在しない場合は作成される。指定
1006+
しない場合、または空の場合は、デフォルトのグ
1007+
ループが使用される。
1008+
nested 真偽値フラグ。v:true に設定すると、ネストされ
1009+
た自動コマンドを追加する。|autocmd-nested|
1010+
参照。
1011+
once 真偽値フラグ。v:true に設定すると、一度だけ実
1012+
行される自動コマンドが追加される。
1013+
|autocmd-once| を参照。
1014+
pattern 自動コマンドパターン文字列。|autocmd-patterns|
1015+
を参照。"bufnr" 項目が存在する場合、この項目は
1016+
無視される。単一のパターンを持つ文字列またはパ
1017+
ターンのリストにすることができる。
1018+
replace 真偽値フラグ。v:true に設定すると、指定された
1019+
自動コマンドイベントおよびグループに関連付けら
1020+
れたすべてのコマンドが削除され、{cmd} が追加さ
1021+
れる。これは、グループ内の自動コマンドイベント
1022+
に対して同じコマンドを複数回追加することを避け
1023+
るのに役立つ。
1024+
1025+
成功した場合は v:true を返し、失敗した場合は v:false を返す。
1026+
例: >
1027+
" バッファ 5 のバッファローカルな自動コマンドを作成
1028+
let acmd = {}
1029+
let acmd.group = 'MyGroup'
1030+
let acmd.event = 'BufEnter'
1031+
let acmd.bufnr = 5
1032+
let acmd.cmd = 'call BufEnterFunc()'
1033+
call autocmd_add([acmd])
1034+
<
1035+
|method| としても使用できる: >
1036+
GetAutocmdList()->autocmd_add()
1037+
<
1038+
autocmd_delete({acmds}) *autocmd_delete()*
1039+
自動コマンドと自動コマンドグループを削除する。
1040+
1041+
引数 {acmds} は、各項目が以下のオプション項目を持つ辞書のリス
1042+
トである:
1043+
bufnr バッファローカルな自動コマンドを削除するための
1044+
バッファ番号。この項目を指定した場合、
1045+
"pattern" 項目は無視される。
1046+
cmd この自動コマンドイベントに対して実行する Ex コ
1047+
マンド
1048+
event 自動コマンドイベント名。|autocmd-events| を参
1049+
'*' の場合、このグループ内のすべての自動コマン
1050+
ドイベントが削除される。
1051+
group 自動コマンドグループ名。|autocmd-groups| を参
1052+
照。指定なし、または空の場合は、デフォルトのグ
1053+
ループが使用される。
1054+
nested ネストされた自動コマンドの場合は v:true に設定
1055+
する。|autocmd-nested| を参照。
1056+
once 一度だけ実行される自動コマンドの場合は v:true
1057+
に設定する。|autocmd-once| を参照。
1058+
pattern 自動コマンドパターン文字列。|autocmd-patterns|
1059+
を参照。"bufnr" 項目が存在する場合、この項目は
1060+
無視される。
1061+
1062+
{acmds} エントリで {group} のみが指定されており、{event}
1063+
{pattern}、および {cmd} が指定されていない場合、その自動コマン
1064+
ドグループは削除される。
1065+
1066+
成功した場合は v:true を返し、失敗した場合は v:false を返す。
1067+
例: >
1068+
" :autocmd! BufLeave *.vim
1069+
let acmd = #{event: 'BufLeave', pattern: '*.vim'}
1070+
call autocmd_delete([acmd]})
1071+
" :autocmd! MyGroup1 BufLeave
1072+
let acmd = #{group: 'MyGroup1', event: 'BufLeave'}
1073+
call autocmd_delete([acmd])
1074+
" :autocmd! MyGroup2 BufEnter *.c
1075+
let acmd = #{group: 'MyGroup2', event: 'BufEnter',
1076+
\ pattern: '*.c'}
1077+
" :autocmd! MyGroup2 * *.c
1078+
let acmd = #{group: 'MyGroup2', event: '*',
1079+
\ pattern: '*.c'}
1080+
call autocmd_delete([acmd])
1081+
" :autocmd! MyGroup3
1082+
let acmd = #{group: 'MyGroup3'}
1083+
call autocmd_delete([acmd])
1084+
<
1085+
|method| としても使用できる: >
1086+
GetAutocmdList()->autocmd_delete()
1087+
1088+
autocmd_get([{opts}]) *autocmd_get()*
1089+
自動コマンドの |List| を返す。{opts} が指定されていない場合は、
1090+
すべてのグループのすべてのイベントの自動コマンドを返す。
1091+
1092+
オプションの {opts} 辞書引数は、以下の項目をサポートする:
1093+
group 自動コマンドグループ名。指定した場合、このグ
1094+
ループで定義されている自動コマンドのみを返す。
1095+
指定したグループが存在しない場合は、エラーメッ
1096+
セージが表示される。空の文字列を設定すると、デ
1097+
フォルトの自動コマンドグループが使用される。
1098+
event 自動コマンドイベント名。指定した場合、このイベ
1099+
ントに定義された自動コマンドのみを返す。"*" を
1100+
設定すると、すべてのイベントの自動コマンドが返
1101+
される。指定したイベントが存在しない場合は、エ
1102+
ラーメッセージが表示される。
1103+
pattern 自動コマンドパターン。指定した場合、このパター
1104+
ンに定義されている自動コマンドのみを返す。
1105+
上記 3 つの組み合わせを {opts} で指定できる。
1106+
1107+
返されたリストの各辞書には次の項目が含まれる:
1108+
bufnr バッファローカルな自動コマンドの場合、自動コマ
1109+
ンドが定義されているバッファ番号。
1110+
cmd 自動コマンドに対して実行されたコマンド。
1111+
event 自動コマンドイベント名。
1112+
group 自動コマンドグループ名。
1113+
nested Booleanフラグ。ネストされた自動コマンドの場合、
1114+
v:true が設定される。|autocmd-nested| を参照。
1115+
once Booleanフラグ。自動コマンドが 1 回だけ実行され
1116+
る場合は、v:true に設定する。|autocmd-once|
1117+
参照。
1118+
pattern 自動コマンドパターン。バッファローカルな自動コ
1119+
マンドの場合、"<buffer=n>" の形式になる。
1120+
グループ内の自動コマンドイベントに複数のコマンドがある場合、コ
1121+
マンドごとに個別の項目が返される。
1122+
1123+
指定されたグループ、イベント、またはパターンを持つ自動コマンド
1124+
が見つからない場合は、空のリストを返す。
1125+
1126+
例: >
1127+
" :autocmd MyGroup
1128+
echo autocmd_get(#{group: 'Mygroup'})
1129+
" :autocmd G BufUnload
1130+
echo autocmd_get(#{group: 'G', event: 'BufUnload'})
1131+
" :autocmd G * *.ts
1132+
let acmd = #{group: 'G', event: '*', pattern: '*.ts'}
1133+
echo autocmd_get(acmd)
1134+
" :autocmd Syntax
1135+
echo autocmd_get(#{event: 'Syntax'})
1136+
" :autocmd G BufEnter *.ts
1137+
let acmd = #{group: 'G', event: 'BufEnter',
1138+
\ pattern: '*.ts'}
1139+
echo autocmd_get(acmd)
1140+
<
1141+
|method| としても使用できる: >
1142+
Getopts()->autocmd_get()
1143+
<
9871144
balloon_gettext() *balloon_gettext()*
9881145
バルーン内の現在のテキストを返す。文字列に対してのみ使用され、
9891146
リストには使用されない。

en/builtin.txt

Lines changed: 159 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
Builtin functions *builtin-functions*
88

9-
Note: Expression evaluation can be disabled at compile time. If this has been
10-
done, the builtin functions are not available. See |+eval| and
11-
|no-eval-feature|.
9+
Note: Expression evaluation can be disabled at compile time, the builtin
10+
functions are not available then. See |+eval| and |no-eval-feature|.
11+
12+
For functions grouped by what they are used for see |function-list|.
1213

1314
1. Overview |builtin-function-list|
1415
2. Details |builtin-function-details|
@@ -60,6 +61,9 @@ assert_report({msg}) Number report a test failure
6061
assert_true({actual} [, {msg}]) Number assert {actual} is true
6162
atan({expr}) Float arc tangent of {expr}
6263
atan2({expr1}, {expr2}) Float arc tangent of {expr1} / {expr2}
64+
autocmd_add({acmds}) Bool add a list of autocmds and groups
65+
autocmd_delete({acmds}) Bool delete a list of autocmds and groups
66+
autocmd_get([{opts}]) List return a list of autocmds
6367
balloon_gettext() String current text in the balloon
6468
balloon_show({expr}) none show {expr} inside the balloon
6569
balloon_split({msg}) List split {msg} as used for a balloon
@@ -921,9 +925,159 @@ atan2({expr1}, {expr2}) *atan2()*
921925

922926
Can also be used as a |method|: >
923927
Compute()->atan2(1)
924-
<
925-
{only available when compiled with the |+float| feature}
926928
929+
930+
autocmd_add({acmds}) *autocmd_add()*
931+
Adds a List of autocmds and autocmd groups.
932+
933+
The {acmds} argument is a List where each item is a Dict with
934+
the following optional items:
935+
bufnr buffer number to add a buffer-local autocmd.
936+
If this item is specified, then the "pattern"
937+
item is ignored.
938+
cmd Ex command to execute for this autocmd event
939+
event autocmd event name. Refer to |autocmd-events|.
940+
This can be either a String with a single
941+
event name or a List of event names.
942+
group autocmd group name. Refer to |autocmd-groups|.
943+
If this group doesn't exist then it is
944+
created. If not specified or empty, then the
945+
default group is used.
946+
nested boolean flag, set to v:true to add a nested
947+
autocmd. Refer to |autocmd-nested|.
948+
once boolean flag, set to v:true to add an autocmd
949+
which executes only once. Refer to
950+
|autocmd-once|.
951+
pattern autocmd pattern string. Refer to
952+
|autocmd-patterns|. If "bufnr" item is
953+
present, then this item is ignored. This can
954+
be a String with a single pattern or a List of
955+
patterns.
956+
replace boolean flag, set to v:true to remove all the
957+
commands associated with the specified autocmd
958+
event and group and add the {cmd}. This is
959+
useful to avoid adding the same command
960+
multiple times for an autocmd event in a group.
961+
962+
Returns v:true on success and v:false on failure.
963+
Examples: >
964+
" Create a buffer-local autocmd for buffer 5
965+
let acmd = {}
966+
let acmd.group = 'MyGroup'
967+
let acmd.event = 'BufEnter'
968+
let acmd.bufnr = 5
969+
let acmd.cmd = 'call BufEnterFunc()'
970+
call autocmd_add([acmd])
971+
<
972+
Can also be used as a |method|: >
973+
GetAutocmdList()->autocmd_add()
974+
<
975+
autocmd_delete({acmds}) *autocmd_delete()*
976+
Deletes a List of autocmds and autocmd groups.
977+
978+
The {acmds} argument is a List where each item is a Dict with
979+
the following optional items:
980+
bufnr buffer number to delete a buffer-local autocmd.
981+
If this item is specified, then the "pattern"
982+
item is ignored.
983+
cmd Ex command for this autocmd event
984+
event autocmd event name. Refer to |autocmd-events|.
985+
If '*' then all the autocmd events in this
986+
group are deleted.
987+
group autocmd group name. Refer to |autocmd-groups|.
988+
If not specified or empty, then the default
989+
group is used.
990+
nested set to v:true for a nested autocmd.
991+
Refer to |autocmd-nested|.
992+
once set to v:true for an autocmd which executes
993+
only once. Refer to |autocmd-once|.
994+
pattern autocmd pattern string. Refer to
995+
|autocmd-patterns|. If "bufnr" item is
996+
present, then this item is ignored.
997+
998+
If only {group} is specified in a {acmds} entry and {event},
999+
{pattern} and {cmd} are not specified, then that autocmd group
1000+
is deleted.
1001+
1002+
Returns |v:true| on success and |v:false| on failure.
1003+
Examples: >
1004+
" :autocmd! BufLeave *.vim
1005+
let acmd = #{event: 'BufLeave', pattern: '*.vim'}
1006+
call autocmd_delete([acmd]})
1007+
" :autocmd! MyGroup1 BufLeave
1008+
let acmd = #{group: 'MyGroup1', event: 'BufLeave'}
1009+
call autocmd_delete([acmd])
1010+
" :autocmd! MyGroup2 BufEnter *.c
1011+
let acmd = #{group: 'MyGroup2', event: 'BufEnter',
1012+
\ pattern: '*.c'}
1013+
" :autocmd! MyGroup2 * *.c
1014+
let acmd = #{group: 'MyGroup2', event: '*',
1015+
\ pattern: '*.c'}
1016+
call autocmd_delete([acmd])
1017+
" :autocmd! MyGroup3
1018+
let acmd = #{group: 'MyGroup3'}
1019+
call autocmd_delete([acmd])
1020+
<
1021+
Can also be used as a |method|: >
1022+
GetAutocmdList()->autocmd_delete()
1023+
1024+
autocmd_get([{opts}]) *autocmd_get()*
1025+
Returns a |List| of autocmds. If {opts} is not supplied, then
1026+
returns the autocmds for all the events in all the groups.
1027+
1028+
The optional {opts} Dict argument supports the following
1029+
items:
1030+
group Autocmd group name. If specified, returns only
1031+
the autocmds defined in this group. If the
1032+
specified group doesn't exist, results in an
1033+
error message. If set to an empty string,
1034+
then the default autocmd group is used.
1035+
event Autocmd event name. If specified, returns only
1036+
the autocmds defined for this event. If set
1037+
to "*", then returns autocmds for all the
1038+
events. If the specified event doesn't exist,
1039+
results in an error message.
1040+
pattern Autocmd pattern. If specified, returns only
1041+
the autocmds defined for this pattern.
1042+
A combination of the above three times can be supplied in
1043+
{opts}.
1044+
1045+
Each Dict in the returned List contains the following items:
1046+
bufnr For buffer-local autocmds, buffer number where
1047+
the autocmd is defined.
1048+
cmd Command executed for this autocmd.
1049+
event Autocmd event name.
1050+
group Autocmd group name.
1051+
nested Boolean flag, set to v:true for a nested
1052+
autocmd. See |autocmd-nested|.
1053+
once Boolean flag, set to v:true, if the autocmd
1054+
will be executed only once. See |autocmd-once|.
1055+
pattern Autocmd pattern. For a buffer-local
1056+
autocmd, this will be of the form "<buffer=n>".
1057+
If there are multiple commands for an autocmd event in a
1058+
group, then separate items are returned for each command.
1059+
1060+
Returns an empty List if an autocmd with the specified group
1061+
or event or pattern is not found.
1062+
1063+
Examples: >
1064+
" :autocmd MyGroup
1065+
echo autocmd_get(#{group: 'Mygroup'})
1066+
" :autocmd G BufUnload
1067+
echo autocmd_get(#{group: 'G', event: 'BufUnload'})
1068+
" :autocmd G * *.ts
1069+
let acmd = #{group: 'G', event: '*', pattern: '*.ts'}
1070+
echo autocmd_get(acmd)
1071+
" :autocmd Syntax
1072+
echo autocmd_get(#{event: 'Syntax'})
1073+
" :autocmd G BufEnter *.ts
1074+
let acmd = #{group: 'G', event: 'BufEnter',
1075+
\ pattern: '*.ts'}
1076+
echo autocmd_get(acmd)
1077+
<
1078+
Can also be used as a |method|: >
1079+
Getopts()->autocmd_get()
1080+
<
9271081
balloon_gettext() *balloon_gettext()*
9281082
Return the current text in the balloon. Only for the string,
9291083
not used for the List.

0 commit comments

Comments
 (0)