aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c18
-rw-r--r--src/nvim/fileio.c13
-rw-r--r--src/nvim/version.c2
3 files changed, 32 insertions, 1 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 67c346237c..7e0122acd2 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -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");
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 4486d43578..b20150b2c9 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -5198,6 +5198,7 @@ static struct event_name {
{"BufWriteCmd", EVENT_BUFWRITECMD},
{"CmdwinEnter", EVENT_CMDWINENTER},
{"CmdwinLeave", EVENT_CMDWINLEAVE},
+ {"CmdUndefined", EVENT_CMDUNDEFINED},
{"ColorScheme", EVENT_COLORSCHEME},
{"CompleteDone", EVENT_COMPLETEDONE},
{"CursorHold", EVENT_CURSORHOLD},
@@ -6462,6 +6463,18 @@ int has_insertcharpre(void)
return first_autopat[(int)EVENT_INSERTCHARPRE] != NULL;
}
+/// @returns true when there is an CmdUndefined autocommand defined.
+int has_cmdundefined(void)
+{
+ return first_autopat[(int)EVENT_CMDUNDEFINED] != NULL;
+}
+
+/// @returns true when there is an FuncUndefined autocommand defined.
+int has_funcundefined(void)
+{
+ return first_autopat[(int)EVENT_FUNCUNDEFINED] != NULL;
+}
+
static int
apply_autocmds_group (
event_T event,
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 137f85bb2b..7f80c57242 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -251,7 +251,7 @@ static int included_patches[] = {
//417,
//416,
//415,
- //414,
+ 414,
//413 NA
//412 NA
411,