0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

updated for version 7.4.414

Problem:    Cannot define a command only when it's used.
Solution:   Add the CmdUndefined autocommand event. (partly by Yasuhiro
            Matsumoto)
This commit is contained in:
Bram Moolenaar
2014-08-22 23:05:54 +02:00
parent fb539273c9
commit d5005164e1
5 changed files with 56 additions and 0 deletions

View File

@@ -2143,6 +2143,26 @@ do_one_cmd(cmdlinep, sourcing,
/* Find the command and let "p" point to after it. */
p = find_command(&ea, NULL);
#ifdef FEAT_AUTOCMD
/* 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;
int ret;
while (ASCII_ISALNUM(*p))
++p;
p = vim_strnsave(ea.cmd, p - ea.cmd);
ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL);
vim_free(p);
if (ret && !aborting())
p = find_command(&ea, NULL);
}
#endif
#ifdef FEAT_USR_CMDS
if (p == NULL)
{