To: vim_dev@googlegroups.com Subject: Patch 8.1.1995 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1995 Problem: More functions can be used as methods. Solution: Make sign functions usable as a method. Files: runtime/doc/sign.txt, src/evalfunc.c, src/testdir/test_signs.vim *** ../vim-8.1.1994/runtime/doc/sign.txt 2019-07-21 16:39:56.200095876 +0200 --- runtime/doc/sign.txt 2019-09-06 21:56:04.538586349 +0200 *************** *** 389,394 **** --- 389,397 ---- \ 'text' : '!!'} \ ]) < + Can also be used as a |method|: > + GetSignList()->sign_define() + sign_getdefined([{name}]) *sign_getdefined()* Get a list of defined signs and their attributes. This is similar to the |:sign-list| command. *************** *** 417,422 **** --- 420,428 ---- " Get the attribute of the sign named mySign echo sign_getdefined("mySign") < + Can also be used as a |method|: > + GetSignList()->sign_getdefined() + sign_getplaced([{expr} [, {dict}]]) *sign_getplaced()* Return a list of signs placed in a buffer or all the buffers. This is similar to the |:sign-place-list| command. *************** *** 477,482 **** --- 483,491 ---- " Get a List of all the placed signs echo sign_getplaced() < + Can also be used as a |method|: > + GetBufname()->sign_getplaced() + < *sign_jump()* sign_jump({id}, {group}, {expr}) Open the buffer {expr} or jump to the window that contains *************** *** 492,498 **** " Jump to sign 10 in the current buffer call sign_jump(10, '', '') < ! *sign_place()* sign_place({id}, {group}, {name}, {expr} [, {dict}]) Place the sign defined as {name} at line {lnum} in file or --- 501,509 ---- " Jump to sign 10 in the current buffer call sign_jump(10, '', '') < ! Can also be used as a |method|: > ! GetSignid()->sign_jump() ! < *sign_place()* sign_place({id}, {group}, {name}, {expr} [, {dict}]) Place the sign defined as {name} at line {lnum} in file or *************** *** 542,548 **** call sign_place(10, 'g3', 'sign4', 'json.c', \ {'lnum' : 40, 'priority' : 90}) < ! *sign_placelist()* sign_placelist({list}) Place one or more signs. This is similar to the --- 553,561 ---- call sign_place(10, 'g3', 'sign4', 'json.c', \ {'lnum' : 40, 'priority' : 90}) < ! Can also be used as a |method|: > ! GetSignid()->sign_place(group, name, expr) ! < *sign_placelist()* sign_placelist({list}) Place one or more signs. This is similar to the *************** *** 602,607 **** --- 615,622 ---- \ 'lnum' : 50} \ ]) < + Can also be used as a |method|: > + GetSignlist()->sign_placelist() sign_undefine([{name}]) *sign_undefine()* sign_undefine({list}) *************** *** 626,631 **** --- 641,648 ---- " Delete all the signs call sign_undefine() < + Can also be used as a |method|: > + GetSignlist()->sign_undefine() sign_unplace({group} [, {dict}]) *sign_unplace()* Remove a previously placed sign in one or more buffers. This *************** *** 668,673 **** --- 685,693 ---- " Remove all the placed signs from all the buffers call sign_unplace('*') + + < Can also be used as a |method|: > + GetSigngroup()->sign_unplace() < sign_unplacelist({list}) *sign_unplacelist()* Remove previously placed signs from one or more buffers. This *************** *** 697,701 **** --- 717,724 ---- \ {'id' : 20, 'buffer' : 'b.vim'}, \ ]) < + Can also be used as a |method|: > + GetSignlist()->sign_unplacelist() + < vim:tw=78:ts=8:noet:ft=help:norl: *** ../vim-8.1.1994/src/evalfunc.c 2019-09-06 21:34:25.358847422 +0200 --- src/evalfunc.c 2019-09-06 21:55:24.586695973 +0200 *************** *** 736,750 **** {"shellescape", 1, 2, 0, f_shellescape}, {"shiftwidth", 0, 1, 0, f_shiftwidth}, #ifdef FEAT_SIGNS ! {"sign_define", 1, 2, 0, f_sign_define}, ! {"sign_getdefined", 0, 1, 0, f_sign_getdefined}, ! {"sign_getplaced", 0, 2, 0, f_sign_getplaced}, ! {"sign_jump", 3, 3, 0, f_sign_jump}, ! {"sign_place", 4, 5, 0, f_sign_place}, ! {"sign_placelist", 1, 1, 0, f_sign_placelist}, ! {"sign_undefine", 0, 1, 0, f_sign_undefine}, ! {"sign_unplace", 1, 2, 0, f_sign_unplace}, ! {"sign_unplacelist", 1, 2, 0, f_sign_unplacelist}, #endif {"simplify", 1, 1, 0, f_simplify}, #ifdef FEAT_FLOAT --- 736,750 ---- {"shellescape", 1, 2, 0, f_shellescape}, {"shiftwidth", 0, 1, 0, f_shiftwidth}, #ifdef FEAT_SIGNS ! {"sign_define", 1, 2, FEARG_1, f_sign_define}, ! {"sign_getdefined", 0, 1, FEARG_1, f_sign_getdefined}, ! {"sign_getplaced", 0, 2, FEARG_1, f_sign_getplaced}, ! {"sign_jump", 3, 3, FEARG_1, f_sign_jump}, ! {"sign_place", 4, 5, FEARG_1, f_sign_place}, ! {"sign_placelist", 1, 1, FEARG_1, f_sign_placelist}, ! {"sign_undefine", 0, 1, FEARG_1, f_sign_undefine}, ! {"sign_unplace", 1, 2, FEARG_1, f_sign_unplace}, ! {"sign_unplacelist", 1, 2, FEARG_1, f_sign_unplacelist}, #endif {"simplify", 1, 1, 0, f_simplify}, #ifdef FEAT_FLOAT *** ../vim-8.1.1994/src/testdir/test_signs.vim 2019-08-21 13:45:12.728075572 +0200 --- src/testdir/test_signs.vim 2019-09-06 22:00:14.329856331 +0200 *************** *** 393,399 **** " Tests for sign_define() let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'} ! call assert_equal(0, sign_define("sign1", attr)) call assert_equal([{'name' : 'sign1', 'texthl' : 'Error', \ 'linehl' : 'Search', 'text' : '=>'}], sign_getdefined()) --- 393,399 ---- " Tests for sign_define() let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'} ! call assert_equal(0, "sign1"->sign_define(attr)) call assert_equal([{'name' : 'sign1', 'texthl' : 'Error', \ 'linehl' : 'Search', 'text' : '=>'}], sign_getdefined()) *************** *** 404,416 **** call Sign_define_ignore_error("sign2", attr) call assert_equal([{'name' : 'sign2', 'texthl' : 'DiffChange', \ 'linehl' : 'DiffAdd', 'text' : '!!', 'icon' : 'sign2.ico'}], ! \ sign_getdefined("sign2")) " Test for a sign name with digits call assert_equal(0, sign_define(0002, {'linehl' : 'StatusLine'})) call assert_equal([{'name' : '2', 'linehl' : 'StatusLine'}], \ sign_getdefined(0002)) ! call sign_undefine(0002) " Tests for invalid arguments to sign_define() call assert_fails('call sign_define("sign4", {"text" : "===>"})', 'E239:') --- 404,416 ---- call Sign_define_ignore_error("sign2", attr) call assert_equal([{'name' : 'sign2', 'texthl' : 'DiffChange', \ 'linehl' : 'DiffAdd', 'text' : '!!', 'icon' : 'sign2.ico'}], ! \ "sign2"->sign_getdefined()) " Test for a sign name with digits call assert_equal(0, sign_define(0002, {'linehl' : 'StatusLine'})) call assert_equal([{'name' : '2', 'linehl' : 'StatusLine'}], \ sign_getdefined(0002)) ! eval 0002->sign_undefine() " Tests for invalid arguments to sign_define() call assert_fails('call sign_define("sign4", {"text" : "===>"})', 'E239:') *************** *** 434,440 **** call assert_equal([{'bufnr' : bufnr(''), 'signs' : \ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1', \ 'priority' : 10}]}], ! \ sign_getplaced('%', {'lnum' : 20})) call assert_equal([{'bufnr' : bufnr(''), 'signs' : \ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1', \ 'priority' : 10}]}], --- 434,440 ---- call assert_equal([{'bufnr' : bufnr(''), 'signs' : \ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1', \ 'priority' : 10}]}], ! \ '%'->sign_getplaced({'lnum' : 20})) call assert_equal([{'bufnr' : bufnr(''), 'signs' : \ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1', \ 'priority' : 10}]}], *************** *** 490,499 **** \ 'E745:') " Tests for sign_unplace() ! call sign_place(20, '', 'sign2', 'Xsign', {"lnum" : 30}) call assert_equal(0, sign_unplace('', \ {'id' : 20, 'buffer' : 'Xsign'})) ! call assert_equal(-1, sign_unplace('', \ {'id' : 30, 'buffer' : 'Xsign'})) call sign_place(20, '', 'sign2', 'Xsign', {"lnum" : 30}) call assert_fails("call sign_unplace('', --- 490,499 ---- \ 'E745:') " Tests for sign_unplace() ! eval 20->sign_place('', 'sign2', 'Xsign', {"lnum" : 30}) call assert_equal(0, sign_unplace('', \ {'id' : 20, 'buffer' : 'Xsign'})) ! call assert_equal(-1, ''->sign_unplace( \ {'id' : 30, 'buffer' : 'Xsign'})) call sign_place(20, '', 'sign2', 'Xsign', {"lnum" : 30}) call assert_fails("call sign_unplace('', *************** *** 1711,1717 **** let r = sign_jump(5, '', 'foo') call assert_equal(2, r) call assert_equal(2, line('.')) ! let r = sign_jump(6, 'g1', 'foo') call assert_equal(5, r) call assert_equal(5, line('.')) let r = sign_jump(5, '', 'bar') --- 1711,1717 ---- let r = sign_jump(5, '', 'foo') call assert_equal(2, r) call assert_equal(2, line('.')) ! let r = 6->sign_jump('g1', 'foo') call assert_equal(5, r) call assert_equal(5, line('.')) let r = sign_jump(5, '', 'bar') *************** *** 1935,1942 **** \ 'group' : 'g1', 'priority' : 10}], s[0].signs) " Change an existing sign without specifying the group ! call assert_equal([5], sign_placelist([ ! \ {'id' : 5, 'name' : 'sign1', 'buffer' : 'Xsign'}])) let s = sign_getplaced('Xsign', {'id' : 5, 'group' : ''}) call assert_equal([{'id' : 5, 'name' : 'sign1', 'lnum' : 11, \ 'group' : '', 'priority' : 10}], s[0].signs) --- 1935,1941 ---- \ 'group' : 'g1', 'priority' : 10}], s[0].signs) " Change an existing sign without specifying the group ! call assert_equal([5], [{'id' : 5, 'name' : 'sign1', 'buffer' : 'Xsign'}]->sign_placelist()) let s = sign_getplaced('Xsign', {'id' : 5, 'group' : ''}) call assert_equal([{'id' : 5, 'name' : 'sign1', 'lnum' : 11, \ 'group' : '', 'priority' : 10}], s[0].signs) *************** *** 1969,1975 **** \ {'id' : 1, 'group' : 'g1'}, {'id' : 1, 'group' : 'g2'}])) " Invalid arguments ! call assert_equal([], sign_unplacelist([])) call assert_fails('call sign_unplacelist({})', "E714:") call assert_fails('call sign_unplacelist([[]])', "E715:") call assert_fails('call sign_unplacelist(["abc"])', "E715:") --- 1968,1974 ---- \ {'id' : 1, 'group' : 'g1'}, {'id' : 1, 'group' : 'g2'}])) " Invalid arguments ! call assert_equal([], []->sign_unplacelist()) call assert_fails('call sign_unplacelist({})', "E714:") call assert_fails('call sign_unplacelist([[]])', "E715:") call assert_fails('call sign_unplacelist(["abc"])', "E715:") *** ../vim-8.1.1994/src/version.c 2019-09-06 21:46:12.352612027 +0200 --- src/version.c 2019-09-06 21:50:46.507669475 +0200 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 1995, /**/ -- panic("Foooooooood fight!"); -- In the kernel source aha1542.c, after detecting a bad segment list /// 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 ///