summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-08-22 23:05:54 +0200
committerBram Moolenaar <Bram@vim.org>2014-08-22 23:05:54 +0200
commitd5005164e1f367136c956d2941478a3aea30ec47 (patch)
tree08ea4c1c98bcb7ad6f24040825faa4c6493e1bae /src
parentfb539273c95f95e18e9542c2de3318b1b1e73db6 (diff)
downloadvim-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')
-rw-r--r--src/ex_docmd.c20
-rw-r--r--src/fileio.c19
-rw-r--r--src/proto/fileio.pro2
-rw-r--r--src/version.c2
4 files changed, 43 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)
{
diff --git a/src/fileio.c b/src/fileio.c
index 17490ac21..f2d204078 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7641,6 +7641,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},
@@ -9159,6 +9160,24 @@ has_insertcharpre()
return (first_autopat[(int)EVENT_INSERTCHARPRE] != NULL);
}
+/*
+ * Return TRUE when there is an CmdUndefined autocommand defined.
+ */
+ int
+has_cmdundefined()
+{
+ return (first_autopat[(int)EVENT_CMDUNDEFINED] != NULL);
+}
+
+/*
+ * Return TRUE when there is an FuncUndefined autocommand defined.
+ */
+ int
+has_funcundefined()
+{
+ return (first_autopat[(int)EVENT_FUNCUNDEFINED] != NULL);
+}
+
static int
apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
event_T event;
diff --git a/src/proto/fileio.pro b/src/proto/fileio.pro
index 0d532f4ce..5b71d0aad 100644
--- a/src/proto/fileio.pro
+++ b/src/proto/fileio.pro
@@ -47,6 +47,8 @@ int has_cursormovedI __ARGS((void));
int has_textchanged __ARGS((void));
int has_textchangedI __ARGS((void));
int has_insertcharpre __ARGS((void));
+int has_cmdundefined __ARGS((void));
+int has_funcundefined __ARGS((void));
void block_autocmds __ARGS((void));
void unblock_autocmds __ARGS((void));
int is_autocmd_blocked __ARGS((void));
diff --git a/src/version.c b/src/version.c
index e742d187c..ae87bb5a0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 414,
+/**/
413,
/**/
412,