Skip to content

Commit 0e47383

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 93d7fe4 + 833e5da commit 0e47383

29 files changed

Lines changed: 665 additions & 62 deletions

Filelist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,11 @@ RT_SCRIPTS = \
691691
runtime/compiler/README.txt \
692692
runtime/indent/*.vim \
693693
runtime/indent/README.txt \
694+
runtime/indent/Makefile \
695+
runtime/indent/testdir/README.txt \
696+
runtime/indent/testdir/*.vim \
697+
runtime/indent/testdir/*.in \
698+
runtime/indent/testdir/*.ok \
694699
runtime/ftplugin/*.vim \
695700
runtime/ftplugin/logtalk.dict \
696701
runtime/ftplugin/README.txt \

runtime/doc/eval.txt

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,11 +2026,11 @@ append({lnum}, {text}) Number append {text} below line {lnum}
20262026
appendbufline({expr}, {lnum}, {text})
20272027
Number append {text} below line {lnum}
20282028
in buffer {expr}
2029-
argc() Number number of files in the argument list
2029+
argc( [{winid}]) Number number of files in the argument list
20302030
argidx() Number current index in the argument list
20312031
arglistid([{winnr} [, {tabnr}]]) Number argument list id
2032-
argv({nr}) String {nr} entry of the argument list
2033-
argv() List the argument list
2032+
argv({nr} [, {winid}]) String {nr} entry of the argument list
2033+
argv([-1, {winid}]) List the argument list
20342034
assert_beeps({cmd}) Number assert {cmd} causes a beep
20352035
assert_equal({exp}, {act} [, {msg}])
20362036
Number assert {exp} is equal to {act}
@@ -2596,8 +2596,15 @@ appendbufline({expr}, {lnum}, {text}) *appendbufline()*
25962596
:let failed = appendbufline(13, 0, "# THE START")
25972597
<
25982598
*argc()*
2599-
argc() The result is the number of files in the argument list of the
2600-
current window. See |arglist|.
2599+
argc([{winid}])
2600+
The result is the number of files in the argument list. See
2601+
|arglist|.
2602+
If {winid} is not supplied, the argument list of the current
2603+
window is used.
2604+
If {winid} is -1, the global argument list is used.
2605+
Otherwise {winid} specifies the window of which the argument
2606+
list is used: either the window number or the window ID.
2607+
Returns -1 if the {winid} argument is invalid.
26012608

26022609
*argidx()*
26032610
argidx() The result is the current index in the argument list. 0 is
@@ -2608,7 +2615,7 @@ arglistid([{winnr} [, {tabnr}]])
26082615
Return the argument list ID. This is a number which
26092616
identifies the argument list being used. Zero is used for the
26102617
global argument list. See |arglist|.
2611-
Return -1 if the arguments are invalid.
2618+
Returns -1 if the arguments are invalid.
26122619

26132620
Without arguments use the current window.
26142621
With {winnr} only use this window in the current tab page.
@@ -2617,17 +2624,19 @@ arglistid([{winnr} [, {tabnr}]])
26172624
{winnr} can be the window number or the |window-ID|.
26182625

26192626
*argv()*
2620-
argv([{nr}]) The result is the {nr}th file in the argument list of the
2621-
current window. See |arglist|. "argv(0)" is the first one.
2622-
Example: >
2627+
argv([{nr} [, {winid}])
2628+
The result is the {nr}th file in the argument list. See
2629+
|arglist|. "argv(0)" is the first one. Example: >
26232630
:let i = 0
26242631
:while i < argc()
26252632
: let f = escape(fnameescape(argv(i)), '.')
26262633
: exe 'amenu Arg.' . f . ' :e ' . f . '<CR>'
26272634
: let i = i + 1
26282635
:endwhile
2629-
< Without the {nr} argument a |List| with the whole |arglist| is
2630-
returned.
2636+
< Without the {nr} argument, or when {nr} is -1, a |List| with
2637+
the whole |arglist| is returned.
2638+
2639+
The {winid} argument specifies the window ID, see |argc()|.
26312640

26322641
assert_beeps({cmd}) *assert_beeps()*
26332642
Run {cmd} and add an error message to |v:errors| if it does

runtime/doc/various.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,18 @@ N *+X11* Unix only: can restore window title |X11|
568568
The pattern is matched against the relevant part of
569569
the output, not necessarily the whole line. Only some
570570
commands support filtering, try it out to check if it
571-
works.
571+
works. Some of the commands that support filtering:
572+
|:#| - filter whole line
573+
|:command| - filter by command name
574+
|:files| - filter by file name
575+
|:highlight| - filter by highlight group
576+
|:jumps| - filter by file name
577+
|:let| - filter by variable name
578+
|:list| - filter whole line
579+
|:llist| - filter by file name or module name
580+
|:oldfiles| - filter by file name
581+
|:clist| - filter by file name or module name
582+
|:set| - filter by variable name
572583

573584
Only normal messages are filtered, error messages are
574585
not.

runtime/filetype.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,12 @@ au BufNewFile,BufRead *.mo,*.gdmo setf gdmo
613613
au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom
614614

615615
" Git
616-
au BufNewFile,BufRead COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG setf gitcommit
617-
au BufNewFile,BufRead *.git/config,.gitconfig,.gitmodules setf gitconfig
618-
au BufNewFile,BufRead *.git/modules/*/config setf gitconfig
619-
au BufNewFile,BufRead */.config/git/config setf gitconfig
616+
au BufNewFile,BufRead COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG setf gitcommit
617+
au BufNewFile,BufRead *.git/config,.gitconfig,/etc/gitconfig setf gitconfig
618+
au BufNewFile,BufRead */.config/git/config setf gitconfig
619+
au BufNewFile,BufRead .gitmodules,*.git/modules/*/config setf gitconfig
620620
if !empty($XDG_CONFIG_HOME)
621-
au BufNewFile,BufRead $XDG_CONFIG_HOME/git/config setf gitconfig
621+
au BufNewFile,BufRead $XDG_CONFIG_HOME/git/config setf gitconfig
622622
endif
623623
au BufNewFile,BufRead git-rebase-todo setf gitrebase
624624
au BufRead,BufNewFile .gitsendemail.msg.?????? setf gitsendemail

runtime/indent/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Portable Makefile for running indent tests.
2+
3+
VIM = vim
4+
5+
# Run the tests that didn't run yet or failed previously.
6+
# If a test succeeds a testdir/*.out file will be written.
7+
# If a test fails a testdir/*.fail file will be written.
8+
test:
9+
$(VIM) --not-a-term -u testdir/runtest.vim
10+
11+
12+
clean:
13+
$(VIM) --not-a-term -u testdir/cleantest.vim

runtime/indent/README.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ running. Add a test if the function exists and use ":finish", like this:
4343
The user may have several options set unlike you, try to write the file such
4444
that it works with any option settings. Also be aware of certain features not
4545
being compiled in.
46+
47+
To test the indent file, see testdir/README.txt.

runtime/indent/testdir/README.txt

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
TESTING INDENT SCRIPTS
2+
3+
We'll use FILETYPE for the filetype name here.
4+
5+
6+
FORMAT OF THE FILETYPE.IN FILE
7+
8+
First of all, create a FILETYPE.in file. It should contain:
9+
10+
- A modeline setting the 'filetype' and any other option values.
11+
This must work like a comment for FILETYPE. E.g. for vim:
12+
" vim: set ft=vim sw=4 :
13+
14+
- At least one block of lines to indent, prefixed with START_INDENT and
15+
followed by END_INDENT. These lines must also look like a comment for your
16+
FILETYPE. You would normally leave out all indent, so that the effect of
17+
the indent command results in adding indent. Example:
18+
19+
" START_INDENT
20+
func Some()
21+
let x = 1
22+
endfunc
23+
" END_INDENT
24+
25+
- Optionally, a line with INDENT_EXE, followed by a Vim command. This will be
26+
executed before indenting the lines. Example:
27+
28+
" START_INDENT
29+
" INDENT_EXE let g:vim_indent_cont = 6
30+
let cmd =
31+
\ 'some '
32+
\ 'string'
33+
" END_INDENT
34+
35+
Note that the command is not undone, you may need to reverse the effect for
36+
the next block of lines.
37+
38+
- Alternatively to indenting all the lines between START_INDENT and
39+
END_INDENT, use a INDENT_AT line, which specifies a pattern to find the line
40+
to indent. Example:
41+
42+
" START_INDENT
43+
" INDENT_AT this-line
44+
func Some()
45+
let f = x " this-line
46+
endfunc
47+
" END_INDENT
48+
49+
Alternatively you can use INDENT_NEXT to indent the line below the matching
50+
pattern:
51+
52+
" START_INDENT
53+
" INDENT_NEXT next-line
54+
func Some()
55+
" next-line
56+
let f = x
57+
endfunc
58+
" END_INDENT
59+
60+
Or use INDENT_PREV to indent the line above the matching pattern:
61+
62+
" START_INDENT
63+
" INDENT_PREV prev-line
64+
func Some()
65+
let f = x
66+
" prev-line
67+
endfunc
68+
" END_INDENT
69+
70+
It's best to keep the whole file valid for FILETYPE, so that syntax
71+
highlighting works normally, and any indenting that depends on the syntax
72+
highlighting also works.
73+
74+
75+
RUNNING THE TEST
76+
77+
Before running the test, create a FILETYPE.ok file. You can leave it empty at
78+
first.
79+
80+
Now run "make test". After Vim has done the indenting you will see a
81+
FILETYPE.fail file. This contains the actual result of indenting, and it's
82+
different from the FILETYPE.ok file.
83+
84+
Check the contents of the FILETYPE.fail file. If it is perfectly OK, then
85+
rename it to overwrite the FILETYPE.ok file. If you now run "make test" again,
86+
the test will pass and create a FILETYPE.out file, which is identical to the
87+
FILETYPE.ok file.
88+
89+
If you try to run "make test" again you will notice that nothing happens,
90+
because the FILETYPE.out file already exists. Delete it, or do "make clean",
91+
so that the text runs again. If you edit the FILETYPE.in file, so that it's
92+
newer than the FILETYPE.out file, the test will also run.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
" Deletes all the test output files: *.fail and *.out
2+
for fname in glob('testdir/*.out', 1, 1) + glob('testdir/*.fail', 1, 1)
3+
call delete(fname)
4+
endfor
5+
6+
quit

runtime/indent/testdir/runtest.vim

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
" Runs all the indent tests for which there is no .out file
2+
3+
set nocp
4+
filetype indent on
5+
set nowrapscan
6+
7+
au! SwapExists * call HandleSwapExists()
8+
func HandleSwapExists()
9+
" Ignore finding a swap file for the test input and output, the user might be
10+
" editing them and that's OK.
11+
if expand('<afile>') =~ '.*\.\(in\|out\|fail\|ok\)'
12+
let v:swapchoice = 'e'
13+
endif
14+
endfunc
15+
16+
for fname in glob('testdir/*.in', 1, 1)
17+
let root = substitute(fname, '\.in', '', '')
18+
19+
" Execute the test if the .out file does not exist of when the .in file is
20+
" newer.
21+
let in_time = getftime(fname)
22+
let out_time = getftime(root . '.out')
23+
if out_time < 0 || in_time > out_time
24+
call delete(root . '.fail')
25+
call delete(root . '.out')
26+
27+
set sw& ts& filetype=
28+
exe 'split ' . fname
29+
30+
let did_some = 0
31+
let failed = 0
32+
let end = 1
33+
while 1
34+
" Indent all the lines between "START_INDENT" and "END_INDENT"
35+
exe end
36+
let start = search('\<START_INDENT\>')
37+
let end = search('\<END_INDENT\>')
38+
if start <= 0 || end <= 0 || end <= start
39+
if did_some == 0
40+
call append(0, 'ERROR: START_INDENT and/or END_INDENT not found')
41+
let failed = 1
42+
endif
43+
break
44+
else
45+
let did_some = 1
46+
47+
" Execute all commands marked with INDENT_EXE and find any pattern.
48+
let lnum = start
49+
let pattern = ''
50+
let at = ''
51+
while 1
52+
exe lnum + 1
53+
let lnum_exe = search('\<INDENT_EXE\>')
54+
exe lnum + 1
55+
let indent_at = search('\<INDENT_\(AT\|NEXT\|PREV\)\>')
56+
if lnum_exe > 0 && lnum_exe < end && (indent_at <= 0 || lnum_exe < indent_at)
57+
exe substitute(getline(lnum_exe), '.*INDENT_EXE', '', '')
58+
let lnum = lnum_exe
59+
let start = lnum
60+
elseif indent_at > 0 && indent_at < end
61+
if pattern != ''
62+
call append(indent_at, 'ERROR: duplicate pattern')
63+
let failed = 1
64+
break
65+
endif
66+
let text = getline(indent_at)
67+
let pattern = substitute(text, '.*INDENT_\S*\s*', '', '')
68+
let at = substitute(text, '.*INDENT_\(\S*\).*', '\1', '')
69+
let lnum = indent_at
70+
let start = lnum
71+
else
72+
break
73+
endif
74+
endwhile
75+
76+
exe start + 1
77+
if pattern == ''
78+
exe 'normal =' . (end - 1) . 'G'
79+
else
80+
let lnum = search(pattern)
81+
if lnum <= 0
82+
call append(indent_at, 'ERROR: pattern not found: ' . pattern)
83+
let failed = 1
84+
break
85+
endif
86+
if at == 'AT'
87+
exe lnum
88+
elseif at == 'NEXT'
89+
exe lnum + 1
90+
else
91+
exe lnum - 1
92+
endif
93+
normal ==
94+
endif
95+
endif
96+
endwhile
97+
98+
if !failed
99+
" Check the resulting text equals the .ok file.
100+
if getline(1, '$') != readfile(root . '.ok')
101+
let failed = 1
102+
endif
103+
endif
104+
105+
if failed
106+
exe 'write ' . root . '.fail'
107+
echoerr 'Test ' . fname . ' FAILED!'
108+
sleep 2
109+
else
110+
exe 'write ' . root . '.out'
111+
endif
112+
113+
quit! " close the indented file
114+
endif
115+
endfor
116+
117+
qall!

0 commit comments

Comments
 (0)