patch 8.1.1921: 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 b5e98f4..c5ec21d 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -523,41 +523,41 @@
{"diff_hlID", 2, 2, FEARG_1, f_diff_hlID},
{"empty", 1, 1, FEARG_1, f_empty},
{"environ", 0, 0, 0, f_environ},
- {"escape", 2, 2, 0, f_escape},
+ {"escape", 2, 2, FEARG_1, f_escape},
{"eval", 1, 1, FEARG_1, f_eval},
{"eventhandler", 0, 0, 0, f_eventhandler},
- {"executable", 1, 1, 0, f_executable},
- {"execute", 1, 2, 0, f_execute},
- {"exepath", 1, 1, 0, f_exepath},
- {"exists", 1, 1, 0, f_exists},
+ {"executable", 1, 1, FEARG_1, f_executable},
+ {"execute", 1, 2, FEARG_1, f_execute},
+ {"exepath", 1, 1, FEARG_1, f_exepath},
+ {"exists", 1, 1, FEARG_1, f_exists},
#ifdef FEAT_FLOAT
{"exp", 1, 1, FEARG_1, f_exp},
#endif
- {"expand", 1, 3, 0, f_expand},
- {"expandcmd", 1, 1, 0, f_expandcmd},
+ {"expand", 1, 3, FEARG_1, f_expand},
+ {"expandcmd", 1, 1, FEARG_1, f_expandcmd},
{"extend", 2, 3, FEARG_1, f_extend},
- {"feedkeys", 1, 2, 0, f_feedkeys},
- {"file_readable", 1, 1, 0, f_filereadable}, // obsolete
- {"filereadable", 1, 1, 0, f_filereadable},
- {"filewritable", 1, 1, 0, f_filewritable},
+ {"feedkeys", 1, 2, FEARG_1, f_feedkeys},
+ {"file_readable", 1, 1, FEARG_1, f_filereadable}, // obsolete
+ {"filereadable", 1, 1, FEARG_1, f_filereadable},
+ {"filewritable", 1, 1, FEARG_1, f_filewritable},
{"filter", 2, 2, FEARG_1, f_filter},
- {"finddir", 1, 3, 0, f_finddir},
- {"findfile", 1, 3, 0, f_findfile},
+ {"finddir", 1, 3, FEARG_1, f_finddir},
+ {"findfile", 1, 3, FEARG_1, f_findfile},
#ifdef FEAT_FLOAT
{"float2nr", 1, 1, FEARG_1, f_float2nr},
{"floor", 1, 1, FEARG_1, f_floor},
{"fmod", 2, 2, FEARG_1, f_fmod},
#endif
- {"fnameescape", 1, 1, 0, f_fnameescape},
- {"fnamemodify", 2, 2, 0, f_fnamemodify},
- {"foldclosed", 1, 1, 0, f_foldclosed},
- {"foldclosedend", 1, 1, 0, f_foldclosedend},
- {"foldlevel", 1, 1, 0, f_foldlevel},
+ {"fnameescape", 1, 1, FEARG_1, f_fnameescape},
+ {"fnamemodify", 2, 2, FEARG_1, f_fnamemodify},
+ {"foldclosed", 1, 1, FEARG_1, f_foldclosed},
+ {"foldclosedend", 1, 1, FEARG_1, f_foldclosedend},
+ {"foldlevel", 1, 1, FEARG_1, f_foldlevel},
{"foldtext", 0, 0, 0, f_foldtext},
- {"foldtextresult", 1, 1, 0, f_foldtextresult},
+ {"foldtextresult", 1, 1, FEARG_1, f_foldtextresult},
{"foreground", 0, 0, 0, f_foreground},
- {"funcref", 1, 3, 0, f_funcref},
- {"function", 1, 3, 0, f_function},
+ {"funcref", 1, 3, FEARG_1, f_funcref},
+ {"function", 1, 3, FEARG_1, f_function},
{"garbagecollect", 0, 1, 0, f_garbagecollect},
{"get", 2, 3, FEARG_1, f_get},
{"getbufinfo", 0, 1, 0, f_getbufinfo},
diff --git a/src/testdir/test_expand.vim b/src/testdir/test_expand.vim
index bd8021f..53f753d 100644
--- a/src/testdir/test_expand.vim
+++ b/src/testdir/test_expand.vim
@@ -58,7 +58,7 @@
call assert_equal('e Xfile1', expandcmd('e %'))
edit Xfile2
edit Xfile1
- call assert_equal('e Xfile2', expandcmd('e #'))
+ call assert_equal('e Xfile2', 'e #'->expandcmd())
edit Xfile2
edit Xfile3
edit Xfile4
diff --git a/src/testdir/test_expand_func.vim b/src/testdir/test_expand_func.vim
index f6e5293..f9c5b5f 100644
--- a/src/testdir/test_expand_func.vim
+++ b/src/testdir/test_expand_func.vim
@@ -68,7 +68,7 @@
func Test_expand()
new
call assert_equal("", expand('%:S'))
- call assert_equal('3', expand('<slnum>'))
+ call assert_equal('3', '<slnum>'->expand())
call assert_equal(['4'], expand('<slnum>', v:false, v:true))
" Don't add any line above this, otherwise <slnum> will change.
quit
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim
index ccca792..9f43732 100644
--- a/src/testdir/test_expr.vim
+++ b/src/testdir/test_expr.vim
@@ -403,7 +403,7 @@
call assert_equal(string(value), printf('%s', value))
" funcref
- call assert_equal('printf', printf('%s', function('printf')))
+ call assert_equal('printf', printf('%s', 'printf'->function()))
" partial
call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s'])))
@@ -490,7 +490,7 @@
endfunc
call assert_equal(2, OneByName())
call assert_equal(1, OneByRef())
- let OneByRef = funcref('One')
+ let OneByRef = 'One'->funcref()
call assert_equal(2, OneByRef())
call assert_fails('echo funcref("{")', 'E475:')
endfunc
diff --git a/src/testdir/test_findfile.vim b/src/testdir/test_findfile.vim
index 0bae161..5cda2ea 100644
--- a/src/testdir/test_findfile.vim
+++ b/src/testdir/test_findfile.vim
@@ -50,7 +50,7 @@
set path=.
call assert_equal('Xdir2/foo', findfile('foo'))
call assert_equal('', findfile('bar'))
- call assert_equal('Xdir2/foobar', findfile('foobar'))
+ call assert_equal('Xdir2/foobar', 'foobar'->findfile())
" Empty {path} 2nd argument is the same as no 2nd argument.
call assert_equal('Xdir2/foo', findfile('foo', ''))
@@ -137,7 +137,7 @@
cd Xdir1
call assert_equal('Xdir2', finddir('Xdir2'))
- call assert_equal('', finddir('Xdir3'))
+ call assert_equal('', 'Xdir3'->finddir())
" Files should not be found (findfile() finds them).
call assert_equal('', finddir('foo'))
diff --git a/src/testdir/test_fnameescape.vim b/src/testdir/test_fnameescape.vim
index 5382b89..b0fdb3a 100644
--- a/src/testdir/test_fnameescape.vim
+++ b/src/testdir/test_fnameescape.vim
@@ -13,7 +13,7 @@
let fname = 'Xemark!'
let status = v:false
try
- exe "w! " . fnameescape(fname)
+ exe "w! " . fname->fnameescape()
let status = v:true
endtry
call assert_true(status, "ExclamationMark")
diff --git a/src/testdir/test_fnamemodify.vim b/src/testdir/test_fnamemodify.vim
index 63f2736..fd5f1ef 100644
--- a/src/testdir/test_fnamemodify.vim
+++ b/src/testdir/test_fnamemodify.vim
@@ -13,7 +13,7 @@
call assert_equal('a', fnamemodify('../testdir/a', ':.'))
call assert_equal('~/testdir/test.out', fnamemodify('test.out', ':~'))
call assert_equal('~/testdir/a', fnamemodify('../testdir/a', ':~'))
- call assert_equal('a', fnamemodify('../testdir/a', ':t'))
+ call assert_equal('a', '../testdir/a'->fnamemodify(':t'))
call assert_equal('', fnamemodify('.', ':p:t'))
call assert_equal('test.out', fnamemodify('test.out', ':p:t'))
call assert_equal('out', fnamemodify('test.out', ':p:e'))
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index 1d5259f..7aef51f 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -89,7 +89,7 @@
setl fen fdm=marker
2
norm! >>
- let a=map(range(1,5), 'foldclosed(v:val)')
+ let a=map(range(1,5), 'v:val->foldclosed()')
call assert_equal([-1,-1,-1,4,4], a)
bw!
endfunc
@@ -133,7 +133,7 @@
call assert_equal(0, foldlevel(3))
call assert_equal(0, foldlevel(4))
call assert_equal(1, foldlevel(5))
- call assert_equal(7, foldclosedend(5))
+ call assert_equal(7, 5->foldclosedend())
bwipe!
set foldmethod&
@@ -208,7 +208,7 @@
%foldclose
call assert_equal(2, foldclosedend(1))
call assert_equal(0, foldlevel(3))
- call assert_equal(0, foldlevel(4))
+ call assert_equal(0, 4->foldlevel())
call assert_equal(6, foldclosedend(5))
call assert_equal(10, foldclosedend(7))
call assert_equal(14, foldclosedend(11))
@@ -656,7 +656,7 @@
call assert_equal(10, foldclosed(10))
call assert_equal(11, foldclosedend(10))
call assert_equal('+-- 2 lines: Line2', foldtextresult(2))
- call assert_equal('+-- 2 lines: Line8', foldtextresult(10))
+ call assert_equal('+-- 2 lines: Line8', 10->foldtextresult())
set fdm& sw& fdl&
enew!
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 7a3d054..027700b 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1001,7 +1001,7 @@
call assert_equal(0, filewritable('Xfilewritable'))
call assert_notequal(0, setfperm('Xfilewritable', 'rw-r-----'))
- call assert_equal(1, filewritable('Xfilewritable'))
+ call assert_equal(1, 'Xfilewritable'->filewritable())
call assert_equal(0, filewritable('doesnotexist'))
@@ -1012,20 +1012,21 @@
func Test_Executable()
if has('win32')
call assert_equal(1, executable('notepad'))
- call assert_equal(1, executable('notepad.exe'))
+ call assert_equal(1, 'notepad.exe'->executable())
call assert_equal(0, executable('notepad.exe.exe'))
call assert_equal(0, executable('shell32.dll'))
call assert_equal(0, executable('win.ini'))
elseif has('unix')
- call assert_equal(1, executable('cat'))
+ call assert_equal(1, 'cat'->executable())
call assert_equal(0, executable('nodogshere'))
" get "cat" path and remove the leading /
let catcmd = exepath('cat')[1:]
new
+ " check that the relative path works in /
lcd /
call assert_equal(1, executable(catcmd))
- call assert_equal('/' .. catcmd, exepath(catcmd))
+ call assert_equal('/' .. catcmd, catcmd->exepath())
bwipe
endif
endfunc
@@ -1349,7 +1350,7 @@
sandbox let F = {-> 'hello'}
call assert_equal('hello', F())
- sandbox let F = {-> execute("normal ix\<Esc>")}
+ sandbox let F = {-> "normal ix\<Esc>"->execute()}
call assert_fails('call F()', 'E48:')
unlet F
@@ -1380,7 +1381,7 @@
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists')
call assert_equal(0, exists('*ExistingFunction'))
source Xfuncexists
- call assert_equal(1, exists('*ExistingFunction'))
+ call assert_equal(1, '*ExistingFunction'->exists())
" Redefining a function when reloading a script is OK.
source Xfuncexists
call assert_equal(1, exists('*ExistingFunction'))
@@ -1427,7 +1428,7 @@
" <Esc> requires another character to avoid it being seen as the start of an
" escape sequence. Zero should be harmless.
- call feedkeys("\<Esc>0", 'L')
+ eval "\<Esc>0"->feedkeys('L')
let a = confirm('Are you sure?', "&Yes\n&No")
call assert_equal(0, a)
@@ -1525,7 +1526,7 @@
call writefile([], 'Xdir/[a-1]/foo.txt')
call writefile([], 'Xdir/[a-1]/bar.txt')
call assert_true(filereadable('Xdir/foo.txt'))
- call assert_true(filereadable('Xdir/[a-1]/foo.txt'))
+ call assert_true('Xdir/[a-1]/foo.txt'->filereadable())
call assert_equal(0, delete('Xdir', 'rf'))
call assert_false(filereadable('Xdir/foo.txt'))
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 604f3c2..7c30a1a 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -1303,7 +1303,7 @@
call cursor(1, 1)
let @/ = 'foo'
- let pat = escape(@/, '()*?'. '\s\+')
+ let pat = @/->escape('()*?'. '\s\+')
let g:a = execute(':unsilent :norm! n')
call assert_match(pat, g:a)
diff --git a/src/testdir/test_vimscript.vim b/src/testdir/test_vimscript.vim
index dc4df44..8dc00f2 100644
--- a/src/testdir/test_vimscript.vim
+++ b/src/testdir/test_vimscript.vim
@@ -638,7 +638,7 @@
if v:errmsg == ""
Xout "Message missing."
else
- let v:errmsg = escape(v:errmsg, '"')
+ let v:errmsg = v:errmsg->escape('"')
Xout "Unexpected message:" v:errmsg
endif
endif
diff --git a/src/version.c b/src/version.c
index 9d4e89b..58d86e5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1921,
+/**/
1920,
/**/
1919,