mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #1282 from splinterofchaos/cmd-undef
vim-patch:7.4.414 + vim-patch:7.4.415
This commit is contained in:
commit
b1e06c6d60
@ -278,6 +278,7 @@ Name triggered by ~
|
|||||||
|ShellCmdPost| after executing a shell command
|
|ShellCmdPost| after executing a shell command
|
||||||
|ShellFilterPost| after filtering with a shell command
|
|ShellFilterPost| after filtering with a shell command
|
||||||
|
|
||||||
|
|CmdUndefined| a user command is used but it isn't defined
|
||||||
|FuncUndefined| a user function is used but it isn't defined
|
|FuncUndefined| a user function is used but it isn't defined
|
||||||
|SpellFileMissing| a spell file is used but it can't be found
|
|SpellFileMissing| a spell file is used but it can't be found
|
||||||
|SourcePre| before sourcing a Vim script
|
|SourcePre| before sourcing a Vim script
|
||||||
@ -466,6 +467,16 @@ BufWriteCmd Before writing the whole buffer to a file.
|
|||||||
*BufWritePost*
|
*BufWritePost*
|
||||||
BufWritePost After writing the whole buffer to a file
|
BufWritePost After writing the whole buffer to a file
|
||||||
(should undo the commands for BufWritePre).
|
(should undo the commands for BufWritePre).
|
||||||
|
*CmdUndefined*
|
||||||
|
CmdUndefined When a user command is used but it isn't
|
||||||
|
defined. Useful for defining a command only
|
||||||
|
when it's used. The pattern is matched
|
||||||
|
against the command name. Both <amatch> and
|
||||||
|
<afile> are set to the name of the command.
|
||||||
|
NOTE: Autocompletion won't work until the
|
||||||
|
command is defined. An alternative is to
|
||||||
|
always define the user command and have it
|
||||||
|
invoke an autoloaded function. See |autoload|.
|
||||||
*CmdwinEnter*
|
*CmdwinEnter*
|
||||||
CmdwinEnter After entering the command-line window.
|
CmdwinEnter After entering the command-line window.
|
||||||
Useful for setting options specifically for
|
Useful for setting options specifically for
|
||||||
@ -671,6 +682,8 @@ FuncUndefined When a user function is used but it isn't
|
|||||||
when it's used. The pattern is matched
|
when it's used. The pattern is matched
|
||||||
against the function name. Both <amatch> and
|
against the function name. Both <amatch> and
|
||||||
<afile> are set to the name of the function.
|
<afile> are set to the name of the function.
|
||||||
|
NOTE: When writing Vim scripts a better
|
||||||
|
alternative is to use an autoloaded function.
|
||||||
See |autoload-functions|.
|
See |autoload-functions|.
|
||||||
*GUIEnter*
|
*GUIEnter*
|
||||||
GUIEnter After starting the GUI successfully, and after
|
GUIEnter After starting the GUI successfully, and after
|
||||||
|
@ -1459,6 +1459,23 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
|||||||
/* Find the command and let "p" point to after it. */
|
/* Find the command and let "p" point to after it. */
|
||||||
p = find_command(&ea, NULL);
|
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 (p == NULL) {
|
||||||
if (!ea.skip)
|
if (!ea.skip)
|
||||||
errormsg = (char_u *)_("E464: Ambiguous use of user-defined command");
|
errormsg = (char_u *)_("E464: Ambiguous use of user-defined command");
|
||||||
|
@ -72,25 +72,25 @@
|
|||||||
* The result is an array of Autopat lists, which point to AutoCmd lists:
|
* The result is an array of Autopat lists, which point to AutoCmd lists:
|
||||||
*
|
*
|
||||||
* first_autopat[0] --> Autopat.next --> Autopat.next --> NULL
|
* first_autopat[0] --> Autopat.next --> Autopat.next --> NULL
|
||||||
* Autopat.cmds Autopat.cmds
|
* Autopat.cmds Autopat.cmds
|
||||||
* | |
|
* | |
|
||||||
* V V
|
* V V
|
||||||
* AutoCmd.next AutoCmd.next
|
* AutoCmd.next AutoCmd.next
|
||||||
* | |
|
* | |
|
||||||
* V V
|
* V V
|
||||||
* AutoCmd.next NULL
|
* AutoCmd.next NULL
|
||||||
* |
|
* |
|
||||||
* V
|
* V
|
||||||
* NULL
|
* NULL
|
||||||
*
|
*
|
||||||
* first_autopat[1] --> Autopat.next --> NULL
|
* first_autopat[1] --> Autopat.next --> NULL
|
||||||
* Autopat.cmds
|
* Autopat.cmds
|
||||||
* |
|
* |
|
||||||
* V
|
* V
|
||||||
* AutoCmd.next
|
* AutoCmd.next
|
||||||
* |
|
* |
|
||||||
* V
|
* V
|
||||||
* NULL
|
* NULL
|
||||||
* etc.
|
* etc.
|
||||||
*
|
*
|
||||||
* The order of AutoCmds is important, this is the order in which they were
|
* The order of AutoCmds is important, this is the order in which they were
|
||||||
@ -5198,6 +5198,7 @@ static struct event_name {
|
|||||||
{"BufWriteCmd", EVENT_BUFWRITECMD},
|
{"BufWriteCmd", EVENT_BUFWRITECMD},
|
||||||
{"CmdwinEnter", EVENT_CMDWINENTER},
|
{"CmdwinEnter", EVENT_CMDWINENTER},
|
||||||
{"CmdwinLeave", EVENT_CMDWINLEAVE},
|
{"CmdwinLeave", EVENT_CMDWINLEAVE},
|
||||||
|
{"CmdUndefined", EVENT_CMDUNDEFINED},
|
||||||
{"ColorScheme", EVENT_COLORSCHEME},
|
{"ColorScheme", EVENT_COLORSCHEME},
|
||||||
{"CompleteDone", EVENT_COMPLETEDONE},
|
{"CompleteDone", EVENT_COMPLETEDONE},
|
||||||
{"CursorHold", EVENT_CURSORHOLD},
|
{"CursorHold", EVENT_CURSORHOLD},
|
||||||
@ -6462,6 +6463,18 @@ int has_insertcharpre(void)
|
|||||||
return first_autopat[(int)EVENT_INSERTCHARPRE] != NULL;
|
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
|
static int
|
||||||
apply_autocmds_group (
|
apply_autocmds_group (
|
||||||
event_T event,
|
event_T event,
|
||||||
|
@ -99,6 +99,7 @@ typedef enum auto_event {
|
|||||||
EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */
|
EVENT_SHELLFILTERPOST, /* after ":1,2!cmd", ":w !cmd", ":r !cmd". */
|
||||||
EVENT_TEXTCHANGED, /* text was modified */
|
EVENT_TEXTCHANGED, /* text was modified */
|
||||||
EVENT_TEXTCHANGEDI, /* text was modified in Insert mode*/
|
EVENT_TEXTCHANGEDI, /* text was modified in Insert mode*/
|
||||||
|
EVENT_CMDUNDEFINED, ///< command undefined
|
||||||
NUM_EVENTS /* MUST be the last one */
|
NUM_EVENTS /* MUST be the last one */
|
||||||
} event_T;
|
} event_T;
|
||||||
|
|
||||||
|
@ -250,8 +250,8 @@ static int included_patches[] = {
|
|||||||
418,
|
418,
|
||||||
//417,
|
//417,
|
||||||
//416,
|
//416,
|
||||||
//415,
|
415,
|
||||||
//414,
|
414,
|
||||||
//413 NA
|
//413 NA
|
||||||
//412 NA
|
//412 NA
|
||||||
411,
|
411,
|
||||||
|
Loading…
Reference in New Issue
Block a user