diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-08-22 23:05:54 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-08-22 23:05:54 +0200 |
commit | d5005164e1f367136c956d2941478a3aea30ec47 (patch) | |
tree | 08ea4c1c98bcb7ad6f24040825faa4c6493e1bae /src/ex_docmd.c | |
parent | fb539273c95f95e18e9542c2de3318b1b1e73db6 (diff) | |
download | vim-git-d5005164e1f367136c956d2941478a3aea30ec47.tar.gz |
updated for version 7.4.414v7.4.414
Problem: Cannot define a command only when it's used.
Solution: Add the CmdUndefined autocommand event. (partly by Yasuhiro
Matsumoto)
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r-- | src/ex_docmd.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index fecb653b5..682695173 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -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) { |