diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-04 20:05:59 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-04 20:05:59 +0200 |
commit | 3f4f3d8e7e6fc0494d00cfb75669a554c8e67c8b (patch) | |
tree | ac8bdd089ce9a96e2e96033410b88b1836425a28 /src | |
parent | ea781459b9617aa47335061fcc78403495260315 (diff) |
patch 8.1.1984: more functions can be used as methodsv8.1.1984
Problem: More functions can be used as methods.
Solution: Make various functions usable as a method.
Diffstat (limited to 'src')
-rw-r--r-- | src/evalfunc.c | 22 | ||||
-rw-r--r-- | src/testdir/test_functions.vim | 14 | ||||
-rw-r--r-- | src/testdir/test_perl.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_prompt_buffer.vim | 17 | ||||
-rw-r--r-- | src/testdir/test_python2.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_python3.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_pyx2.vim | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
8 files changed, 33 insertions, 30 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 784132f5ae..3e8c48b7a2 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -625,12 +625,12 @@ static funcentry_T global_functions[] = #ifdef FEAT_MZSCHEME {"mzeval", 1, 1, FEARG_1, f_mzeval}, #endif - {"nextnonblank", 1, 1, 0, f_nextnonblank}, - {"nr2char", 1, 2, 0, f_nr2char}, + {"nextnonblank", 1, 1, FEARG_1, f_nextnonblank}, + {"nr2char", 1, 2, FEARG_1, f_nr2char}, {"or", 2, 2, FEARG_1, f_or}, - {"pathshorten", 1, 1, 0, f_pathshorten}, + {"pathshorten", 1, 1, FEARG_1, f_pathshorten}, #ifdef FEAT_PERL - {"perleval", 1, 1, 0, f_perleval}, + {"perleval", 1, 1, FEARG_1, f_perleval}, #endif #ifdef FEAT_TEXT_PROP {"popup_atcursor", 2, 2, FEARG_1, f_popup_atcursor}, @@ -657,12 +657,12 @@ static funcentry_T global_functions[] = #ifdef FEAT_FLOAT {"pow", 2, 2, FEARG_1, f_pow}, #endif - {"prevnonblank", 1, 1, 0, f_prevnonblank}, + {"prevnonblank", 1, 1, FEARG_1, f_prevnonblank}, {"printf", 1, 19, FEARG_2, f_printf}, #ifdef FEAT_JOB_CHANNEL - {"prompt_setcallback", 2, 2, 0, f_prompt_setcallback}, - {"prompt_setinterrupt", 2, 2, 0, f_prompt_setinterrupt}, - {"prompt_setprompt", 2, 2, 0, f_prompt_setprompt}, + {"prompt_setcallback", 2, 2, FEARG_1, f_prompt_setcallback}, + {"prompt_setinterrupt", 2, 2, FEARG_1, f_prompt_setinterrupt}, + {"prompt_setprompt", 2, 2, FEARG_1, f_prompt_setprompt}, #endif #ifdef FEAT_TEXT_PROP {"prop_add", 3, 3, 0, f_prop_add}, @@ -678,13 +678,13 @@ static funcentry_T global_functions[] = {"pum_getpos", 0, 0, 0, f_pum_getpos}, {"pumvisible", 0, 0, 0, f_pumvisible}, #ifdef FEAT_PYTHON3 - {"py3eval", 1, 1, 0, f_py3eval}, + {"py3eval", 1, 1, FEARG_1, f_py3eval}, #endif #ifdef FEAT_PYTHON - {"pyeval", 1, 1, 0, f_pyeval}, + {"pyeval", 1, 1, FEARG_1, f_pyeval}, #endif #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) - {"pyxeval", 1, 1, 0, f_pyxeval}, + {"pyxeval", 1, 1, FEARG_1, f_pyxeval}, #endif {"range", 1, 3, 0, f_range}, {"readdir", 1, 2, 0, f_readdir}, diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index d5ce5f02bf..fc22bcd320 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -400,10 +400,10 @@ endfunc func Test_pathshorten() call assert_equal('', pathshorten('')) call assert_equal('foo', pathshorten('foo')) - call assert_equal('/foo', pathshorten('/foo')) + call assert_equal('/foo', '/foo'->pathshorten()) call assert_equal('f/', pathshorten('foo/')) call assert_equal('f/bar', pathshorten('foo/bar')) - call assert_equal('f/b/foobar', pathshorten('foo/bar/foobar')) + call assert_equal('f/b/foobar', 'foo/bar/foobar'->pathshorten()) call assert_equal('/f/b/foobar', pathshorten('/foo/bar/foobar')) call assert_equal('.f/bar', pathshorten('.foo/bar')) call assert_equal('~f/bar', pathshorten('~foo/bar')) @@ -847,21 +847,21 @@ Test call assert_equal(0, nextnonblank(-1)) call assert_equal(0, nextnonblank(0)) call assert_equal(1, nextnonblank(1)) - call assert_equal(4, nextnonblank(2)) + call assert_equal(4, 2->nextnonblank()) call assert_equal(4, nextnonblank(3)) call assert_equal(4, nextnonblank(4)) call assert_equal(6, nextnonblank(5)) call assert_equal(6, nextnonblank(6)) call assert_equal(7, nextnonblank(7)) - call assert_equal(0, nextnonblank(8)) + call assert_equal(0, 8->nextnonblank()) call assert_equal(0, prevnonblank(-1)) call assert_equal(0, prevnonblank(0)) - call assert_equal(1, prevnonblank(1)) + call assert_equal(1, 1->prevnonblank()) call assert_equal(1, prevnonblank(2)) call assert_equal(1, prevnonblank(3)) call assert_equal(4, prevnonblank(4)) - call assert_equal(4, prevnonblank(5)) + call assert_equal(4, 5->prevnonblank()) call assert_equal(6, prevnonblank(6)) call assert_equal(7, prevnonblank(7)) call assert_equal(0, prevnonblank(8)) @@ -1220,7 +1220,7 @@ func Test_trim() call assert_equal("a", trim("a", "")) call assert_equal("", trim("", "a")) - let chars = join(map(range(1, 0x20) + [0xa0], {n -> nr2char(n)}), '') + let chars = join(map(range(1, 0x20) + [0xa0], {n -> n->nr2char()}), '') call assert_equal("x", trim(chars . "x" . chars)) endfunc diff --git a/src/testdir/test_perl.vim b/src/testdir/test_perl.vim index 8f23f2c136..b4df0ba26d 100644 --- a/src/testdir/test_perl.vim +++ b/src/testdir/test_perl.vim @@ -30,7 +30,7 @@ endfunc funct Test_VIM_Blob() call assert_equal('0z', perleval('VIM::Blob("")')) - call assert_equal('0z31326162', perleval('VIM::Blob("12ab")')) + call assert_equal('0z31326162', 'VIM::Blob("12ab")'->perleval()) call assert_equal('0z00010203', perleval('VIM::Blob("\x00\x01\x02\x03")')) call assert_equal('0z8081FEFF', perleval('VIM::Blob("\x80\x81\xfe\xff")')) endfunc diff --git a/src/testdir/test_prompt_buffer.vim b/src/testdir/test_prompt_buffer.vim index 028f3371e3..199c1c2984 100644 --- a/src/testdir/test_prompt_buffer.vim +++ b/src/testdir/test_prompt_buffer.vim @@ -48,6 +48,7 @@ func WriteScript(name) \ 'new', \ 'set buftype=prompt', \ 'call prompt_setcallback(bufnr(""), function("TextEntered"))', + \ 'eval bufnr("")->prompt_setprompt("cmd: ")', \ 'startinsert', \ ], a:name) endfunc @@ -60,10 +61,10 @@ func Test_prompt_basic() call WriteScript(scriptName) let buf = RunVimInTerminal('-S ' . scriptName, {}) - call WaitForAssert({-> assert_equal('%', term_getline(buf, 1))}) + call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))}) call term_sendkeys(buf, "hello\<CR>") - call WaitForAssert({-> assert_equal('% hello', term_getline(buf, 1))}) + call WaitForAssert({-> assert_equal('cmd: hello', term_getline(buf, 1))}) call WaitForAssert({-> assert_equal('Command: "hello"', term_getline(buf, 2))}) call WaitForAssert({-> assert_equal('Result: "hello"', term_getline(buf, 3))}) @@ -82,19 +83,19 @@ func Test_prompt_editing() call WriteScript(scriptName) let buf = RunVimInTerminal('-S ' . scriptName, {}) - call WaitForAssert({-> assert_equal('%', term_getline(buf, 1))}) + call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))}) let bs = "\<BS>" call term_sendkeys(buf, "hello" . bs . bs) - call WaitForAssert({-> assert_equal('% hel', term_getline(buf, 1))}) + call WaitForAssert({-> assert_equal('cmd: hel', term_getline(buf, 1))}) let left = "\<Left>" call term_sendkeys(buf, left . left . left . bs . '-') - call WaitForAssert({-> assert_equal('% -hel', term_getline(buf, 1))}) + call WaitForAssert({-> assert_equal('cmd: -hel', term_getline(buf, 1))}) let end = "\<End>" call term_sendkeys(buf, end . "x") - call WaitForAssert({-> assert_equal('% -helx', term_getline(buf, 1))}) + call WaitForAssert({-> assert_equal('cmd: -helx', term_getline(buf, 1))}) call term_sendkeys(buf, "\<C-U>exit\<CR>") call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))}) @@ -113,8 +114,8 @@ func Test_prompt_garbage_collect() new set buftype=prompt - call prompt_setcallback(bufnr(''), function('MyPromptCallback', [{}])) - call prompt_setinterrupt(bufnr(''), function('MyPromptInterrupt', [{}])) + eval bufnr('')->prompt_setcallback(function('MyPromptCallback', [{}])) + eval bufnr('')->prompt_setinterrupt(function('MyPromptInterrupt', [{}])) call test_garbagecollect_now() " Must not crash call feedkeys("\<CR>\<C-C>", 'xt') diff --git a/src/testdir/test_python2.vim b/src/testdir/test_python2.vim index 61cf959bad..de5b0c94ac 100644 --- a/src/testdir/test_python2.vim +++ b/src/testdir/test_python2.vim @@ -54,7 +54,7 @@ func Test_vim_function() try py f = vim.Function('\x80\xfdR' + vim.eval('s:foo()')) - call assert_equal(name, pyeval('f.name')) + call assert_equal(name, 'f.name'->pyeval()) catch call assert_false(v:exception) endtry diff --git a/src/testdir/test_python3.vim b/src/testdir/test_python3.vim index 7f48619209..d66e54f9d7 100644 --- a/src/testdir/test_python3.vim +++ b/src/testdir/test_python3.vim @@ -54,7 +54,7 @@ func Test_vim_function() try py3 f = vim.Function(b'\x80\xfdR' + vim.eval('s:foo()').encode()) - call assert_equal(name, py3eval('f.name')) + call assert_equal(name, 'f.name'->py3eval()) catch call assert_false(v:exception) endtry diff --git a/src/testdir/test_pyx2.vim b/src/testdir/test_pyx2.vim index 40e93c227b..20199a4f74 100644 --- a/src/testdir/test_pyx2.vim +++ b/src/testdir/test_pyx2.vim @@ -34,7 +34,7 @@ endfunc func Test_pyxeval() pyx import sys - call assert_match(s:py2pattern, split(pyxeval('sys.version'))[0]) + call assert_match(s:py2pattern, split('sys.version'->pyxeval())[0]) endfunc diff --git a/src/version.c b/src/version.c index bf67e38c75..7715bc80ce 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1984, +/**/ 1983, /**/ 1982, |