Skip to content

Commit 5178dd4

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 6a9348a + c631f2d commit 5178dd4

52 files changed

Lines changed: 1653 additions & 658 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

runtime/doc/eval.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,7 @@ submatch({nr} [, {list}]) String or List
24092409
specific match in ":s" or substitute()
24102410
substitute({expr}, {pat}, {sub}, {flags})
24112411
String all {pat} in {expr} replaced with {sub}
2412+
swapinfo({fname}) Dict information about swap file {fname}
24122413
synID({lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col}
24132414
synIDattr({synID}, {what} [, {mode}])
24142415
String attribute {what} of syntax ID {synID}
@@ -2497,6 +2498,7 @@ win_screenpos({nr}) List get screen position of window {nr}
24972498
winbufnr({nr}) Number buffer number of window {nr}
24982499
wincol() Number window column of the cursor
24992500
winheight({nr}) Number height of window {nr}
2501+
winlayout([{tabnr}]) List layout of windows in tab {tabnr}
25002502
winline() Number window line of the cursor
25012503
winnr([{expr}]) Number number of current window
25022504
winrestcmd() String returns command to restore window sizes
@@ -8000,6 +8002,24 @@ substitute({expr}, {pat}, {sub}, {flags}) *substitute()*
80008002
|submatch()| returns. Example: >
80018003
:echo substitute(s, '%\(\x\x\)', {m -> '0x' . m[1]}, 'g')
80028004
8005+
swapinfo({fname}) swapinfo()
8006+
The result is a dictionary, which holds information about the
8007+
swapfile {fname}. The available fields are:
8008+
version VIM version
8009+
user user name
8010+
host host name
8011+
fname original file name
8012+
pid PID of the VIM process that created the swap
8013+
file
8014+
mtime last modification time in seconds
8015+
inode Optional: INODE number of the file
8016+
dirty 1 if file was modified, 0 if not
8017+
In case of failure an "error" item is added with the reason:
8018+
Cannot open file: file not found or in accessible
8019+
Cannot read file: cannot read first block
8020+
Not a swap file: does not contain correct block ID
8021+
Magic number mismatch: Info in first block is invalid
8022+
80038023
synID({lnum}, {col}, {trans}) *synID()*
80048024
The result is a Number, which is the syntax ID at the position
80058025
{lnum} and {col} in the current window.
@@ -9087,6 +9107,35 @@ winheight({nr}) *winheight()*
90879107
This excludes any window toolbar line.
90889108
Examples: >
90899109
:echo "The current window has " . winheight(0) . " lines."
9110+
<
9111+
winlayout([{tabnr}]) *winlayout()*
9112+
The result is a nested List containing the layout of windows
9113+
in a tabpage.
9114+
9115+
Without {tabnr} use the current tabpage, otherwise the tabpage
9116+
with number {tabnr}. If the tabpage {tabnr} is not found,
9117+
returns an empty list.
9118+
9119+
For a leaf window, it returns:
9120+
['leaf', {winid}]
9121+
For horizontally split windows, which form a column, it
9122+
returns:
9123+
['col', [{nested list of windows}]]
9124+
For vertically split windows, which form a row, it returns:
9125+
['row', [{nested list of windows}]]
9126+
9127+
Example: >
9128+
" Only one window in the tab page
9129+
:echo winlayout()
9130+
['leaf', 1000]
9131+
" Two horizontally split windows
9132+
:echo winlayout()
9133+
['col', [['leaf', 1000], ['leaf', 1001]]]
9134+
" Three horizontally split windows, with two
9135+
" vertically split windows in the middle window
9136+
:echo winlayout(2)
9137+
['col', [['leaf', 1002], ['row', ['leaf', 1003],
9138+
['leaf', 1001]]], ['leaf', 1000]]
90909139
<
90919140
*winline()*
90929141
winline() The result is a Number, which is the screen line of the cursor

runtime/doc/quickfix.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,22 @@ The backslashes before the pipe character are required to avoid it to be
15511551
recognized as a command separator. The backslash before each space is
15521552
required for the set command.
15531553

1554+
*cfilter-plugin*
1555+
If you have too many matching messages, you can use the cfilter plugin to
1556+
reduce the number of entries. Load the plugin with: >
1557+
packadd cfilter
1558+
1559+
Then you can use these command: >
1560+
:Cfilter[!] {pat}
1561+
:Lfilter[!] {pat}
1562+
1563+
:Cfilter creates a new quickfix list from entries matching {pat} in the
1564+
current quickfix list. Both the file name and the text of the entries are
1565+
matched against {pat}. If ! is supplied, then entries not matching {pat} are
1566+
used.
1567+
1568+
:Lfilter does the same as :Cfilter but operates on the current location list.
1569+
15541570
=============================================================================
15551571
8. The directory stack *quickfix-directory-stack*
15561572

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
" cfilter.vim: Plugin to filter entries from a quickfix/location list
2+
" Last Change: May 12, 2018
3+
" Maintainer: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
4+
" Version: 1.0
5+
"
6+
" Commands to filter the quickfix list:
7+
" :Cfilter[!] {pat}
8+
" Create a new quickfix list from entries matching {pat} in the current
9+
" quickfix list. Both the file name and the text of the entries are
10+
" matched against {pat}. If ! is supplied, then entries not matching
11+
" {pat} are used.
12+
" :Lfilter[!] {pat}
13+
" Same as :Cfilter but operates on the current location list.
14+
"
15+
if exists("loaded_cfilter")
16+
finish
17+
endif
18+
let loaded_cfilter = 1
19+
20+
func s:Qf_filter(qf, pat, bang)
21+
if a:qf
22+
let Xgetlist = function('getqflist')
23+
let Xsetlist = function('setqflist')
24+
let cmd = ':Cfilter' . a:bang
25+
else
26+
let Xgetlist = function('getloclist', [0])
27+
let Xsetlist = function('setloclist', [0])
28+
let cmd = ':Lfilter' . a:bang
29+
endif
30+
31+
if a:bang == '!'
32+
let cond = 'v:val.text !~# a:pat && bufname(v:val.bufnr) !~# a:pat'
33+
else
34+
let cond = 'v:val.text =~# a:pat || bufname(v:val.bufnr) =~# a:pat'
35+
endif
36+
37+
let items = filter(Xgetlist(), cond)
38+
let title = cmd . ' ' . a:pat
39+
call Xsetlist([], ' ', {'title' : title, 'items' : items})
40+
endfunc
41+
42+
com! -nargs=+ -bang Cfilter call s:Qf_filter(1, <q-args>, <q-bang>)
43+
com! -nargs=+ -bang Lfilter call s:Qf_filter(0, <q-args>, <q-bang>)

src/buffer.c

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,14 @@ handle_swap_exists(bufref_T *old_curbuf)
10391039
buf = old_curbuf->br_buf;
10401040
if (buf != NULL)
10411041
{
1042+
int old_msg_silent = msg_silent;
1043+
1044+
if (shortmess(SHM_FILEINFO))
1045+
msg_silent = 1; // prevent fileinfo message
10421046
enter_buffer(buf);
1047+
// restore msg_silent, so that the command line will be shown
1048+
msg_silent = old_msg_silent;
1049+
10431050
# ifdef FEAT_SYN_HL
10441051
if (old_tw != curbuf->b_p_tw)
10451052
check_colorcolumn(curwin);
@@ -1178,26 +1185,14 @@ do_bufdel(
11781185
else if (deleted >= p_report)
11791186
{
11801187
if (command == DOBUF_UNLOAD)
1181-
{
1182-
if (deleted == 1)
1183-
MSG(_("1 buffer unloaded"));
1184-
else
1185-
smsg((char_u *)_("%d buffers unloaded"), deleted);
1186-
}
1188+
smsg((char_u *)NGETTEXT("%d buffer unloaded",
1189+
"%d buffers unloaded", deleted), deleted);
11871190
else if (command == DOBUF_DEL)
1188-
{
1189-
if (deleted == 1)
1190-
MSG(_("1 buffer deleted"));
1191-
else
1192-
smsg((char_u *)_("%d buffers deleted"), deleted);
1193-
}
1191+
smsg((char_u *)NGETTEXT("%d buffer deleted",
1192+
"%d buffers deleted", deleted), deleted);
11941193
else
1195-
{
1196-
if (deleted == 1)
1197-
MSG(_("1 buffer wiped out"));
1198-
else
1199-
smsg((char_u *)_("%d buffers wiped out"), deleted);
1200-
}
1194+
smsg((char_u *)NGETTEXT("%d buffer wiped out",
1195+
"%d buffers wiped out", deleted), deleted);
12011196
}
12021197
}
12031198

@@ -3489,19 +3484,14 @@ fileinfo(
34893484
n = (int)(((long)curwin->w_cursor.lnum * 100L) /
34903485
(long)curbuf->b_ml.ml_line_count);
34913486
if (curbuf->b_ml.ml_flags & ML_EMPTY)
3492-
{
34933487
vim_snprintf_add((char *)buffer, IOSIZE, "%s", _(no_lines_msg));
3494-
}
34953488
#ifdef FEAT_CMDL_INFO
34963489
else if (p_ru)
3497-
{
34983490
/* Current line and column are already on the screen -- webb */
3499-
if (curbuf->b_ml.ml_line_count == 1)
3500-
vim_snprintf_add((char *)buffer, IOSIZE, _("1 line --%d%%--"), n);
3501-
else
3502-
vim_snprintf_add((char *)buffer, IOSIZE, _("%ld lines --%d%%--"),
3503-
(long)curbuf->b_ml.ml_line_count, n);
3504-
}
3491+
vim_snprintf_add((char *)buffer, IOSIZE,
3492+
NGETTEXT("%ld line --%d%%--", "%ld lines --%d%%--",
3493+
curbuf->b_ml.ml_line_count),
3494+
(long)curbuf->b_ml.ml_line_count, n);
35053495
#endif
35063496
else
35073497
{

src/dosinst.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,18 +1575,13 @@ install_registry(void)
15751575
}
15761576

15771577
printf("Creating an uninstall entry\n");
1578+
sprintf(display_name, "Vim " VIM_VERSION_SHORT);
15781579

15791580
/* For the NSIS installer use the generated uninstaller. */
15801581
if (interactive)
1581-
{
1582-
sprintf(display_name, "Vim " VIM_VERSION_SHORT);
15831582
sprintf(uninstall_string, "%s\\uninstal.exe", installdir);
1584-
}
15851583
else
1586-
{
1587-
sprintf(display_name, "Vim " VIM_VERSION_SHORT " (self-installing)");
15881584
sprintf(uninstall_string, "%s\\uninstall-gui.exe", installdir);
1589-
}
15901585

15911586
lRet = register_uninstall(
15921587
HKEY_LOCAL_MACHINE,

src/evalfunc.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ static void f_strdisplaywidth(typval_T *argvars, typval_T *rettv);
398398
static void f_strwidth(typval_T *argvars, typval_T *rettv);
399399
static void f_submatch(typval_T *argvars, typval_T *rettv);
400400
static void f_substitute(typval_T *argvars, typval_T *rettv);
401+
static void f_swapinfo(typval_T *argvars, typval_T *rettv);
401402
static void f_synID(typval_T *argvars, typval_T *rettv);
402403
static void f_synIDattr(typval_T *argvars, typval_T *rettv);
403404
static void f_synIDtrans(typval_T *argvars, typval_T *rettv);
@@ -463,6 +464,7 @@ static void f_win_screenpos(typval_T *argvars, typval_T *rettv);
463464
static void f_winbufnr(typval_T *argvars, typval_T *rettv);
464465
static void f_wincol(typval_T *argvars, typval_T *rettv);
465466
static void f_winheight(typval_T *argvars, typval_T *rettv);
467+
static void f_winlayout(typval_T *argvars, typval_T *rettv);
466468
static void f_winline(typval_T *argvars, typval_T *rettv);
467469
static void f_winnr(typval_T *argvars, typval_T *rettv);
468470
static void f_winrestcmd(typval_T *argvars, typval_T *rettv);
@@ -858,6 +860,7 @@ static struct fst
858860
{"strwidth", 1, 1, f_strwidth},
859861
{"submatch", 1, 2, f_submatch},
860862
{"substitute", 4, 4, f_substitute},
863+
{"swapinfo", 1, 1, f_swapinfo},
861864
{"synID", 3, 3, f_synID},
862865
{"synIDattr", 2, 3, f_synIDattr},
863866
{"synIDtrans", 1, 1, f_synIDtrans},
@@ -952,6 +955,7 @@ static struct fst
952955
{"winbufnr", 1, 1, f_winbufnr},
953956
{"wincol", 0, 0, f_wincol},
954957
{"winheight", 1, 1, f_winheight},
958+
{"winlayout", 0, 1, f_winlayout},
955959
{"winline", 0, 0, f_winline},
956960
{"winnr", 0, 1, f_winnr},
957961
{"winrestcmd", 0, 0, f_winrestcmd},
@@ -12342,6 +12346,16 @@ f_substitute(typval_T *argvars, typval_T *rettv)
1234212346
rettv->vval.v_string = do_string_sub(str, pat, sub, expr, flg);
1234312347
}
1234412348

12349+
/*
12350+
* "swapinfo(swap_filename)" function
12351+
*/
12352+
static void
12353+
f_swapinfo(typval_T *argvars, typval_T *rettv)
12354+
{
12355+
if (rettv_dict_alloc(rettv) == OK)
12356+
get_b0_dict(get_tv_string(argvars), rettv->vval.v_dict);
12357+
}
12358+
1234512359
/*
1234612360
* "synID(lnum, col, trans)" function
1234712361
*/
@@ -13773,6 +13787,29 @@ f_winheight(typval_T *argvars, typval_T *rettv)
1377313787
rettv->vval.v_number = wp->w_height;
1377413788
}
1377513789

13790+
/*
13791+
* "winlayout()" function
13792+
*/
13793+
static void
13794+
f_winlayout(typval_T *argvars, typval_T *rettv)
13795+
{
13796+
tabpage_T *tp;
13797+
13798+
if (rettv_list_alloc(rettv) != OK)
13799+
return;
13800+
13801+
if (argvars[0].v_type == VAR_UNKNOWN)
13802+
tp = curtab;
13803+
else
13804+
{
13805+
tp = find_tabpage((int)get_tv_number(&argvars[0]));
13806+
if (tp == NULL)
13807+
return;
13808+
}
13809+
13810+
get_framelayout(tp->tp_topframe, rettv->vval.v_list, TRUE);
13811+
}
13812+
1377613813
/*
1377713814
* "winline()" function
1377813815
*/

src/ex_cmds.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -985,12 +985,8 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
985985
ml_delete(line1 + extra, TRUE);
986986

987987
if (!global_busy && num_lines > p_report)
988-
{
989-
if (num_lines == 1)
990-
MSG(_("1 line moved"));
991-
else
992-
smsg((char_u *)_("%ld lines moved"), num_lines);
993-
}
988+
smsg((char_u *)NGETTEXT("%ld line moved", "%ld lines moved", num_lines),
989+
(long)num_lines);
994990

995991
/*
996992
* Leave the cursor on the last of the moved lines.
@@ -5940,23 +5936,29 @@ do_sub_msg(
59405936
|| count_only)
59415937
&& messaging())
59425938
{
5939+
char *msg_single;
5940+
char *msg_plural;
5941+
59435942
if (got_int)
59445943
STRCPY(msg_buf, _("(Interrupted) "));
59455944
else
59465945
*msg_buf = NUL;
5947-
if (sub_nsubs == 1)
5948-
vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
5949-
"%s", count_only ? _("1 match") : _("1 substitution"));
5950-
else
5951-
vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
5952-
count_only ? _("%ld matches") : _("%ld substitutions"),
5953-
sub_nsubs);
5954-
if (sub_nlines == 1)
5955-
vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
5956-
"%s", _(" on 1 line"));
5957-
else
5958-
vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
5959-
_(" on %ld lines"), (long)sub_nlines);
5946+
5947+
msg_single = count_only
5948+
? NGETTEXT("%ld match on %ld line",
5949+
"%ld matches on %ld line", sub_nsubs)
5950+
: NGETTEXT("%ld substitution on %ld line",
5951+
"%ld substitutions on %ld line", sub_nsubs);
5952+
msg_plural = count_only
5953+
? NGETTEXT("%ld match on %ld lines",
5954+
"%ld matches on %ld lines", sub_nsubs)
5955+
: NGETTEXT("%ld substitution on %ld lines",
5956+
"%ld substitutions on %ld lines", sub_nsubs);
5957+
5958+
vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
5959+
NGETTEXT(msg_single, msg_plural, sub_nlines),
5960+
sub_nsubs, (long)sub_nlines);
5961+
59605962
if (msg(msg_buf))
59615963
/* save message to display it after redraw */
59625964
set_keep_msg(msg_buf, 0);

src/ex_cmds.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,12 @@ struct exarg
17971797
void *cookie; /* argument for getline() */
17981798
#ifdef FEAT_EVAL
17991799
struct condstack *cstack; /* condition stack for ":if" etc. */
1800+
#endif
1801+
long verbose_save; // saved value of p_verbose
1802+
int save_msg_silent; // saved value of msg_silent
1803+
int did_esilent; // how many times emsg_silent was incremented
1804+
#ifdef HAVE_SANDBOX
1805+
int did_sandbox; // when TRUE did ++sandbox
18001806
#endif
18011807
};
18021808

0 commit comments

Comments
 (0)