aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2014-11-11 12:46:08 -0500
committerJustin M. Keyes <justinkz@gmail.com>2014-11-11 12:46:08 -0500
commitb1e06c6d60f4947794851982eb73db6ef3b64fbf (patch)
tree22feb7e133de02452e2dc437d9152b34a13376c8 /src/nvim/ex_docmd.c
parentb027e1ed0c92ed49961ecbd24228967d916c2bbd (diff)
parentbffea01c89bfe2c93169f65b50653d63dcb8e035 (diff)
downloadrneovim-b1e06c6d60f4947794851982eb73db6ef3b64fbf.tar.gz
rneovim-b1e06c6d60f4947794851982eb73db6ef3b64fbf.tar.bz2
rneovim-b1e06c6d60f4947794851982eb73db6ef3b64fbf.zip
Merge pull request #1282 from splinterofchaos/cmd-undef
vim-patch:7.4.414 + vim-patch:7.4.415
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 67c346237c..134def0c2c 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1459,6 +1459,23 @@ 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()) {
+ 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");