1
0
forked from aniani/vim

patch 7.4.2244

Problem:    Adding pattern to ":oldfiles" is not a generic solution.
Solution:   Add the ":filter /pat/ cmd" command modifier.  Only works for some
            commands right now.
This commit is contained in:
Bram Moolenaar
2016-08-23 23:51:21 +02:00
parent 1b58cdd160
commit 7b668e83d0
12 changed files with 125 additions and 22 deletions

View File

@@ -1781,6 +1781,7 @@ do_one_cmd(
linenr_T lnum;
long n;
char_u *errormsg = NULL; /* error message */
char_u *after_modifier = NULL;
exarg_T ea; /* Ex command arguments */
long verbose_save = -1;
int save_msg_scroll = msg_scroll;
@@ -1917,6 +1918,24 @@ do_one_cmd(
cmdmod.keepjumps = TRUE;
continue;
case 'f': /* only accept ":filter {pat} cmd" */
{
char_u *reg_pat;
if (!checkforcmd(&p, "filter", 4)
|| *p == NUL || ends_excmd(*p))
break;
p = skip_vimgrep_pat(p, &reg_pat, NULL);
if (p == NULL || *p == NUL)
break;
cmdmod.filter_regmatch.regprog =
vim_regcomp(reg_pat, RE_MAGIC);
if (cmdmod.filter_regmatch.regprog == NULL)
break;
ea.cmd = p;
continue;
}
/* ":hide" and ":hide | cmd" are not modifiers */
case 'h': if (p != ea.cmd || !checkforcmd(&p, "hide", 3)
|| *p == NUL || ends_excmd(*p))
@@ -2041,6 +2060,7 @@ do_one_cmd(
}
break;
}
after_modifier = ea.cmd;
#ifdef FEAT_EVAL
ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0
@@ -2374,7 +2394,14 @@ do_one_cmd(
{
STRCPY(IObuff, _("E492: Not an editor command"));
if (!sourcing)
append_command(*cmdlinep);
{
/* If the modifier was parsed OK the error must be in the
* following command */
if (after_modifier != NULL)
append_command(after_modifier);
else
append_command(*cmdlinep);
}
errormsg = IObuff;
did_emsg_syntax = TRUE;
}
@@ -2818,6 +2845,7 @@ do_one_cmd(
case CMD_echomsg:
case CMD_echon:
case CMD_execute:
case CMD_filter:
case CMD_help:
case CMD_hide:
case CMD_ijump:
@@ -2989,6 +3017,8 @@ doend:
free_string_option(cmdmod.save_ei);
}
#endif
if (cmdmod.filter_regmatch.regprog != NULL)
vim_regfree(cmdmod.filter_regmatch.regprog);
cmdmod = save_cmdmod;
@@ -3323,6 +3353,7 @@ static struct cmdmod
{"botright", 2, FALSE},
{"browse", 3, FALSE},
{"confirm", 4, FALSE},
{"filter", 4, FALSE},
{"hide", 3, FALSE},
{"keepalt", 5, FALSE},
{"keepjumps", 5, FALSE},
@@ -3833,6 +3864,7 @@ set_one_cmd_context(
case CMD_cfdo:
case CMD_confirm:
case CMD_debug:
case CMD_filter:
case CMD_folddoclosed:
case CMD_folddoopen:
case CMD_hide: