-
-
Save Shougo/90f0c0b67653764d33b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 7af530381fec src/eval.c | |
--- a/src/eval.c Sun Aug 17 17:24:07 2014 +0200 | |
+++ b/src/eval.c Tue Aug 19 03:23:32 2014 +0900 | |
@@ -365,6 +365,7 @@ | |
{VV_NAME("oldfiles", VAR_LIST), 0}, | |
{VV_NAME("windowid", VAR_NUMBER), VV_RO}, | |
{VV_NAME("progpath", VAR_STRING), VV_RO}, | |
+ {VV_NAME("command", VAR_STRING), VV_RO}, | |
}; | |
/* shorthand */ | |
diff -r 7af530381fec src/ex_docmd.c | |
--- a/src/ex_docmd.c Sun Aug 17 17:24:07 2014 +0200 | |
+++ b/src/ex_docmd.c Tue Aug 19 03:23:32 2014 +0900 | |
@@ -2142,6 +2142,16 @@ | |
/* Find the command and let "p" point to after it. */ | |
p = find_command(&ea, NULL); | |
+#ifdef FEAT_AUTOCMD | |
+ if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip && has_commandnotfound()) | |
+ { | |
+ set_vim_var_string(VV_COMMAND, *cmdlinep, -1); | |
+ int ret = apply_autocmds(EVENT_COMMANDNOTFOUND, NULL, NULL, FALSE, curbuf); | |
+ set_vim_var_string(VV_COMMAND, NULL, -1); | |
+ if (ret) | |
+ p = find_command(&ea, NULL); | |
+ } | |
+#endif | |
#ifdef FEAT_USR_CMDS | |
if (p == NULL) | |
diff -r 7af530381fec src/fileio.c | |
--- a/src/fileio.c Sun Aug 17 17:24:07 2014 +0200 | |
+++ b/src/fileio.c Tue Aug 19 03:23:32 2014 +0900 | |
@@ -7642,6 +7642,7 @@ | |
{"CmdwinEnter", EVENT_CMDWINENTER}, | |
{"CmdwinLeave", EVENT_CMDWINLEAVE}, | |
{"ColorScheme", EVENT_COLORSCHEME}, | |
+ {"CommandNotFound", EVENT_COMMANDNOTFOUND}, | |
{"CompleteDone", EVENT_COMPLETEDONE}, | |
{"CursorHold", EVENT_CURSORHOLD}, | |
{"CursorHoldI", EVENT_CURSORHOLDI}, | |
@@ -9159,6 +9160,16 @@ | |
return (first_autopat[(int)EVENT_INSERTCHARPRE] != NULL); | |
} | |
+/* | |
+ * Return TRUE when there is an CommandNotFound autocommand defined. | |
+ */ | |
+ int | |
+has_commandnotfound() | |
+{ | |
+ return (first_autopat[(int)EVENT_COMMANDNOTFOUND] != NULL); | |
+} | |
+ | |
+ | |
static int | |
apply_autocmds_group(event, fname, fname_io, force, group, buf, eap) | |
event_T event; | |
diff -r 7af530381fec src/proto/fileio.pro | |
--- a/src/proto/fileio.pro Sun Aug 17 17:24:07 2014 +0200 | |
+++ b/src/proto/fileio.pro Tue Aug 19 03:23:32 2014 +0900 | |
@@ -47,6 +47,7 @@ | |
int has_textchanged __ARGS((void)); | |
int has_textchangedI __ARGS((void)); | |
int has_insertcharpre __ARGS((void)); | |
+int has_commandnotfound __ARGS((void)); | |
void block_autocmds __ARGS((void)); | |
void unblock_autocmds __ARGS((void)); | |
int is_autocmd_blocked __ARGS((void)); | |
diff -r 7af530381fec src/vim.h | |
--- a/src/vim.h Sun Aug 17 17:24:07 2014 +0200 | |
+++ b/src/vim.h Tue Aug 19 03:23:32 2014 +0900 | |
@@ -1326,6 +1326,7 @@ | |
EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */ | |
EVENT_TEXTCHANGED, /* text was modified */ | |
EVENT_TEXTCHANGEDI, /* text was modified in Insert mode*/ | |
+ EVENT_COMMANDNOTFOUND, /* command not found */ | |
NUM_EVENTS /* MUST be the last one */ | |
}; | |
@@ -1888,7 +1889,8 @@ | |
#define VV_OLDFILES 55 | |
#define VV_WINDOWID 56 | |
#define VV_PROGPATH 57 | |
-#define VV_LEN 58 /* number of v: vars */ | |
+#define VV_COMMAND 58 | |
+#define VV_LEN 59 /* number of v: vars */ | |
#ifdef FEAT_CLIPBOARD | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment