Skip to content

Commit 5d69fdb

Browse files
committed
patch 8.1.1952: more functions can be used as a method
Problem: More functions can be used as a method. Solution: Allow more functions to be used as a method.
1 parent f169996 commit 5d69fdb

9 files changed

Lines changed: 44 additions & 17 deletions

File tree

runtime/doc/eval.txt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.1. Last change: 2019 Aug 28
1+
*eval.txt* For Vim version 8.1. Last change: 2019 Aug 31
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -5517,7 +5517,7 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
55175517
gettabwinvar({tabnr}, {winnr}, '&')
55185518
55195519
< Can also be used as a |method|: >
5520-
GetTabnr()->gettabvar(winnr, varname)
5520+
GetTabnr()->gettabwinvar(winnr, varname)
55215521
55225522
gettagstack([{nr}]) *gettagstack()*
55235523
The result is a Dict, which is the tag stack of window {nr}.
@@ -5547,6 +5547,9 @@ gettagstack([{nr}]) *gettagstack()*
55475547

55485548
See |tagstack| for more information about the tag stack.
55495549

5550+
Can also be used as a |method|: >
5551+
GetWinnr()->gettagstack()
5552+
55505553
getwininfo([{winid}]) *getwininfo()*
55515554
Returns information about windows as a List with Dictionaries.
55525555

@@ -5581,6 +5584,9 @@ getwininfo([{winid}]) *getwininfo()*
55815584
winrow topmost screen column of the window,
55825585
row from |win_screenpos()|
55835586

5587+
Can also be used as a |method|: >
5588+
GetWinnr()->getwininfo()
5589+
55845590
getwinpos([{timeout}]) *getwinpos()*
55855591
The result is a list with two numbers, the result of
55865592
getwinposx() and getwinposy() combined:
@@ -5600,6 +5606,10 @@ getwinpos([{timeout}]) *getwinpos()*
56005606
" Do some work here
56015607
endwhile
56025608
<
5609+
5610+
Can also be used as a |method|: >
5611+
GetTimeout()->getwinpos()
5612+
<
56035613
*getwinposx()*
56045614
getwinposx() The result is a Number, which is the X coordinate in pixels of
56055615
the left hand side of the GUI Vim window. Also works for an
@@ -5619,6 +5629,9 @@ getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
56195629
Examples: >
56205630
:let list_is_on = getwinvar(2, '&list')
56215631
:echo "myvar = " . getwinvar(1, 'myvar')
5632+
5633+
< Can also be used as a |method|: >
5634+
GetWinnr()->getwinvar(varname)
56225635
<
56235636
glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
56245637
Expand the file wildcards in {expr}. See |wildcards| for the
@@ -5656,6 +5669,9 @@ glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
56565669
See |expand()| for expanding special Vim variables. See
56575670
|system()| for getting the raw output of an external command.
56585671

5672+
Can also be used as a |method|: >
5673+
GetExpr()->glob()
5674+
56595675
glob2regpat({expr}) *glob2regpat()*
56605676
Convert a file pattern, as used by glob(), into a search
56615677
pattern. The result can be used to match with a string that
@@ -5668,7 +5684,9 @@ glob2regpat({expr}) *glob2regpat()*
56685684
Note that the result depends on the system. On MS-Windows
56695685
a backslash usually means a path separator.
56705686

5671-
*globpath()*
5687+
Can also be used as a |method|: >
5688+
GetExpr()->glob2regpat()
5689+
< *globpath()*
56725690
globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
56735691
Perform glob() on all directories in {path} and concatenate
56745692
the results. Example: >
@@ -5704,6 +5722,10 @@ globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
57045722
< Upwards search and limiting the depth of "**" is not
57055723
supported, thus using 'path' will not always work properly.
57065724

5725+
Can also be used as a |method|, the base is passed as the
5726+
second argument: >
5727+
GetExpr()->globpath(&rtp)
5728+
<
57075729
*has()*
57085730
has({feature}) The result is a Number, which is 1 if the feature {feature} is
57095731
supported, zero otherwise. The {feature} argument is a

src/evalfunc.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -584,15 +584,15 @@ static funcentry_T global_functions[] =
584584
{"gettabinfo", 0, 1, FEARG_1, f_gettabinfo},
585585
{"gettabvar", 2, 3, FEARG_1, f_gettabvar},
586586
{"gettabwinvar", 3, 4, FEARG_1, f_gettabwinvar},
587-
{"gettagstack", 0, 1, 0, f_gettagstack},
588-
{"getwininfo", 0, 1, 0, f_getwininfo},
589-
{"getwinpos", 0, 1, 0, f_getwinpos},
587+
{"gettagstack", 0, 1, FEARG_1, f_gettagstack},
588+
{"getwininfo", 0, 1, FEARG_1, f_getwininfo},
589+
{"getwinpos", 0, 1, FEARG_1, f_getwinpos},
590590
{"getwinposx", 0, 0, 0, f_getwinposx},
591591
{"getwinposy", 0, 0, 0, f_getwinposy},
592-
{"getwinvar", 2, 3, 0, f_getwinvar},
593-
{"glob", 1, 4, 0, f_glob},
594-
{"glob2regpat", 1, 1, 0, f_glob2regpat},
595-
{"globpath", 2, 5, 0, f_globpath},
592+
{"getwinvar", 2, 3, FEARG_1, f_getwinvar},
593+
{"glob", 1, 4, FEARG_1, f_glob},
594+
{"glob2regpat", 1, 1, FEARG_1, f_glob2regpat},
595+
{"globpath", 2, 5, FEARG_2, f_globpath},
596596
{"has", 1, 1, 0, f_has},
597597
{"has_key", 2, 2, FEARG_1, f_has_key},
598598
{"haslocaldir", 0, 2, 0, f_haslocaldir},

src/testdir/test_bufwintabinfo.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function Test_getbufwintabinfo()
7777

7878
call assert_equal('green', winlist[2].variables.signal)
7979
call assert_equal(w4_id, winlist[3].winid)
80-
let winfo = getwininfo(w5_id)[0]
80+
let winfo = w5_id->getwininfo()[0]
8181
call assert_equal(2, winfo.tabnr)
8282
call assert_equal([], getwininfo(3))
8383

src/testdir/test_escaped_glob.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function Test_glob()
1616
" Execute these commands in the sandbox, so that using the shell fails.
1717
" Setting 'shell' to an invalid name causes a memory leak.
1818
sandbox call assert_equal("", glob('Xxx\{'))
19-
sandbox call assert_equal("", glob('Xxx\$'))
19+
sandbox call assert_equal("", 'Xxx\$'->glob())
2020
w! Xxx\{
2121
w! Xxx\$
2222
sandbox call assert_equal("Xxx{", glob('Xxx\{'))
@@ -29,5 +29,5 @@ function Test_globpath()
2929
sandbox call assert_equal("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim",
3030
\ globpath('sautest/autoload', 'glob*.vim'))
3131
sandbox call assert_equal(['sautest/autoload/globone.vim', 'sautest/autoload/globtwo.vim'],
32-
\ globpath('sautest/autoload', 'glob*.vim', 0, 1))
32+
\ 'glob*.vim'->globpath('sautest/autoload', 0, 1))
3333
endfunction

src/testdir/test_getvar.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ func Test_var()
1212
let def_str = "Chance"
1313
call assert_equal('Dance', getwinvar(1, 'var_str'))
1414
call assert_equal('Dance', getwinvar(1, 'var_str', def_str))
15-
call assert_equal({'var_str': 'Dance'}, getwinvar(1, ''))
16-
call assert_equal({'var_str': 'Dance'}, getwinvar(1, '', def_str))
15+
call assert_equal({'var_str': 'Dance'}, 1->getwinvar(''))
16+
call assert_equal({'var_str': 'Dance'}, 1->getwinvar('', def_str))
1717
unlet w:var_str
1818
call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
1919
call assert_equal({}, getwinvar(1, ''))

src/testdir/test_glob2regpat.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ endfunc
88

99
func Test_glob2regpat_valid()
1010
call assert_equal('^foo\.', glob2regpat('foo.*'))
11-
call assert_equal('^foo.$', glob2regpat('foo?'))
11+
call assert_equal('^foo.$', 'foo?'->glob2regpat())
1212
call assert_equal('\.vim$', glob2regpat('*.vim'))
1313
call assert_equal('^[abc]$', glob2regpat('[abc]'))
1414
call assert_equal('^foo bar$', glob2regpat('foo\ bar'))

src/testdir/test_tagjump.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func Test_getsettagstack()
268268
enew | only
269269
call settagstack(1, {'items' : []})
270270
call assert_equal(0, gettagstack(1).length)
271-
call assert_equal([], gettagstack(1).items)
271+
call assert_equal([], 1->gettagstack().items)
272272
" Error cases
273273
call assert_equal({}, gettagstack(100))
274274
call assert_equal(-1, settagstack(100, {'items' : []}))

src/testdir/test_terminal.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,6 +2066,9 @@ func Test_terminal_getwinpos()
20662066
" In the GUI it can be more, let's assume a 20 x 14 cell.
20672067
" And then add 100 / 200 tolerance.
20682068
let [xroot, yroot] = getwinpos()
2069+
let winpos = 50->getwinpos()
2070+
call assert_equal(xroot, winpos[0])
2071+
call assert_equal(yroot, winpos[1])
20692072
let [winrow, wincol] = win_screenpos('.')
20702073
let xoff = wincol * (has('gui_running') ? 14 : 7) + 100
20712074
let yoff = winrow * (has('gui_running') ? 20 : 10) + 200

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1952,
764766
/**/
765767
1951,
766768
/**/

0 commit comments

Comments
 (0)