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.
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 9f1d227..94216b3 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1781,6 +1781,7 @@
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 @@
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, ®_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 @@
}
break;
}
+ after_modifier = ea.cmd;
#ifdef FEAT_EVAL
ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0
@@ -2374,7 +2394,14 @@
{
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 @@
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 @@
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 @@
{"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 @@
case CMD_cfdo:
case CMD_confirm:
case CMD_debug:
+ case CMD_filter:
case CMD_folddoclosed:
case CMD_folddoopen:
case CMD_hide: