diff options
author | James McCoy <jamessan@jamessan.com> | 2017-04-29 07:58:49 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2017-04-29 23:48:27 -0400 |
commit | 7bd97127b4e45dcef1159603834b04ef0dcadfd7 (patch) | |
tree | 650f557edef609d8fa5c764503f0da880e55a07d /src/nvim/ex_docmd.c | |
parent | 059c3fc2f952b42824ca37610c040c938a75de5c (diff) | |
download | rneovim-7bd97127b4e45dcef1159603834b04ef0dcadfd7.tar.gz rneovim-7bd97127b4e45dcef1159603834b04ef0dcadfd7.tar.bz2 rneovim-7bd97127b4e45dcef1159603834b04ef0dcadfd7.zip |
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.
https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 7568d71ac0..45a11482d0 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1350,6 +1350,24 @@ static char_u * do_one_cmd(char_u **cmdlinep, 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)) @@ -1452,6 +1470,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, } break; } + char_u *after_modifier = ea.cmd; ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0 && !(cstack->cs_flags[cstack-> @@ -1734,7 +1753,13 @@ static char_u * do_one_cmd(char_u **cmdlinep, if (!ea.skip) { STRCPY(IObuff, _("E492: Not an editor command")); if (!(flags & DOCMD_VERBOSE)) { - 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; @@ -2104,6 +2129,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, case CMD_echomsg: case CMD_echon: case CMD_execute: + case CMD_filter: case CMD_help: case CMD_hide: case CMD_ijump: @@ -2255,6 +2281,10 @@ doend: free_string_option(cmdmod.save_ei); } + if (cmdmod.filter_regmatch.regprog != NULL) { + vim_regfree(cmdmod.filter_regmatch.regprog); + } + cmdmod = save_cmdmod; if (save_msg_silent != -1) { @@ -2545,6 +2575,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}, @@ -3007,6 +3038,7 @@ const char * 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: |