patch 8.1.1925: more functions can be used as methods
Problem: More functions can be used as methods.
Solution: Make various functions usable as a method.
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 07e5993..498e87f 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -561,9 +561,9 @@
{"garbagecollect", 0, 1, 0, f_garbagecollect},
{"get", 2, 3, FEARG_1, f_get},
{"getbufinfo", 0, 1, 0, f_getbufinfo},
- {"getbufline", 2, 3, 0, f_getbufline},
- {"getbufvar", 2, 3, 0, f_getbufvar},
- {"getchangelist", 1, 1, 0, f_getchangelist},
+ {"getbufline", 2, 3, FEARG_1, f_getbufline},
+ {"getbufvar", 2, 3, FEARG_1, f_getbufvar},
+ {"getchangelist", 0, 1, FEARG_1, f_getchangelist},
{"getchar", 0, 1, 0, f_getchar},
{"getcharmod", 0, 0, 0, f_getcharmod},
{"getcharsearch", 0, 0, 0, f_getcharsearch},
@@ -571,27 +571,27 @@
{"getcmdpos", 0, 0, 0, f_getcmdpos},
{"getcmdtype", 0, 0, 0, f_getcmdtype},
{"getcmdwintype", 0, 0, 0, f_getcmdwintype},
- {"getcompletion", 2, 3, 0, f_getcompletion},
+ {"getcompletion", 2, 3, FEARG_1, f_getcompletion},
{"getcurpos", 0, 0, 0, f_getcurpos},
- {"getcwd", 0, 2, 0, f_getcwd},
- {"getenv", 1, 1, 0, f_getenv},
+ {"getcwd", 0, 2, FEARG_1, f_getcwd},
+ {"getenv", 1, 1, FEARG_1, f_getenv},
{"getfontname", 0, 1, 0, f_getfontname},
- {"getfperm", 1, 1, 0, f_getfperm},
- {"getfsize", 1, 1, 0, f_getfsize},
- {"getftime", 1, 1, 0, f_getftime},
- {"getftype", 1, 1, 0, f_getftype},
- {"getjumplist", 0, 2, 0, f_getjumplist},
- {"getline", 1, 2, 0, f_getline},
+ {"getfperm", 1, 1, FEARG_1, f_getfperm},
+ {"getfsize", 1, 1, FEARG_1, f_getfsize},
+ {"getftime", 1, 1, FEARG_1, f_getftime},
+ {"getftype", 1, 1, FEARG_1, f_getftype},
+ {"getjumplist", 0, 2, FEARG_1, f_getjumplist},
+ {"getline", 1, 2, FEARG_1, f_getline},
{"getloclist", 1, 2, 0, f_getloclist},
{"getmatches", 0, 1, 0, f_getmatches},
{"getpid", 0, 0, 0, f_getpid},
- {"getpos", 1, 1, 0, f_getpos},
+ {"getpos", 1, 1, FEARG_1, f_getpos},
{"getqflist", 0, 1, 0, f_getqflist},
- {"getreg", 0, 3, 0, f_getreg},
- {"getregtype", 0, 1, 0, f_getregtype},
- {"gettabinfo", 0, 1, 0, f_gettabinfo},
- {"gettabvar", 2, 3, 0, f_gettabvar},
- {"gettabwinvar", 3, 4, 0, f_gettabwinvar},
+ {"getreg", 0, 3, FEARG_1, f_getreg},
+ {"getregtype", 0, 1, FEARG_1, f_getregtype},
+ {"gettabinfo", 0, 1, FEARG_1, f_gettabinfo},
+ {"gettabvar", 2, 3, FEARG_1, f_gettabvar},
+ {"gettabwinvar", 3, 4, FEARG_1, f_gettabwinvar},
{"gettagstack", 0, 1, 0, f_gettagstack},
{"getwininfo", 0, 1, 0, f_getwininfo},
{"getwinpos", 0, 1, 0, f_getwinpos},
@@ -793,7 +793,7 @@
{"setcharsearch", 1, 1, 0, f_setcharsearch},
{"setcmdpos", 1, 1, 0, f_setcmdpos},
{"setenv", 2, 2, 0, f_setenv},
- {"setfperm", 2, 2, 0, f_setfperm},
+ {"setfperm", 2, 2, FEARG_1, f_setfperm},
{"setline", 2, 2, 0, f_setline},
{"setloclist", 2, 4, 0, f_setloclist},
{"setmatches", 1, 2, 0, f_setmatches},
@@ -4477,10 +4477,15 @@
return;
#ifdef FEAT_JUMPLIST
- (void)tv_get_number(&argvars[0]); /* issue errmsg if type error */
- ++emsg_off;
- buf = tv_get_buf(&argvars[0], FALSE);
- --emsg_off;
+ if (argvars[0].v_type == VAR_UNKNOWN)
+ buf = curbuf;
+ else
+ {
+ (void)tv_get_number(&argvars[0]); // issue errmsg if type error
+ ++emsg_off;
+ buf = tv_get_buf(&argvars[0], FALSE);
+ --emsg_off;
+ }
if (buf == NULL)
return;
diff --git a/src/testdir/test_bufline.vim b/src/testdir/test_bufline.vim
index 183a186..50f7275 100644
--- a/src/testdir/test_bufline.vim
+++ b/src/testdir/test_bufline.vim
@@ -22,7 +22,7 @@
call assert_equal(1, setbufline(b, 5, ['x']))
call assert_equal(1, setbufline(bufnr('$') + 1, 1, ['x']))
call assert_equal(0, setbufline(b, 4, ['d', 'e']))
- call assert_equal(['c'], getbufline(b, 3))
+ call assert_equal(['c'], b->getbufline(3))
call assert_equal(['d'], getbufline(b, 4))
call assert_equal(['e'], getbufline(b, 5))
call assert_equal([], getbufline(b, 6))
diff --git a/src/testdir/test_bufwintabinfo.vim b/src/testdir/test_bufwintabinfo.vim
index 7f0a6ce..d9b3691 100644
--- a/src/testdir/test_bufwintabinfo.vim
+++ b/src/testdir/test_bufwintabinfo.vim
@@ -88,7 +88,7 @@
call assert_equal(2, tablist[1].tabnr)
call assert_equal('build', tablist[0].variables.space)
call assert_equal(w2_id, tablist[0].windows[0])
- call assert_equal([], gettabinfo(3))
+ call assert_equal([], 3->gettabinfo())
tabonly | only
@@ -106,7 +106,7 @@
endfunction
function Test_get_buf_options()
- let opts = getbufvar(bufnr('%'), '&')
+ let opts = bufnr()->getbufvar('&')
call assert_equal(v:t_dict, type(opts))
call assert_equal(8, opts.tabstop)
endfunc
diff --git a/src/testdir/test_cd.vim b/src/testdir/test_cd.vim
index e0dedfb..c3589b4 100644
--- a/src/testdir/test_cd.vim
+++ b/src/testdir/test_cd.vim
@@ -83,7 +83,7 @@
tabfirst
call chdir('..')
call assert_equal('y', fnamemodify(getcwd(1, 2), ':t'))
- call assert_equal('z', fnamemodify(getcwd(3, 2), ':t'))
+ call assert_equal('z', fnamemodify(3->getcwd(2), ':t'))
tabnext | wincmd t
eval '..'->chdir()
call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t'))
diff --git a/src/testdir/test_changelist.vim b/src/testdir/test_changelist.vim
index dd6ea96..ce77c1f 100644
--- a/src/testdir/test_changelist.vim
+++ b/src/testdir/test_changelist.vim
@@ -8,8 +8,8 @@
bwipe!
enew
- call assert_equal([], getchangelist(10))
- call assert_equal([[], 0], getchangelist('%'))
+ call assert_equal([], 10->getchangelist())
+ call assert_equal([[], 0], getchangelist())
call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt')
call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt')
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index f0d83c6..6ed7848 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -209,7 +209,7 @@
endif
let groupcount = len(getcompletion('', 'event'))
call assert_true(groupcount > 0)
- let matchcount = len(getcompletion('File', 'event'))
+ let matchcount = len('File'->getcompletion('event'))
call assert_true(matchcount > 0)
call assert_true(groupcount > matchcount)
diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim
index 32569b6..799642d 100644
--- a/src/testdir/test_edit.vim
+++ b/src/testdir/test_edit.vim
@@ -199,11 +199,11 @@
endfu
au InsertCharPre <buffer> :call DoIt()
call feedkeys("A\<f5>\<c-p>u\<cr>\<c-l>\<cr>", 'tx')
- call assert_equal(["Jan\<c-l>",''], getline(1,'$'))
+ call assert_equal(["Jan\<c-l>",''], 1->getline('$'))
%d
call setline(1, 'J')
call feedkeys("A\<f5>\<c-p>u\<down>\<c-l>\<cr>", 'tx')
- call assert_equal(["January"], getline(1,'$'))
+ call assert_equal(["January"], 1->getline('$'))
delfu ListMonths
delfu DoIt
@@ -345,7 +345,7 @@
call cursor(2, 4)
call feedkeys("R^\<c-d>", 'tnix')
call assert_equal(["\tabc", "def"], getline(1, '$'))
- call assert_equal([0, 2, 2, 0], getpos('.'))
+ call assert_equal([0, 2, 2, 0], '.'->getpos())
%d
call setline(1, ["\tabc", "\t\tdef"])
call cursor(2, 2)
diff --git a/src/testdir/test_environ.vim b/src/testdir/test_environ.vim
index 21bb09a..ba61b17 100644
--- a/src/testdir/test_environ.vim
+++ b/src/testdir/test_environ.vim
@@ -11,7 +11,7 @@
func Test_getenv()
unlet! $TESTENV
- call assert_equal(v:null, getenv('TESTENV'))
+ call assert_equal(v:null, 'TESTENV'->getenv())
let $TESTENV = 'foo'
call assert_equal('foo', getenv('TESTENV'))
endfunc
diff --git a/src/testdir/test_file_perm.vim b/src/testdir/test_file_perm.vim
index 0dba6a7..3950168 100644
--- a/src/testdir/test_file_perm.vim
+++ b/src/testdir/test_file_perm.vim
@@ -2,10 +2,10 @@
func Test_file_perm()
call assert_equal('', getfperm('Xtest'))
- call assert_equal(0, setfperm('Xtest', 'r--------'))
+ call assert_equal(0, 'Xtest'->setfperm('r--------'))
call writefile(['one'], 'Xtest')
- call assert_true(len(getfperm('Xtest')) == 9)
+ call assert_true(len('Xtest'->getfperm()) == 9)
call assert_equal(1, setfperm('Xtest', 'rwx------'))
if has('win32')
diff --git a/src/testdir/test_getvar.vim b/src/testdir/test_getvar.vim
index 3b61d68..e9868c7 100644
--- a/src/testdir/test_getvar.vim
+++ b/src/testdir/test_getvar.vim
@@ -31,7 +31,7 @@
let t:other = 777
let def_list = [4, 5, 6, 7]
tabrewind
- call assert_equal([1, 2, 3], gettabvar(3, 'var_list'))
+ call assert_equal([1, 2, 3], 3->gettabvar('var_list'))
call assert_equal([1, 2, 3], gettabvar(3, 'var_list', def_list))
call assert_equal({'var_list': [1, 2, 3], 'other': 777}, gettabvar(3, ''))
call assert_equal({'var_list': [1, 2, 3], 'other': 777},
@@ -61,7 +61,7 @@
let def_dict = {'dict2': 'newval'}
wincmd b
tabrewind
- call assert_equal({'dict': 'tabwin'}, gettabwinvar(2, 3, 'var_dict'))
+ call assert_equal({'dict': 'tabwin'}, 2->gettabwinvar(3, 'var_dict'))
call assert_equal({'dict': 'tabwin'},
\ gettabwinvar(2, 3, 'var_dict', def_dict))
call assert_equal({'var_dict': {'dict': 'tabwin'}}, gettabwinvar(2, 3, ''))
diff --git a/src/testdir/test_jumplist.vim b/src/testdir/test_jumplist.vim
index be1af5e..9cfbbe2 100644
--- a/src/testdir/test_jumplist.vim
+++ b/src/testdir/test_jumplist.vim
@@ -39,7 +39,7 @@
" Traverse the jump list and verify the results
5
exe "normal \<C-O>"
- call assert_equal(2, getjumplist(1)[1])
+ call assert_equal(2, 1->getjumplist()[1])
exe "normal 2\<C-O>"
call assert_equal(0, getjumplist(1, 1)[1])
exe "normal 3\<C-I>"
diff --git a/src/testdir/test_put.vim b/src/testdir/test_put.vim
index 80d2a26..afe82f9 100644
--- a/src/testdir/test_put.vim
+++ b/src/testdir/test_put.vim
@@ -22,7 +22,7 @@
func Test_put_char_block2()
new
- let a = [ getreg('a'), getregtype('a') ]
+ let a = [ 'a'->getreg(), 'a'->getregtype() ]
call setreg('a', ' one ', 'v')
call setline(1, ['Line 1', '', 'Line 3', ''])
" visually select the first 3 lines and put register a over it
diff --git a/src/testdir/test_stat.vim b/src/testdir/test_stat.vim
index e48e887..8ec2a42 100644
--- a/src/testdir/test_stat.vim
+++ b/src/testdir/test_stat.vim
@@ -10,7 +10,7 @@
let fl = ['Hello World!']
for fname in fnames
call writefile(fl, fname)
- call add(times, getftime(fname))
+ call add(times, fname->getftime())
if a:doSleep
sleep 1
endif
@@ -19,8 +19,8 @@
let time_correct = (times[0] <= times[1] && times[1] <= times[2])
if a:doSleep || time_correct
call assert_true(time_correct, printf('Expected %s <= %s <= %s', times[0], times[1], times[2]))
- call assert_equal(strlen(fl[0] . "\n"), getfsize(fnames[0]))
- call assert_equal('file', getftype(fnames[0]))
+ call assert_equal(strlen(fl[0] . "\n"), fnames[0]->getfsize())
+ call assert_equal('file', fnames[0]->getftype())
call assert_equal('rw-', getfperm(fnames[0])[0:2])
let result = 1
endif
diff --git a/src/version.c b/src/version.c
index cab79da..8501ae0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1925,
+/**/
1924,
/**/
1923,