To: vim_dev@googlegroups.com Subject: Patch 8.1.1952 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1952 Problem: More functions can be used as a method. Solution: Allow more functions to be used as a method. Files: runtime/doc/eval.txt, src/evalfunc.c, src/testdir/test_tagjump.vim, src/testdir/test_bufwintabinfo.vim, src/testdir/test_terminal.vim, src/testdir/test_getvar.vim, src/testdir/test_escaped_glob.vim, src/testdir/test_glob2regpat.vim, *** ../vim-8.1.1951/runtime/doc/eval.txt 2019-08-24 22:58:08.307264136 +0200 --- runtime/doc/eval.txt 2019-08-31 19:06:15.291091331 +0200 *************** *** 40,46 **** 1.1 Variable types ~ *E712* *E896* *E897* *E899* ! There are nine types of variables: Number A 32 or 64 bit signed number. |expr-number| *Number* 64-bit Numbers are available only when compiled with the --- 40,46 ---- 1.1 Variable types ~ *E712* *E896* *E897* *E899* ! There are ten types of variables: Number A 32 or 64 bit signed number. |expr-number| *Number* 64-bit Numbers are available only when compiled with the *************** *** 5509,5515 **** gettabwinvar({tabnr}, {winnr}, '&') < Can also be used as a |method|: > ! GetTabnr()->gettabvar(winnr, varname) gettagstack([{nr}]) *gettagstack()* The result is a Dict, which is the tag stack of window {nr}. --- 5517,5523 ---- gettabwinvar({tabnr}, {winnr}, '&') < Can also be used as a |method|: > ! GetTabnr()->gettabwinvar(winnr, varname) gettagstack([{nr}]) *gettagstack()* The result is a Dict, which is the tag stack of window {nr}. *************** *** 5539,5544 **** --- 5547,5555 ---- See |tagstack| for more information about the tag stack. + Can also be used as a |method|: > + GetWinnr()->gettagstack() + getwininfo([{winid}]) *getwininfo()* Returns information about windows as a List with Dictionaries. *************** *** 5573,5578 **** --- 5584,5592 ---- winrow topmost screen column of the window, row from |win_screenpos()| + Can also be used as a |method|: > + GetWinnr()->getwininfo() + getwinpos([{timeout}]) *getwinpos()* The result is a list with two numbers, the result of getwinposx() and getwinposy() combined: *************** *** 5592,5597 **** --- 5606,5615 ---- " Do some work here endwhile < + + Can also be used as a |method|: > + GetTimeout()->getwinpos() + < *getwinposx()* getwinposx() The result is a Number, which is the X coordinate in pixels of the left hand side of the GUI Vim window. Also works for an *************** *** 5611,5616 **** --- 5629,5637 ---- Examples: > :let list_is_on = getwinvar(2, '&list') :echo "myvar = " . getwinvar(1, 'myvar') + + < Can also be used as a |method|: > + GetWinnr()->getwinvar(varname) < glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()* Expand the file wildcards in {expr}. See |wildcards| for the *************** *** 5648,5653 **** --- 5669,5677 ---- See |expand()| for expanding special Vim variables. See |system()| for getting the raw output of an external command. + Can also be used as a |method|: > + GetExpr()->glob() + glob2regpat({expr}) *glob2regpat()* Convert a file pattern, as used by glob(), into a search pattern. The result can be used to match with a string that *************** *** 5660,5666 **** Note that the result depends on the system. On MS-Windows a backslash usually means a path separator. ! *globpath()* globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]]) Perform glob() on all directories in {path} and concatenate the results. Example: > --- 5684,5692 ---- Note that the result depends on the system. On MS-Windows a backslash usually means a path separator. ! Can also be used as a |method|: > ! GetExpr()->glob2regpat() ! < *globpath()* globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]]) Perform glob() on all directories in {path} and concatenate the results. Example: > *************** *** 5696,5701 **** --- 5722,5731 ---- < Upwards search and limiting the depth of "**" is not supported, thus using 'path' will not always work properly. + Can also be used as a |method|, the base is passed as the + second argument: > + GetExpr()->globpath(&rtp) + < *has()* has({feature}) The result is a Number, which is 1 if the feature {feature} is supported, zero otherwise. The {feature} argument is a *** ../vim-8.1.1951/src/evalfunc.c 2019-08-30 15:46:27.188906163 +0200 --- src/evalfunc.c 2019-08-31 19:06:29.534972984 +0200 *************** *** 584,598 **** {"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}, {"getwinposx", 0, 0, 0, f_getwinposx}, {"getwinposy", 0, 0, 0, f_getwinposy}, ! {"getwinvar", 2, 3, 0, f_getwinvar}, ! {"glob", 1, 4, 0, f_glob}, ! {"glob2regpat", 1, 1, 0, f_glob2regpat}, ! {"globpath", 2, 5, 0, f_globpath}, {"has", 1, 1, 0, f_has}, {"has_key", 2, 2, FEARG_1, f_has_key}, {"haslocaldir", 0, 2, 0, f_haslocaldir}, --- 584,598 ---- {"gettabinfo", 0, 1, FEARG_1, f_gettabinfo}, {"gettabvar", 2, 3, FEARG_1, f_gettabvar}, {"gettabwinvar", 3, 4, FEARG_1, f_gettabwinvar}, ! {"gettagstack", 0, 1, FEARG_1, f_gettagstack}, ! {"getwininfo", 0, 1, FEARG_1, f_getwininfo}, ! {"getwinpos", 0, 1, FEARG_1, f_getwinpos}, {"getwinposx", 0, 0, 0, f_getwinposx}, {"getwinposy", 0, 0, 0, f_getwinposy}, ! {"getwinvar", 2, 3, FEARG_1, f_getwinvar}, ! {"glob", 1, 4, FEARG_1, f_glob}, ! {"glob2regpat", 1, 1, FEARG_1, f_glob2regpat}, ! {"globpath", 2, 5, FEARG_2, f_globpath}, {"has", 1, 1, 0, f_has}, {"has_key", 2, 2, FEARG_1, f_has_key}, {"haslocaldir", 0, 2, 0, f_haslocaldir}, *** ../vim-8.1.1951/src/testdir/test_tagjump.vim 2019-06-15 18:40:11.044368488 +0200 --- src/testdir/test_tagjump.vim 2019-08-31 18:25:21.322730488 +0200 *************** *** 268,274 **** enew | only call settagstack(1, {'items' : []}) call assert_equal(0, gettagstack(1).length) ! call assert_equal([], gettagstack(1).items) " Error cases call assert_equal({}, gettagstack(100)) call assert_equal(-1, settagstack(100, {'items' : []})) --- 268,274 ---- enew | only call settagstack(1, {'items' : []}) call assert_equal(0, gettagstack(1).length) ! call assert_equal([], 1->gettagstack().items) " Error cases call assert_equal({}, gettagstack(100)) call assert_equal(-1, settagstack(100, {'items' : []})) *** ../vim-8.1.1951/src/testdir/test_bufwintabinfo.vim 2019-08-24 22:58:08.307264136 +0200 --- src/testdir/test_bufwintabinfo.vim 2019-08-31 18:27:29.302094437 +0200 *************** *** 77,83 **** call assert_equal('green', winlist[2].variables.signal) call assert_equal(w4_id, winlist[3].winid) ! let winfo = getwininfo(w5_id)[0] call assert_equal(2, winfo.tabnr) call assert_equal([], getwininfo(3)) --- 77,83 ---- call assert_equal('green', winlist[2].variables.signal) call assert_equal(w4_id, winlist[3].winid) ! let winfo = w5_id->getwininfo()[0] call assert_equal(2, winfo.tabnr) call assert_equal([], getwininfo(3)) *** ../vim-8.1.1951/src/testdir/test_terminal.vim 2019-08-15 20:58:49.818081278 +0200 --- src/testdir/test_terminal.vim 2019-08-31 18:58:27.035182222 +0200 *************** *** 2066,2071 **** --- 2066,2074 ---- " In the GUI it can be more, let's assume a 20 x 14 cell. " And then add 100 / 200 tolerance. let [xroot, yroot] = getwinpos() + let winpos = 50->getwinpos() + call assert_equal(xroot, winpos[0]) + call assert_equal(yroot, winpos[1]) let [winrow, wincol] = win_screenpos('.') let xoff = wincol * (has('gui_running') ? 14 : 7) + 100 let yoff = winrow * (has('gui_running') ? 20 : 10) + 200 *** ../vim-8.1.1951/src/testdir/test_getvar.vim 2019-08-24 22:58:08.307264136 +0200 --- src/testdir/test_getvar.vim 2019-08-31 19:01:11.593792727 +0200 *************** *** 12,19 **** let def_str = "Chance" call assert_equal('Dance', getwinvar(1, 'var_str')) call assert_equal('Dance', getwinvar(1, 'var_str', def_str)) ! call assert_equal({'var_str': 'Dance'}, getwinvar(1, '')) ! call assert_equal({'var_str': 'Dance'}, getwinvar(1, '', def_str)) unlet w:var_str call assert_equal('Chance', getwinvar(1, 'var_str', def_str)) call assert_equal({}, getwinvar(1, '')) --- 12,19 ---- let def_str = "Chance" call assert_equal('Dance', getwinvar(1, 'var_str')) call assert_equal('Dance', getwinvar(1, 'var_str', def_str)) ! call assert_equal({'var_str': 'Dance'}, 1->getwinvar('')) ! call assert_equal({'var_str': 'Dance'}, 1->getwinvar('', def_str)) unlet w:var_str call assert_equal('Chance', getwinvar(1, 'var_str', def_str)) call assert_equal({}, getwinvar(1, '')) *** ../vim-8.1.1951/src/testdir/test_escaped_glob.vim 2019-04-10 22:15:15.817016767 +0200 --- src/testdir/test_escaped_glob.vim 2019-08-31 19:11:06.424772493 +0200 *************** *** 16,22 **** " Execute these commands in the sandbox, so that using the shell fails. " Setting 'shell' to an invalid name causes a memory leak. sandbox call assert_equal("", glob('Xxx\{')) ! sandbox call assert_equal("", glob('Xxx\$')) w! Xxx\{ w! Xxx\$ sandbox call assert_equal("Xxx{", glob('Xxx\{')) --- 16,22 ---- " Execute these commands in the sandbox, so that using the shell fails. " Setting 'shell' to an invalid name causes a memory leak. sandbox call assert_equal("", glob('Xxx\{')) ! sandbox call assert_equal("", 'Xxx\$'->glob()) w! Xxx\{ w! Xxx\$ sandbox call assert_equal("Xxx{", glob('Xxx\{')) *************** *** 29,33 **** sandbox call assert_equal("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim", \ globpath('sautest/autoload', 'glob*.vim')) sandbox call assert_equal(['sautest/autoload/globone.vim', 'sautest/autoload/globtwo.vim'], ! \ globpath('sautest/autoload', 'glob*.vim', 0, 1)) endfunction --- 29,33 ---- sandbox call assert_equal("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim", \ globpath('sautest/autoload', 'glob*.vim')) sandbox call assert_equal(['sautest/autoload/globone.vim', 'sautest/autoload/globtwo.vim'], ! \ 'glob*.vim'->globpath('sautest/autoload', 0, 1)) endfunction *** ../vim-8.1.1951/src/testdir/test_glob2regpat.vim 2018-07-23 04:49:17.225024903 +0200 --- src/testdir/test_glob2regpat.vim 2019-08-31 19:04:32.839961824 +0200 *************** *** 8,14 **** func Test_glob2regpat_valid() call assert_equal('^foo\.', glob2regpat('foo.*')) ! call assert_equal('^foo.$', glob2regpat('foo?')) call assert_equal('\.vim$', glob2regpat('*.vim')) call assert_equal('^[abc]$', glob2regpat('[abc]')) call assert_equal('^foo bar$', glob2regpat('foo\ bar')) --- 8,14 ---- func Test_glob2regpat_valid() call assert_equal('^foo\.', glob2regpat('foo.*')) ! call assert_equal('^foo.$', 'foo?'->glob2regpat()) call assert_equal('\.vim$', glob2regpat('*.vim')) call assert_equal('^[abc]$', glob2regpat('[abc]')) call assert_equal('^foo bar$', glob2regpat('foo\ bar')) *** ../vim-8.1.1951/src/version.c 2019-08-31 17:48:16.725154231 +0200 --- src/version.c 2019-08-31 19:11:35.944547043 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1952, /**/ -- hundred-and-one symptoms of being an internet addict: 151. You find yourself engaged to someone you've never actually met, except through e-mail. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///