:doautocmd : Never show "No matching autocommands" #10689

The message is useless, it doesn't even mention the event name.

vim_dev discussion:
https://groups.google.com/forum/#!msg/vim_dev/RTbq58TMq9w/Xr4rSoUTCgAJ

ref: https://github.com/vim/vim/issues/4300
This commit is contained in:
Justin M. Keyes 2019-08-05 03:33:45 +02:00 committed by GitHub
parent 01ddb39699
commit 45c34bd84a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 18 deletions

View File

@ -1087,14 +1087,12 @@ TextChangedP After a change was made to the text in the
popup menu is visible. Otherwise the same as popup menu is visible. Otherwise the same as
TextChanged. TextChanged.
*User* *User*
User Never executed automatically. To be used for User Not executed automatically. Use |:doautocmd|
autocommands that are only executed with to trigger this, typically for "custom events"
":doautocmd". in a plugin. Example: >
Note that when `:doautocmd User MyEvent` is :autocmd User MyPlugin echom 'got MyPlugin event'
used while there are no matching autocommands, :doautocmd User MyPlugin
you will get an error. If you don't want < *UserGettingBored*
that, define a dummy autocommand yourself.
*UserGettingBored*
UserGettingBored When the user presses the same key 42 times. UserGettingBored When the user presses the same key 42 times.
Just kidding! :-) Just kidding! :-)
*VimEnter* *VimEnter*
@ -1389,18 +1387,17 @@ option will not cause any commands to be executed.
When the [group] argument is not given, Vim executes When the [group] argument is not given, Vim executes
the autocommands for all groups. When the [group] the autocommands for all groups. When the [group]
argument is included, Vim executes only the matching argument is included, Vim executes only the matching
autocommands for that group. Note: if you use an autocommands for that group. Undefined group is an
undefined group name, Vim gives you an error message. error.
*<nomodeline>* *<nomodeline>*
After applying the autocommands the modelines are After applying the autocommands the modelines are
processed, so that their settings overrule the processed, so that their settings overrule the
settings from autocommands, like what happens when settings from autocommands when editing a file. This
editing a file. This is skipped when the <nomodeline> is skipped if <nomodeline> is specified. You probably
argument is present. You probably want to use want to use <nomodeline> for events not used when
<nomodeline> for events that are not used when loading loading a buffer, such as |User|.
a buffer, such as |User|. Modelines are also skipped when no matching
Processing modelines is also skipped when no autocommands were executed.
matching autocommands were executed.
*:doautoa* *:doautoall* *:doautoa* *:doautoall*
:doautoa[ll] [<nomodeline>] [group] {event} [fname] :doautoa[ll] [<nomodeline>] [group] {event} [fname]

View File

@ -310,6 +310,9 @@ other arguments if used).
|input()| and |inputdialog()| support user-defined cmdline highlighting. |input()| and |inputdialog()| support user-defined cmdline highlighting.
Commands:
|:doautocmd| does not warn about "No matching autocommands".
Highlight groups: Highlight groups:
|hl-ColorColumn|, |hl-CursorColumn| are lower priority than most other |hl-ColorColumn|, |hl-CursorColumn| are lower priority than most other
groups groups

View File

@ -4614,7 +4614,7 @@ static void ex_doautocmd(exarg_T *eap)
int call_do_modelines = check_nomodeline(&arg); int call_do_modelines = check_nomodeline(&arg);
bool did_aucmd; bool did_aucmd;
(void)do_doautocmd(arg, true, &did_aucmd); (void)do_doautocmd(arg, false, &did_aucmd);
// Only when there is no <nomodeline>. // Only when there is no <nomodeline>.
if (call_do_modelines && did_aucmd) { if (call_do_modelines && did_aucmd) {
do_modelines(0); do_modelines(0);

View File

@ -260,4 +260,26 @@ describe('autocmd', function()
eq({false, 'Vim(call):E5555: API call: Invalid window id'}, eq({false, 'Vim(call):E5555: API call: Invalid window id'},
meth_pcall(command, "call nvim_set_current_win(g:winid)")) meth_pcall(command, "call nvim_set_current_win(g:winid)"))
end) end)
it(':doautocmd does not warn "No matching autocommands" #10689', function()
local screen = Screen.new(32, 3)
screen:attach()
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue1},
})
feed(':doautocmd User Foo<cr>')
screen:expect{grid=[[
^ |
{1:~ }|
:doautocmd User Foo |
]]}
feed(':autocmd! SessionLoadPost<cr>')
feed(':doautocmd SessionLoadPost<cr>')
screen:expect{grid=[[
^ |
{1:~ }|
:doautocmd SessionLoadPost |
]]}
end)
end) end)