Skip to content

Commit 25bc16e

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 2ce1dbd + b58fe45 commit 25bc16e

File tree

14 files changed

+135
-43
lines changed

14 files changed

+135
-43
lines changed

runtime/doc/starting.txt

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*starting.txt* For Vim version 7.4. Last change: 2016 Aug 06
1+
*starting.txt* For Vim version 7.4. Last change: 2016 Aug 23
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -924,7 +924,8 @@ accordingly. Vim proceeds in this order:
924924
The $MYVIMRC or $MYGVIMRC file will be set to the first found vimrc and/or
925925
gvimrc file.
926926

927-
Some hints on using initializations:
927+
928+
Some hints on using initializations ~
928929

929930
Standard setup:
930931
Create a vimrc file to set the default settings and mappings for all your edit
@@ -947,27 +948,37 @@ want to set the defaults for all users. Create a vimrc file with commands
947948
for default settings and mappings and put it in the place that is given with
948949
the ":version" command.
949950

950-
Saving the current state of Vim to a file:
951+
952+
Saving the current state of Vim to a file ~
953+
951954
Whenever you have changed values of options or when you have created a
952955
mapping, then you may want to save them in a vimrc file for later use. See
953956
|save-settings| about saving the current state of settings to a file.
954957

955-
Avoiding setup problems for Vi users:
958+
959+
Avoiding setup problems for Vi users ~
960+
956961
Vi uses the variable EXINIT and the file "~/.exrc". So if you do not want to
957962
interfere with Vi, then use the variable VIMINIT and the file "vimrc" instead.
958963

959-
Amiga environment variables:
964+
965+
Amiga environment variables ~
966+
960967
On the Amiga, two types of environment variables exist. The ones set with the
961968
DOS 1.3 (or later) setenv command are recognized. See the AmigaDos 1.3
962969
manual. The environment variables set with the old Manx Set command (before
963970
version 5.0) are not recognized.
964971

965-
MS-DOS line separators:
972+
973+
MS-DOS line separators ~
974+
966975
On MS-DOS-like systems (MS-DOS itself, Win32, and OS/2), Vim assumes that all
967976
the vimrc files have <CR> <NL> pairs as line separators. This will give
968977
problems if you have a file with only <NL>s and have a line like
969978
":map xx yy^M". The trailing ^M will be ignored.
970979

980+
981+
Vi compatible default value ~
971982
*compatible-default*
972983
When Vim starts, the 'compatible' option is on. This will be used when Vim
973984
starts its initializations. But as soon as:
@@ -1000,6 +1011,8 @@ encountered. This makes a difference when using things like "<CR>". If the
10001011
mappings depend on a certain value of 'compatible', set or reset it before
10011012
giving the mapping.
10021013

1014+
1015+
Defaults without a .vimrc file ~
10031016
*defaults.vim*
10041017
If Vim is started normally and no user vimrc file is found, the
10051018
$VIMRUTIME/defaults.vim script is loaded. This will set 'compatible' off,
@@ -1019,7 +1032,8 @@ revert individual settings. See the defaults.vim file for hints on how to
10191032
revert each item.
10201033

10211034

1022-
Avoiding trojan horses: *trojan-horse*
1035+
Avoiding trojan horses ~
1036+
*trojan-horse*
10231037
While reading the "vimrc" or the "exrc" file in the current directory, some
10241038
commands can be disabled for security reasons by setting the 'secure' option.
10251039
This is always done when executing the command from a tags file. Otherwise it
@@ -1042,6 +1056,8 @@ Be careful!
10421056
part of the line in the tags file) is always done in secure mode. This works
10431057
just like executing a command from a vimrc/exrc in the current directory.
10441058

1059+
1060+
If Vim startup is slow ~
10451061
*slow-start*
10461062
If Vim takes a long time to start up, use the |--startuptime| argument to find
10471063
out what happens. There are a few common causes:
@@ -1056,6 +1072,8 @@ out what happens. There are a few common causes:
10561072
moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of
10571073
lines stored in a register with ":set viminfo='20,<50,s10". |viminfo-file|.
10581074

1075+
1076+
Intro message ~
10591077
*:intro*
10601078
When Vim starts without a file name, an introductory message is displayed (for
10611079
those who don't know what Vim is). It is removed as soon as the display is
@@ -1614,18 +1632,12 @@ most of the information will be restored).
16141632
file. This list is read on startup and only changes
16151633
afterwards with `:rviminfo!`. Also see |v:oldfiles|.
16161634
The number can be used with |c_#<|.
1635+
The output can be filtered with |:filter|, e.g.: >
1636+
filter /\\.vim/ oldfiles
1637+
< The filtering happens on the file name.
16171638
{not in Vi, only when compiled with the |+eval|
16181639
feature}
16191640

1620-
:ol[dfiles] {pat}
1621-
:ol[dfiles] /{pat}/
1622-
Like `:oldfiles` but only files matching {pat} will
1623-
be included. {pat} is a Vim search pattern. Instead
1624-
of enclosing it in / any non-ID character (see
1625-
|'isident'|) can be used, so long as it does not
1626-
appear in {pat}. Without the enclosing character the
1627-
pattern cannot include the bar character.
1628-
16291641
:bro[wse] ol[dfiles][!]
16301642
List file names as with |:oldfiles|, and then prompt
16311643
for a number. When the number is valid that file from

runtime/doc/various.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*various.txt* For Vim version 7.4. Last change: 2016 Jul 29
1+
*various.txt* For Vim version 7.4. Last change: 2016 Aug 23
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -527,6 +527,25 @@ N *+X11* Unix only: can restore window title |X11|
527527

528528
:redi[r] END End redirecting messages. {not in Vi}
529529

530+
*:filt* *:filter*
531+
:filt[er] {pat} {command}
532+
:filt[er] /{pat}/ {command}
533+
Restrict the output of {command} to matches with {pat}.
534+
535+
{pat} is a Vim search pattern. Instead of enclosing
536+
it in / any non-ID character (see |'isident'|) can be
537+
used, so long as it does not appear in {pat}. Without
538+
the enclosing character the pattern cannot include the
539+
bar character.
540+
541+
The pattern is matched against the relevant part of
542+
the output, not necessarily the whole line. Only some
543+
commands support filtering, try it out to check if it
544+
works.
545+
546+
Only normal messages are filtered, error messages are
547+
not.
548+
530549
*:sil* *:silent* *:silent!*
531550
:sil[ent][!] {command} Execute {command} silently. Normal messages will not
532551
be given or added to the message history.

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,6 +2089,7 @@ test_arglist \
20892089
test_farsi \
20902090
test_feedkeys \
20912091
test_file_perm \
2092+
test_filter_cmd \
20922093
test_filter_map \
20932094
test_fnamemodify \
20942095
test_glob2regpat \

src/buffer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2935,12 +2935,14 @@ buflist_list(exarg_T *eap)
29352935
|| (vim_strchr(eap->arg, '#')
29362936
&& (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum)))
29372937
continue;
2938-
msg_putchar('\n');
29392938
if (buf_spname(buf) != NULL)
29402939
vim_strncpy(NameBuff, buf_spname(buf), MAXPATHL - 1);
29412940
else
29422941
home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
2942+
if (message_filtered(NameBuff))
2943+
continue;
29432944

2945+
msg_putchar('\n');
29442946
len = vim_snprintf((char *)IObuff, IOSIZE - 20, "%3d%c%c%c%c%c \"%s\"",
29452947
buf->b_fnum,
29462948
buf->b_p_bl ? ' ' : 'u',

src/ex_cmds.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8392,7 +8392,6 @@ ex_drop(exarg_T *eap)
83928392
}
83938393
#endif
83948394

8395-
#if defined(FEAT_QUICKFIX) || defined(FEAT_EVAL) || defined(PROTO)
83968395
/*
83978396
* Skip over the pattern argument of ":vimgrep /pat/[g][j]".
83988397
* Put the start of the pattern in "*s", unless "s" is NULL.
@@ -8444,7 +8443,6 @@ skip_vimgrep_pat(char_u *p, char_u **s, int *flags)
84448443
}
84458444
return p;
84468445
}
8447-
#endif
84488446

84498447
#if defined(FEAT_EVAL) || defined(PROTO)
84508448
/*
@@ -8456,34 +8454,19 @@ ex_oldfiles(exarg_T *eap UNUSED)
84568454
list_T *l = get_vim_var_list(VV_OLDFILES);
84578455
listitem_T *li;
84588456
int nr = 0;
8459-
char_u *reg_pat = NULL;
84608457
char_u *fname;
8461-
regmatch_T regmatch;
84628458

84638459
if (l == NULL)
84648460
msg((char_u *)_("No old files"));
84658461
else
84668462
{
8467-
if (*eap->arg != NUL)
8468-
{
8469-
if (skip_vimgrep_pat(eap->arg, &reg_pat, NULL) == NULL)
8470-
{
8471-
EMSG(_(e_invalpat));
8472-
return;
8473-
}
8474-
regmatch.regprog = vim_regcomp(reg_pat, p_magic ? RE_MAGIC : 0);
8475-
if (regmatch.regprog == NULL)
8476-
return;
8477-
}
8478-
84798463
msg_start();
84808464
msg_scroll = TRUE;
84818465
for (li = l->lv_first; li != NULL && !got_int; li = li->li_next)
84828466
{
84838467
++nr;
84848468
fname = get_tv_string(&li->li_tv);
8485-
if (reg_pat == NULL || *reg_pat == NUL
8486-
|| vim_regexec(&regmatch, fname, (colnr_T)0))
8469+
if (!message_filtered(fname))
84878470
{
84888471
msg_outnum((long)nr);
84898472
MSG_PUTS(": ");
@@ -8493,8 +8476,6 @@ ex_oldfiles(exarg_T *eap UNUSED)
84938476
ui_breakcheck();
84948477
}
84958478
}
8496-
if (*eap->arg != NUL)
8497-
vim_regfree(regmatch.regprog);
84988479

84998480
/* Assume "got_int" was set to truncate the listing. */
85008481
got_int = FALSE;

src/ex_cmds.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ EX(CMD_files, "files", buflist_list,
544544
EX(CMD_filetype, "filetype", ex_filetype,
545545
EXTRA|TRLBAR|CMDWIN,
546546
ADDR_LINES),
547+
EX(CMD_filter, "filter", ex_wrongmodifier,
548+
NEEDARG|EXTRA|NOTRLCOM,
549+
ADDR_LINES),
547550
EX(CMD_find, "find", ex_find,
548551
RANGE|NOTADR|BANG|FILE1|EDITCMD|ARGOPT|TRLBAR,
549552
ADDR_LINES),
@@ -998,7 +1001,7 @@ EX(CMD_open, "open", ex_open,
9981001
RANGE|BANG|EXTRA,
9991002
ADDR_LINES),
10001003
EX(CMD_oldfiles, "oldfiles", ex_oldfiles,
1001-
BANG|TRLBAR|NOTADR|EXTRA|SBOXOK|CMDWIN,
1004+
BANG|TRLBAR|SBOXOK|CMDWIN,
10021005
ADDR_LINES),
10031006
EX(CMD_omap, "omap", ex_map,
10041007
EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN,

src/ex_docmd.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,7 @@ do_one_cmd(
17881788
linenr_T lnum;
17891789
long n;
17901790
char_u *errormsg = NULL; /* error message */
1791+
char_u *after_modifier = NULL;
17911792
exarg_T ea; /* Ex command arguments */
17921793
long verbose_save = -1;
17931794
int save_msg_scroll = msg_scroll;
@@ -1924,6 +1925,24 @@ do_one_cmd(
19241925
cmdmod.keepjumps = TRUE;
19251926
continue;
19261927

1928+
case 'f': /* only accept ":filter {pat} cmd" */
1929+
{
1930+
char_u *reg_pat;
1931+
1932+
if (!checkforcmd(&p, "filter", 4)
1933+
|| *p == NUL || ends_excmd(*p))
1934+
break;
1935+
p = skip_vimgrep_pat(p, &reg_pat, NULL);
1936+
if (p == NULL || *p == NUL)
1937+
break;
1938+
cmdmod.filter_regmatch.regprog =
1939+
vim_regcomp(reg_pat, RE_MAGIC);
1940+
if (cmdmod.filter_regmatch.regprog == NULL)
1941+
break;
1942+
ea.cmd = p;
1943+
continue;
1944+
}
1945+
19271946
/* ":hide" and ":hide | cmd" are not modifiers */
19281947
case 'h': if (p != ea.cmd || !checkforcmd(&p, "hide", 3)
19291948
|| *p == NUL || ends_excmd(*p))
@@ -2048,6 +2067,7 @@ do_one_cmd(
20482067
}
20492068
break;
20502069
}
2070+
after_modifier = ea.cmd;
20512071

20522072
#ifdef FEAT_EVAL
20532073
ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0
@@ -2381,7 +2401,14 @@ do_one_cmd(
23812401
{
23822402
STRCPY(IObuff, _("E492: Not an editor command"));
23832403
if (!sourcing)
2384-
append_command(*cmdlinep);
2404+
{
2405+
/* If the modifier was parsed OK the error must be in the
2406+
* following command */
2407+
if (after_modifier != NULL)
2408+
append_command(after_modifier);
2409+
else
2410+
append_command(*cmdlinep);
2411+
}
23852412
errormsg = IObuff;
23862413
did_emsg_syntax = TRUE;
23872414
}
@@ -2825,6 +2852,7 @@ do_one_cmd(
28252852
case CMD_echomsg:
28262853
case CMD_echon:
28272854
case CMD_execute:
2855+
case CMD_filter:
28282856
case CMD_help:
28292857
case CMD_hide:
28302858
case CMD_ijump:
@@ -2996,6 +3024,8 @@ do_one_cmd(
29963024
free_string_option(cmdmod.save_ei);
29973025
}
29983026
#endif
3027+
if (cmdmod.filter_regmatch.regprog != NULL)
3028+
vim_regfree(cmdmod.filter_regmatch.regprog);
29993029

30003030
cmdmod = save_cmdmod;
30013031

@@ -3330,6 +3360,7 @@ static struct cmdmod
33303360
{"botright", 2, FALSE},
33313361
{"browse", 3, FALSE},
33323362
{"confirm", 4, FALSE},
3363+
{"filter", 4, FALSE},
33333364
{"hide", 3, FALSE},
33343365
{"keepalt", 5, FALSE},
33353366
{"keepjumps", 5, FALSE},
@@ -3840,6 +3871,7 @@ set_one_cmd_context(
38403871
case CMD_cfdo:
38413872
case CMD_confirm:
38423873
case CMD_debug:
3874+
case CMD_filter:
38433875
case CMD_folddoclosed:
38443876
case CMD_folddoopen:
38453877
case CMD_hide:

src/message.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ msg_attr_keep(
137137
int retval;
138138
char_u *buf = NULL;
139139

140+
/* Skip messages not matching ":filter pattern".
141+
* Don't filter when there is an error. */
142+
if (!emsg_on_display && message_filtered(s))
143+
return TRUE;
144+
140145
#ifdef FEAT_EVAL
141146
if (attr == 0)
142147
set_vim_var_string(VV_STATUSMSG, s, -1);
@@ -2153,6 +2158,17 @@ msg_puts_display(
21532158
msg_check();
21542159
}
21552160

2161+
/*
2162+
* Return TRUE when ":filter pattern" was used and "msg" does not match
2163+
* "pattern".
2164+
*/
2165+
int
2166+
message_filtered(char_u *msg)
2167+
{
2168+
return cmdmod.filter_regmatch.regprog != NULL
2169+
&& !vim_regexec(&cmdmod.filter_regmatch, msg, (colnr_T)0);
2170+
}
2171+
21562172
/*
21572173
* Scroll the screen up one line for displaying the next message line.
21582174
*/

src/proto/message.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void msg_puts_title(char_u *s);
4343
void msg_puts_long_attr(char_u *longstr, int attr);
4444
void msg_puts_long_len_attr(char_u *longstr, int len, int attr);
4545
void msg_puts_attr(char_u *s, int attr);
46+
int message_filtered(char_u *msg);
4647
void may_clear_sb_text(void);
4748
void clear_sb_text(void);
4849
void show_sb_text(void);

src/structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ typedef struct
571571
# ifdef FEAT_AUTOCMD
572572
char_u *save_ei; /* saved value of 'eventignore' */
573573
# endif
574+
regmatch_T filter_regmatch; /* set by :filter /pat/ */
574575
} cmdmod_T;
575576

576577
#define MF_SEED_LEN 8

0 commit comments

Comments
 (0)