mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 10:55:40 +00:00
vim-patch:7.4.414
Problem: Cannot define a command only when it's used.
Solution: Add the CmdUndefined autocommand event. (partly by Yasuhiro
Matsumoto)
https://code.google.com/p/vim/source/detail?r=v7-4-414
This commit is contained in:
@@ -1459,6 +1459,24 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
||||
/* Find the command and let "p" point to after it. */
|
||||
p = find_command(&ea, NULL);
|
||||
|
||||
// If this looks like an undefined user command and there are CmdUndefined
|
||||
// autocommands defined, trigger the matching autocommands.
|
||||
if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip
|
||||
&& ASCII_ISUPPER(*ea.cmd)
|
||||
&& has_cmdundefined()) {
|
||||
char_u *p = ea.cmd;
|
||||
|
||||
while (ASCII_ISALNUM(*p)) {
|
||||
++p;
|
||||
}
|
||||
p = vim_strnsave(ea.cmd, p - ea.cmd);
|
||||
int ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL);
|
||||
free(p);
|
||||
if (ret && !aborting()) {
|
||||
p = find_command(&ea, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (p == NULL) {
|
||||
if (!ea.skip)
|
||||
errormsg = (char_u *)_("E464: Ambiguous use of user-defined command");
|
||||
|
||||
Reference in New Issue
Block a user