To: vim_dev@googlegroups.com Subject: Patch 8.1.0697 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0697 Problem: ":sign place" requires the buffer argument. Solution: Make the argument optional. Also update the help and clean up the sign test. (Yegappan Lakshmanan, closes #3767) Files: runtime/doc/eval.txt, runtime/doc/sign.txt, src/sign.c, src/testdir/test_signs.vim *** ../vim-8.1.0696/runtime/doc/eval.txt 2019-01-01 19:47:17.854123944 +0100 --- runtime/doc/eval.txt 2019-01-06 16:19:00.281105655 +0100 *************** *** 7868,7880 **** The {name} can be a String or a Number. The optional {dict} argument specifies the sign attributes. The following values are supported: ! icon full path to the bitmap file for the sign. ! linehl highlight group used for the whole line the sign is placed in. ! text text that is displayed when there is no icon or the GUI is not being used. ! texthl highlight group used for the text item ! For an existing sign, the attributes are updated. Returns 0 on success and -1 on failure. --- 7894,7908 ---- The {name} can be a String or a Number. The optional {dict} argument specifies the sign attributes. The following values are supported: ! icon full path to the bitmap file for the sign. ! linehl highlight group used for the whole line the sign is placed in. ! text text that is displayed when there is no icon or the GUI is not being used. ! texthl highlight group used for the text item ! ! If the sign named {name} already exists, then the attributes ! of the sign are updated. Returns 0 on success and -1 on failure. *************** *** 7892,7904 **** Each list item in the returned value is a dictionary with the following entries: ! icon full path to the bitmap file of the sign ! linehl highlight group used for the whole line the sign is placed in. ! name name of the sign ! text text that is displayed when there is no icon or the GUI is not being used. ! texthl highlight group used for the text item Returns an empty List if there are no signs and when {name} is not found. --- 7920,7932 ---- Each list item in the returned value is a dictionary with the following entries: ! icon full path to the bitmap file of the sign ! linehl highlight group used for the whole line the sign is placed in. ! name name of the sign ! text text that is displayed when there is no icon or the GUI is not being used. ! texthl highlight group used for the text item Returns an empty List if there are no signs and when {name} is not found. *************** *** 7918,7932 **** list of signs placed in that buffer is returned. For the use of {expr}, see |bufname()|. The optional {dict} can contain the following entries: ! group select only signs in this group ! id select sign with this identifier ! lnum select signs placed in this line. For the use of {lnum}, see |line()|. If {group} is '*', then signs in all the groups including the global group are returned. If {group} is not supplied or is an empty string, then only signs in the global group are returned. If no arguments are supplied, then signs in the global group placed in all the buffers are returned. Each list item in the returned value is a dictionary with the following entries: --- 7946,7961 ---- list of signs placed in that buffer is returned. For the use of {expr}, see |bufname()|. The optional {dict} can contain the following entries: ! group select only signs in this group ! id select sign with this identifier ! lnum select signs placed in this line. For the use of {lnum}, see |line()|. If {group} is '*', then signs in all the groups including the global group are returned. If {group} is not supplied or is an empty string, then only signs in the global group are returned. If no arguments are supplied, then signs in the global group placed in all the buffers are returned. + See |sign-group|. Each list item in the returned value is a dictionary with the following entries: *************** *** 7942,7948 **** name name of the defined sign priority sign priority ! Returns an empty list on failure. Examples: > " Get a List of signs placed in eval.c in the --- 7971,7978 ---- name name of the defined sign priority sign priority ! Returns an empty list on failure or if there are no placed ! signs. Examples: > " Get a List of signs placed in eval.c in the *************** *** 7956,7966 **** echo sign_getplaced("eval.c", {'lnum' : 10}) " Get sign with identifier 10 placed in a.py ! echo sign_getplaced("a.py", {'id' : 10'}) " Get sign with id 20 in group 'g1' placed in a.py echo sign_getplaced("a.py", {'group' : 'g1', ! \ 'id' : 20'}) " Get a List of all the placed signs echo sign_getplaced() --- 7986,7996 ---- echo sign_getplaced("eval.c", {'lnum' : 10}) " Get sign with identifier 10 placed in a.py ! echo sign_getplaced("a.py", {'id' : 10}) " Get sign with id 20 in group 'g1' placed in a.py echo sign_getplaced("a.py", {'group' : 'g1', ! \ 'id' : 20}) " Get a List of all the placed signs echo sign_getplaced() *************** *** 7975,7982 **** allocated. Otherwise the specified number is used. {group} is the sign group name. To use the global sign group, use an empty string. {group} functions as a namespace for {id}, thus ! two groups can use the same IDs. ! {name} refers to a defined sign. {expr} refers to a buffer name or number. For the accepted values, see |bufname()|. --- 8005,8013 ---- allocated. Otherwise the specified number is used. {group} is the sign group name. To use the global sign group, use an empty string. {group} functions as a namespace for {id}, thus ! two groups can use the same IDs. Refer to |sign-identifier| ! for more information. ! {name} refers to a defined sign. {expr} refers to a buffer name or number. For the accepted values, see |bufname()|. *************** *** 8029,8035 **** < sign_unplace({group} [, {dict}]) *sign_unplace()* Remove a previously placed sign in one or more buffers. This ! is similar to the |:sign-unplace()| command. {group} is the sign group name. To use the global sign group, use an empty string. If {group} is set to '*', then all the --- 8060,8066 ---- < sign_unplace({group} [, {dict}]) *sign_unplace()* Remove a previously placed sign in one or more buffers. This ! is similar to the |:sign-unplace| command. {group} is the sign group name. To use the global sign group, use an empty string. If {group} is set to '*', then all the *** ../vim-8.1.0696/runtime/doc/sign.txt 2018-12-29 18:53:07.839607468 +0100 --- runtime/doc/sign.txt 2019-01-06 16:20:59.548314309 +0100 *************** *** 52,64 **** :highlight SignColumn guibg=darkgrey < *sign-group* ! Each sign can be assigned to either the global group or a named group. When ! placing a sign, if a group name is not supplied, or an empty string is used, ! then the sign is placed in the global group. Otherwise the sign is placed in ! the named group. The sign identifier is unique within a group. The sign group ! allows Vim plugins to use unique signs without interfering with other plugins ! using signs. *sign-priority* Each placed sign is assigned a priority value. When multiple signs are placed --- 52,74 ---- :highlight SignColumn guibg=darkgrey < + *sign-identifier* + Each placed sign is identified by a number called the sign identifier. This + identifier is used to jump to the sign or to remove the sign. The identifier + is assigned when placing the sign using the |sign-place| command or the + |sign_place()| function. Each sign identifier should be a unique number. If + multiple placed signs use the same identifier, then jumping to or removing a + sign becomes unpredictable. To avoid overlapping identifiers, sign groups can + be used. The |sign_place()| function can be called with a zero sign identifier + to allocate the next available identifier. + *sign-group* ! Each placed sign can be assigned to either the global group or a named group. ! When placing a sign, if a group name is not supplied, or an empty string is ! used, then the sign is placed in the global group. Otherwise the sign is ! placed in the named group. The sign identifier is unique within a group. The ! sign group allows Vim plugins to use unique signs without interfering with ! other plugins using signs. *sign-priority* Each placed sign is assigned a priority value. When multiple signs are placed *************** *** 88,94 **** :sign define {name} {argument}... Define a new sign or set attributes for an existing sign. The {name} can either be a number (all digits) or a name ! starting with a non-digit. Leading digits are ignored, thus "0012", "012" and "12" are considered the same name. About 120 different signs can be defined. --- 98,104 ---- :sign define {name} {argument}... Define a new sign or set attributes for an existing sign. The {name} can either be a number (all digits) or a name ! starting with a non-digit. Leading zeros are ignored, thus "0012", "012" and "12" are considered the same name. About 120 different signs can be defined. *************** *** 178,185 **** :sign place 9 group=g2 priority=50 line=5 \ name=sign1 file=a.py < ! :sign place {id} line={lnum} name={name} buffer={nr} ! Same, but use buffer {nr}. *E885* :sign place {id} name={name} file={fname} --- 188,196 ---- :sign place 9 group=g2 priority=50 line=5 \ name=sign1 file=a.py < ! :sign place {id} line={lnum} name={name} [buffer={nr}] ! Same, but use buffer {nr}. If the buffer argument is not ! given, place the sign in the current buffer. *E885* :sign place {id} name={name} file={fname} *************** *** 191,198 **** The optional "group={group}" attribute can be used before "file=" to select a sign in a particular group. ! :sign place {id} name={name} buffer={nr} ! Same, but use buffer {nr}. REMOVING SIGNS *:sign-unplace* *E159* --- 202,210 ---- The optional "group={group}" attribute can be used before "file=" to select a sign in a particular group. ! :sign place {id} name={name} [buffer={nr}] ! Same, but use buffer {nr}. If the buffer argument is not ! given, use the current buffer. REMOVING SIGNS *:sign-unplace* *E159* *************** *** 315,325 **** :sign jump {id} group={group} file={fname} Same but jump to the sign in group {group} ! :sign jump {id} buffer={nr} *E934* Same, but use buffer {nr}. This fails if buffer {nr} does not ! have a name. ! :sign jump {id} group={group} buffer={nr} Same but jump to the sign in group {group} --- 327,338 ---- :sign jump {id} group={group} file={fname} Same but jump to the sign in group {group} ! :sign jump {id} [buffer={nr}] *E934* Same, but use buffer {nr}. This fails if buffer {nr} does not ! have a name. If the buffer argument is not given, use the ! current buffer. ! :sign jump {id} group={group} [buffer={nr}] Same but jump to the sign in group {group} *** ../vim-8.1.0696/src/sign.c 2019-01-01 13:20:05.944711187 +0100 --- src/sign.c 2019-01-06 16:19:00.281105655 +0100 *************** *** 1168,1174 **** int id, char_u *group) { ! if (buf == NULL && sign_name == NULL && group == NULL && id == -1) { EMSG(_(e_argreq)); return; --- 1168,1174 ---- int id, char_u *group) { ! if (sign_name == NULL && group == NULL && id == -1) { EMSG(_(e_argreq)); return; *************** *** 1325,1330 **** --- 1325,1335 ---- return FAIL; } + // If the filename is not supplied for the sign place or the sign jump + // command, then use the current buffer. + if (filename == NULL && (cmd == SIGNCMD_PLACE || cmd == SIGNCMD_JUMP)) + *buf = curwin->w_buffer; + return OK; } *** ../vim-8.1.0696/src/testdir/test_signs.vim 2019-01-02 13:40:26.989339500 +0100 --- src/testdir/test_signs.vim 2019-01-06 16:19:00.281105655 +0100 *************** *** 14,20 **** " the icon name when listing signs. sign define Sign1 text=x try ! sign define Sign2 text=xy texthl=Title linehl=Error icon=../../pixmaps/stock_vim_find_help.png catch /E255:/ " Ignore error: E255: Couldn't read in sign data! " This error can happen when running in the GUI. --- 14,21 ---- " the icon name when listing signs. sign define Sign1 text=x try ! sign define Sign2 text=xy texthl=Title linehl=Error ! \ icon=../../pixmaps/stock_vim_find_help.png catch /E255:/ " Ignore error: E255: Couldn't read in sign data! " This error can happen when running in the GUI. *************** *** 23,29 **** " Test listing signs. let a=execute('sign list') ! call assert_match("^\nsign Sign1 text=x \nsign Sign2 icon=../../pixmaps/stock_vim_find_help.png .*text=xy linehl=Error texthl=Title$", a) let a=execute('sign list Sign1') call assert_equal("\nsign Sign1 text=x ", a) --- 24,32 ---- " Test listing signs. let a=execute('sign list') ! call assert_match('^\nsign Sign1 text=x \nsign Sign2 ' . ! \ 'icon=../../pixmaps/stock_vim_find_help.png .*text=xy ' . ! \ 'linehl=Error texthl=Title$', a) let a=execute('sign list Sign1') call assert_equal("\nsign Sign1 text=x ", a) *************** *** 63,69 **** " Check placed signs let a=execute('sign place') ! call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n line=3 id=41 name=Sign1 priority=10\n", a) " Unplace the sign and try jumping to it again should fail. sign unplace 41 --- 66,73 ---- " Check placed signs let a=execute('sign place') ! call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n" . ! \ " line=3 id=41 name=Sign1 priority=10\n", a) " Unplace the sign and try jumping to it again should fail. sign unplace 41 *************** *** 87,98 **** let a=execute('sign place') call assert_equal("\n--- Signs ---\n", a) " Check :jump with file=... edit foo call setline(1, ['A', 'B', 'C', 'D']) try ! sign define Sign3 text=y texthl=DoesNotExist linehl=DoesNotExist icon=doesnotexist.xpm catch /E255:/ " ignore error: E255: it can happens for guis. endtry --- 91,110 ---- let a=execute('sign place') call assert_equal("\n--- Signs ---\n", a) + " Place a sign without specifying the filename or buffer + sign place 77 line=9 name=Sign2 + let a=execute('sign place') + call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n" . + \ " line=9 id=77 name=Sign2 priority=10\n", a) + sign unplace * + " Check :jump with file=... edit foo call setline(1, ['A', 'B', 'C', 'D']) try ! sign define Sign3 text=y texthl=DoesNotExist linehl=DoesNotExist ! \ icon=doesnotexist.xpm catch /E255:/ " ignore error: E255: it can happens for guis. endtry *************** *** 148,185 **** call assert_equal("\nsign 4 text=#> linehl=Comment", a) exe 'sign place 20 line=3 name=004 buffer=' . bufnr('') let a = execute('sign place') ! call assert_equal("\n--- Signs ---\nSigns for foo:\n line=3 id=20 name=4 priority=10\n", a) exe 'sign unplace 20 buffer=' . bufnr('') sign undefine 004 call assert_fails('sign list 4', 'E155:') - " Error cases - call assert_fails("sign place abc line=3 name=Sign1 buffer=" . - \ bufnr('%'), 'E474:') - call assert_fails("sign unplace abc name=Sign1 buffer=" . - \ bufnr('%'), 'E474:') - call assert_fails("sign place 1abc line=3 name=Sign1 buffer=" . - \ bufnr('%'), 'E474:') - call assert_fails("sign unplace 2abc name=Sign1 buffer=" . - \ bufnr('%'), 'E474:') - call assert_fails("sign unplace 2 *", 'E474:') - call assert_fails("sign place 1 line=3 name=Sign1 buffer=" . - \ bufnr('%') . " a", 'E488:') - call assert_fails("sign place name=Sign1 buffer=" . bufnr('%'), 'E474:') - call assert_fails("sign place line=10 buffer=" . bufnr('%'), 'E474:') - call assert_fails("sign unplace 2 line=10 buffer=" . bufnr('%'), 'E474:') - call assert_fails("sign unplace 2 name=Sign1 buffer=" . bufnr('%'), 'E474:') - call assert_fails("sign place 2 line=3 buffer=" . bufnr('%'), 'E474:') - call assert_fails("sign place 2", 'E474:') - call assert_fails("sign place abc", 'E474:') - call assert_fails("sign place 5 line=3", 'E474:') - call assert_fails("sign place 5 name=Sign1", 'E474:') - call assert_fails("sign place 5 group=g1", 'E474:') - call assert_fails("sign place 5 group=*", 'E474:') - call assert_fails("sign place 5 priority=10", 'E474:') - call assert_fails("sign place 5 line=3 name=Sign1", 'E474:') - call assert_fails("sign place 5 group=g1 line=3 name=Sign1", 'E474:') - " After undefining the sign, we should no longer be able to place it. sign undefine Sign1 sign undefine Sign2 --- 160,171 ---- call assert_equal("\nsign 4 text=#> linehl=Comment", a) exe 'sign place 20 line=3 name=004 buffer=' . bufnr('') let a = execute('sign place') ! call assert_equal("\n--- Signs ---\nSigns for foo:\n" . ! \ " line=3 id=20 name=4 priority=10\n", a) exe 'sign unplace 20 buffer=' . bufnr('') sign undefine 004 call assert_fails('sign list 4', 'E155:') " After undefining the sign, we should no longer be able to place it. sign undefine Sign1 sign undefine Sign2 *************** *** 202,208 **** " Listing placed sign should show that sign is deleted. let a=execute('sign place') ! call assert_equal("\n--- Signs ---\nSigns for foobar:\n line=1 id=41 name=[Deleted] priority=10\n", a) sign unplace 41 let a=execute('sign place') --- 188,195 ---- " Listing placed sign should show that sign is deleted. let a=execute('sign place') ! call assert_equal("\n--- Signs ---\nSigns for foobar:\n" . ! \ " line=1 id=41 name=[Deleted] priority=10\n", a) sign unplace 41 let a=execute('sign place') *************** *** 220,226 **** call assert_equal('"sign define Sign icon= linehl= text= texthl=', @:) call feedkeys(":sign define Sign linehl=Spell\\\"\", 'tx') ! call assert_equal('"sign define Sign linehl=SpellBad SpellCap SpellLocal SpellRare', @:) call writefile(['foo'], 'XsignOne') call writefile(['bar'], 'XsignTwo') --- 207,214 ---- call assert_equal('"sign define Sign icon= linehl= text= texthl=', @:) call feedkeys(":sign define Sign linehl=Spell\\\"\", 'tx') ! call assert_equal('"sign define Sign linehl=SpellBad SpellCap ' . ! \ 'SpellLocal SpellRare', @:) call writefile(['foo'], 'XsignOne') call writefile(['bar'], 'XsignTwo') *************** *** 273,289 **** call assert_fails('sign jump 1 line=100', '474:') call assert_fails('sign define Sign2 text=', 'E239:') " Non-numeric identifier for :sign place ! call assert_fails("sign place abc line=3 name=Sign1 buffer=" . bufnr('%'), 'E474:') " Non-numeric identifier for :sign unplace ! call assert_fails("sign unplace abc name=Sign1 buffer=" . bufnr('%'), 'E474:') " Number followed by an alphabet as sign identifier for :sign place ! call assert_fails("sign place 1abc line=3 name=Sign1 buffer=" . bufnr('%'), 'E474:') " Number followed by an alphabet as sign identifier for :sign unplace ! call assert_fails("sign unplace 2abc name=Sign1 buffer=" . bufnr('%'), 'E474:') " Sign identifier and '*' for :sign unplace call assert_fails("sign unplace 2 *", 'E474:') " Trailing characters after buffer number for :sign place ! call assert_fails("sign place 1 line=3 name=Sign1 buffer=" . bufnr('%') . 'xxx', 'E488:') " Trailing characters after buffer number for :sign unplace call assert_fails("sign unplace 1 buffer=" . bufnr('%') . 'xxx', 'E488:') call assert_fails("sign unplace * buffer=" . bufnr('%') . 'xxx', 'E488:') --- 261,282 ---- call assert_fails('sign jump 1 line=100', '474:') call assert_fails('sign define Sign2 text=', 'E239:') " Non-numeric identifier for :sign place ! call assert_fails("sign place abc line=3 name=Sign1 buffer=" . bufnr(''), ! \ 'E474:') " Non-numeric identifier for :sign unplace ! call assert_fails("sign unplace abc name=Sign1 buffer=" . bufnr(''), ! \ 'E474:') " Number followed by an alphabet as sign identifier for :sign place ! call assert_fails("sign place 1abc line=3 name=Sign1 buffer=" . bufnr(''), ! \ 'E474:') " Number followed by an alphabet as sign identifier for :sign unplace ! call assert_fails("sign unplace 2abc name=Sign1 buffer=" . bufnr(''), ! \ 'E474:') " Sign identifier and '*' for :sign unplace call assert_fails("sign unplace 2 *", 'E474:') " Trailing characters after buffer number for :sign place ! call assert_fails("sign place 1 line=3 name=Sign1 buffer=" . ! \ bufnr('%') . 'xxx', 'E488:') " Trailing characters after buffer number for :sign unplace call assert_fails("sign unplace 1 buffer=" . bufnr('%') . 'xxx', 'E488:') call assert_fails("sign unplace * buffer=" . bufnr('%') . 'xxx', 'E488:') *************** *** 306,321 **** call assert_fails("sign place abc", 'E474:') " Placing a sign with only line number call assert_fails("sign place 5 line=3", 'E474:') - " Placing a sign with only sign name - call assert_fails("sign place 5 name=Sign1", 'E474:') " Placing a sign with only sign group call assert_fails("sign place 5 group=g1", 'E474:') call assert_fails("sign place 5 group=*", 'E474:') " Placing a sign with only sign priority call assert_fails("sign place 5 priority=10", 'E474:') - " Placing a sign without buffer number or file name - call assert_fails("sign place 5 line=3 name=Sign1", 'E474:') - call assert_fails("sign place 5 group=g1 line=3 name=Sign1", 'E474:') sign undefine Sign1 endfunc --- 299,309 ---- *************** *** 624,634 **** " :sign place file={fname} let a = execute('sign place file=Xsign') ! call assert_equal("\n--- Signs ---\nSigns for Xsign:\n line=10 id=5 name=sign1 priority=10\n", a) " :sign place group={group} file={fname} let a = execute('sign place group=g2 file=Xsign') ! call assert_equal("\n--- Signs ---\nSigns for Xsign:\n line=10 id=5 group=g2 name=sign1 priority=10\n", a) " :sign place group=* file={fname} let a = execute('sign place group=* file=Xsign') --- 612,624 ---- " :sign place file={fname} let a = execute('sign place file=Xsign') ! call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . ! \ " line=10 id=5 name=sign1 priority=10\n", a) " :sign place group={group} file={fname} let a = execute('sign place group=g2 file=Xsign') ! call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . ! \ " line=10 id=5 group=g2 name=sign1 priority=10\n", a) " :sign place group=* file={fname} let a = execute('sign place group=* file=Xsign') *************** *** 649,659 **** " :sign place buffer={fname} let a = execute('sign place buffer=' . bnum) ! call assert_equal("\n--- Signs ---\nSigns for Xsign:\n line=10 id=5 name=sign1 priority=10\n", a) " :sign place group={group} buffer={fname} let a = execute('sign place group=g2 buffer=' . bnum) ! call assert_equal("\n--- Signs ---\nSigns for Xsign:\n line=12 id=5 group=g2 name=sign1 priority=10\n", a) " :sign place group=* buffer={fname} let a = execute('sign place group=* buffer=' . bnum) --- 639,651 ---- " :sign place buffer={fname} let a = execute('sign place buffer=' . bnum) ! call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . ! \ " line=10 id=5 name=sign1 priority=10\n", a) " :sign place group={group} buffer={fname} let a = execute('sign place group=g2 buffer=' . bnum) ! call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" . ! \ " line=12 id=5 group=g2 name=sign1 priority=10\n", a) " :sign place group=* buffer={fname} let a = execute('sign place group=* buffer=' . bnum) *************** *** 690,695 **** --- 682,693 ---- sign jump 5 group=g2 file=Xsign call assert_equal(12, line('.')) + " Test for :sign jump command without the filename or buffer + sign jump 5 + call assert_equal(10, line('.')) + sign jump 5 group=g1 + call assert_equal(11, line('.')) + " Error cases call assert_fails("sign place 3 group= name=sign1 buffer=" . bnum, 'E474:') *** ../vim-8.1.0696/src/version.c 2019-01-06 15:29:52.540852980 +0100 --- src/version.c 2019-01-06 16:22:21.751771330 +0100 *************** *** 801,802 **** --- 801,804 ---- { /* Add new patch number below this line */ + /**/ + 697, /**/ -- hundred-and-one symptoms of being an internet addict: 114. You are counting items, you go "0,1,2,3,4,5,6,7,8,9,A,B,C,D...". /// 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 ///