comparison src/ex_docmd.c @ 9941:e975914c17e9 v7.4.2244

commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 23 23:51:21 2016 +0200 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.
author Christian Brabandt <cb@256bit.org>
date Wed, 24 Aug 2016 00:00:08 +0200
parents e1a8b2601fe0
children b222552cf0c4
comparison
equal deleted inserted replaced
9940:b7b5f6a8607e 9941:e975914c17e9
1779 { 1779 {
1780 char_u *p; 1780 char_u *p;
1781 linenr_T lnum; 1781 linenr_T lnum;
1782 long n; 1782 long n;
1783 char_u *errormsg = NULL; /* error message */ 1783 char_u *errormsg = NULL; /* error message */
1784 char_u *after_modifier = NULL;
1784 exarg_T ea; /* Ex command arguments */ 1785 exarg_T ea; /* Ex command arguments */
1785 long verbose_save = -1; 1786 long verbose_save = -1;
1786 int save_msg_scroll = msg_scroll; 1787 int save_msg_scroll = msg_scroll;
1787 int save_msg_silent = -1; 1788 int save_msg_silent = -1;
1788 int did_esilent = 0; 1789 int did_esilent = 0;
1915 if (!checkforcmd(&ea.cmd, "keepjumps", 5)) 1916 if (!checkforcmd(&ea.cmd, "keepjumps", 5))
1916 break; 1917 break;
1917 cmdmod.keepjumps = TRUE; 1918 cmdmod.keepjumps = TRUE;
1918 continue; 1919 continue;
1919 1920
1921 case 'f': /* only accept ":filter {pat} cmd" */
1922 {
1923 char_u *reg_pat;
1924
1925 if (!checkforcmd(&p, "filter", 4)
1926 || *p == NUL || ends_excmd(*p))
1927 break;
1928 p = skip_vimgrep_pat(p, &reg_pat, NULL);
1929 if (p == NULL || *p == NUL)
1930 break;
1931 cmdmod.filter_regmatch.regprog =
1932 vim_regcomp(reg_pat, RE_MAGIC);
1933 if (cmdmod.filter_regmatch.regprog == NULL)
1934 break;
1935 ea.cmd = p;
1936 continue;
1937 }
1938
1920 /* ":hide" and ":hide | cmd" are not modifiers */ 1939 /* ":hide" and ":hide | cmd" are not modifiers */
1921 case 'h': if (p != ea.cmd || !checkforcmd(&p, "hide", 3) 1940 case 'h': if (p != ea.cmd || !checkforcmd(&p, "hide", 3)
1922 || *p == NUL || ends_excmd(*p)) 1941 || *p == NUL || ends_excmd(*p))
1923 break; 1942 break;
1924 ea.cmd = p; 1943 ea.cmd = p;
2039 ea.cmd = p; 2058 ea.cmd = p;
2040 continue; 2059 continue;
2041 } 2060 }
2042 break; 2061 break;
2043 } 2062 }
2063 after_modifier = ea.cmd;
2044 2064
2045 #ifdef FEAT_EVAL 2065 #ifdef FEAT_EVAL
2046 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0 2066 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0
2047 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)); 2067 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE));
2048 #else 2068 #else
2372 { 2392 {
2373 if (!ea.skip) 2393 if (!ea.skip)
2374 { 2394 {
2375 STRCPY(IObuff, _("E492: Not an editor command")); 2395 STRCPY(IObuff, _("E492: Not an editor command"));
2376 if (!sourcing) 2396 if (!sourcing)
2377 append_command(*cmdlinep); 2397 {
2398 /* If the modifier was parsed OK the error must be in the
2399 * following command */
2400 if (after_modifier != NULL)
2401 append_command(after_modifier);
2402 else
2403 append_command(*cmdlinep);
2404 }
2378 errormsg = IObuff; 2405 errormsg = IObuff;
2379 did_emsg_syntax = TRUE; 2406 did_emsg_syntax = TRUE;
2380 } 2407 }
2381 goto doend; 2408 goto doend;
2382 } 2409 }
2816 case CMD_echo: 2843 case CMD_echo:
2817 case CMD_echoerr: 2844 case CMD_echoerr:
2818 case CMD_echomsg: 2845 case CMD_echomsg:
2819 case CMD_echon: 2846 case CMD_echon:
2820 case CMD_execute: 2847 case CMD_execute:
2848 case CMD_filter:
2821 case CMD_help: 2849 case CMD_help:
2822 case CMD_hide: 2850 case CMD_hide:
2823 case CMD_ijump: 2851 case CMD_ijump:
2824 case CMD_ilist: 2852 case CMD_ilist:
2825 case CMD_isearch: 2853 case CMD_isearch:
2987 set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei, 3015 set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei,
2988 OPT_FREE, SID_NONE); 3016 OPT_FREE, SID_NONE);
2989 free_string_option(cmdmod.save_ei); 3017 free_string_option(cmdmod.save_ei);
2990 } 3018 }
2991 #endif 3019 #endif
3020 if (cmdmod.filter_regmatch.regprog != NULL)
3021 vim_regfree(cmdmod.filter_regmatch.regprog);
2992 3022
2993 cmdmod = save_cmdmod; 3023 cmdmod = save_cmdmod;
2994 3024
2995 if (save_msg_silent != -1) 3025 if (save_msg_silent != -1)
2996 { 3026 {
3321 {"aboveleft", 3, FALSE}, 3351 {"aboveleft", 3, FALSE},
3322 {"belowright", 3, FALSE}, 3352 {"belowright", 3, FALSE},
3323 {"botright", 2, FALSE}, 3353 {"botright", 2, FALSE},
3324 {"browse", 3, FALSE}, 3354 {"browse", 3, FALSE},
3325 {"confirm", 4, FALSE}, 3355 {"confirm", 4, FALSE},
3356 {"filter", 4, FALSE},
3326 {"hide", 3, FALSE}, 3357 {"hide", 3, FALSE},
3327 {"keepalt", 5, FALSE}, 3358 {"keepalt", 5, FALSE},
3328 {"keepjumps", 5, FALSE}, 3359 {"keepjumps", 5, FALSE},
3329 {"keepmarks", 3, FALSE}, 3360 {"keepmarks", 3, FALSE},
3330 {"keeppatterns", 5, FALSE}, 3361 {"keeppatterns", 5, FALSE},
3831 case CMD_bufdo: 3862 case CMD_bufdo:
3832 case CMD_cdo: 3863 case CMD_cdo:
3833 case CMD_cfdo: 3864 case CMD_cfdo:
3834 case CMD_confirm: 3865 case CMD_confirm:
3835 case CMD_debug: 3866 case CMD_debug:
3867 case CMD_filter:
3836 case CMD_folddoclosed: 3868 case CMD_folddoclosed:
3837 case CMD_folddoopen: 3869 case CMD_folddoopen:
3838 case CMD_hide: 3870 case CMD_hide:
3839 case CMD_keepalt: 3871 case CMD_keepalt:
3840 case CMD_keepjumps: 3872 case CMD_keepjumps: