Skip to content

Commit b328cca

Browse files
committed
patch 8.1.0697: ":sign place" requires the buffer argument
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)
1 parent 8ad16da commit b328cca

5 files changed

Lines changed: 106 additions & 74 deletions

File tree

runtime/doc/eval.txt

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.1. Last change: 2019 Jan 01
1+
*eval.txt* For Vim version 8.1. Last change: 2019 Jan 06
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -3945,20 +3945,24 @@ extend({expr1}, {expr2} [, {expr3}]) *extend()*
39453945
feedkeys({string} [, {mode}]) *feedkeys()*
39463946
Characters in {string} are queued for processing as if they
39473947
come from a mapping or were typed by the user.
3948+
39483949
By default the string is added to the end of the typeahead
39493950
buffer, thus if a mapping is still being executed the
39503951
characters come after them. Use the 'i' flag to insert before
39513952
other characters, they will be executed next, before any
39523953
characters from a mapping.
3954+
39533955
The function does not wait for processing of keys contained in
39543956
{string}.
3957+
39553958
To include special keys into {string}, use double-quotes
39563959
and "\..." notation |expr-quote|. For example,
39573960
feedkeys("\<CR>") simulates pressing of the <Enter> key. But
39583961
feedkeys('\<CR>') pushes 5 characters.
3959-
If {mode} is absent, keys are remapped.
3962+
39603963
{mode} is a String, which can contain these character flags:
3961-
'm' Remap keys. This is default.
3964+
'm' Remap keys. This is default. If {mode} is absent,
3965+
keys are remapped.
39623966
'n' Do not remap keys.
39633967
't' Handle keys as if typed; otherwise they are handled as
39643968
if coming from a mapping. This matters for undo,
@@ -3972,6 +3976,9 @@ feedkeys({string} [, {mode}]) *feedkeys()*
39723976
will behave as if <Esc> is typed, to avoid getting
39733977
stuck, waiting for a character to be typed before the
39743978
script continues.
3979+
Note that if you manage to call feedkeys() while
3980+
executing commands, thus calling it recursively, the
3981+
all typehead will be consumed by the last call.
39753982
'!' When used with 'x' will not end Insert mode. Can be
39763983
used in a test when a timer is set to exit Insert mode
39773984
a little later. Useful for testing CursorHoldI.
@@ -6700,8 +6707,9 @@ prop_add({lnum}, {col}, {props})
67006707
another line; can be zero
67016708
end_lnum line number for the end of text
67026709
end_col column just after the text; not used when "length"
6703-
is present; when {col} and "end_col" are equal
6704-
this is a zero-width text property
6710+
is present; when {col} and "end_col" are
6711+
equal, and "end_lnum" is omitted or equal to
6712+
{lnum}, this is a zero-width text property
67056713
bufnr buffer to add the property to; when omitted
67066714
the current buffer is used
67076715
id user defined ID for the property; when omitted
@@ -7454,7 +7462,8 @@ serverlist() *serverlist()*
74547462
<
74557463
setbufline({expr}, {lnum}, {text}) *setbufline()*
74567464
Set line {lnum} to {text} in buffer {expr}. To insert
7457-
lines use |append()|.
7465+
lines use |append()|. Any text properties in {lnum} are
7466+
cleared.
74587467

74597468
For the use of {expr}, see |bufname()| above.
74607469

@@ -7534,7 +7543,7 @@ setfperm({fname}, {mode}) *setfperm()* *chmod*
75347543
setline({lnum}, {text}) *setline()*
75357544
Set line {lnum} of the current buffer to {text}. To insert
75367545
lines use |append()|. To set lines in another buffer use
7537-
|setbufline()|.
7546+
|setbufline()|. Any text properties in {lnum} are cleared.
75387547

75397548
{lnum} is used like with |getline()|.
75407549
When {lnum} is just below the last line the {text} will be
@@ -7891,7 +7900,9 @@ sign_define({name} [, {dict}]) *sign_define()*
78917900
text text that is displayed when there is no icon
78927901
or the GUI is not being used.
78937902
texthl highlight group used for the text item
7894-
For an existing sign, the attributes are updated.
7903+
7904+
If the sign named {name} already exists, then the attributes
7905+
of the sign are updated.
78957906

78967907
Returns 0 on success and -1 on failure.
78977908

@@ -7944,6 +7955,7 @@ sign_getplaced([{expr} [, {dict}]]) *sign_getplaced()*
79447955
empty string, then only signs in the global group are
79457956
returned. If no arguments are supplied, then signs in the
79467957
global group placed in all the buffers are returned.
7958+
See |sign-group|.
79477959

79487960
Each list item in the returned value is a dictionary with the
79497961
following entries:
@@ -7959,7 +7971,8 @@ sign_getplaced([{expr} [, {dict}]]) *sign_getplaced()*
79597971
name name of the defined sign
79607972
priority sign priority
79617973

7962-
Returns an empty list on failure.
7974+
Returns an empty list on failure or if there are no placed
7975+
signs.
79637976

79647977
Examples: >
79657978
" Get a List of signs placed in eval.c in the
@@ -7992,7 +8005,8 @@ sign_place({id}, {group}, {name}, {expr} [, {dict}])
79928005
allocated. Otherwise the specified number is used. {group} is
79938006
the sign group name. To use the global sign group, use an
79948007
empty string. {group} functions as a namespace for {id}, thus
7995-
two groups can use the same IDs.
8008+
two groups can use the same IDs. Refer to |sign-identifier|
8009+
for more information.
79968010

79978011
{name} refers to a defined sign.
79988012
{expr} refers to a buffer name or number. For the accepted
@@ -9496,7 +9510,7 @@ undofile({name}) *undofile()*
94969510
If {name} is empty undofile() returns an empty string, since a
94979511
buffer without a file name will not write an undo file.
94989512
Useful in combination with |:wundo| and |:rundo|.
9499-
When compiled without the +persistent_undo option this always
9513+
When compiled without the |+persistent_undo| option this always
95009514
returns an empty string.
95019515

95029516
undotree() *undotree()*

runtime/doc/sign.txt

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*sign.txt* For Vim version 8.1. Last change: 2019 Jan 01
1+
*sign.txt* For Vim version 8.1. Last change: 2019 Jan 06
22

33

44
VIM REFERENCE MANUAL by Gordon Prieur
@@ -52,13 +52,23 @@ Example to set the color: >
5252
5353
:highlight SignColumn guibg=darkgrey
5454
<
55+
*sign-identifier*
56+
Each placed sign is identified by a number called the sign identifier. This
57+
identifier is used to jump to the sign or to remove the sign. The identifier
58+
is assigned when placing the sign using the |sign-place| command or the
59+
|sign_place()| function. Each sign identifier should be a unique number. If
60+
multiple placed signs use the same identifier, then jumping to or removing a
61+
sign becomes unpredictable. To avoid overlapping identifiers, sign groups can
62+
be used. The |sign_place()| function can be called with a zero sign identifier
63+
to allocate the next available identifier.
64+
5565
*sign-group*
56-
Each sign can be assigned to either the global group or a named group. When
57-
placing a sign, if a group name is not supplied, or an empty string is used,
58-
then the sign is placed in the global group. Otherwise the sign is placed in
59-
the named group. The sign identifier is unique within a group. The sign group
60-
allows Vim plugins to use unique signs without interfering with other plugins
61-
using signs.
66+
Each placed sign can be assigned to either the global group or a named group.
67+
When placing a sign, if a group name is not supplied, or an empty string is
68+
used, then the sign is placed in the global group. Otherwise the sign is
69+
placed in the named group. The sign identifier is unique within a group. The
70+
sign group allows Vim plugins to use unique signs without interfering with
71+
other plugins using signs.
6272

6373
*sign-priority*
6474
Each placed sign is assigned a priority value. When multiple signs are placed
@@ -178,8 +188,9 @@ See |sign_place()| for the equivalent Vim script function.
178188
:sign place 9 group=g2 priority=50 line=5
179189
\ name=sign1 file=a.py
180190
<
181-
:sign place {id} line={lnum} name={name} buffer={nr}
182-
Same, but use buffer {nr}.
191+
:sign place {id} line={lnum} name={name} [buffer={nr}]
192+
Same, but use buffer {nr}. If the buffer argument is not
193+
given, place the sign in the current buffer.
183194

184195
*E885*
185196
:sign place {id} name={name} file={fname}
@@ -191,8 +202,9 @@ See |sign_place()| for the equivalent Vim script function.
191202
The optional "group={group}" attribute can be used before
192203
"file=" to select a sign in a particular group.
193204

194-
:sign place {id} name={name} buffer={nr}
195-
Same, but use buffer {nr}.
205+
:sign place {id} name={name} [buffer={nr}]
206+
Same, but use buffer {nr}. If the buffer argument is not
207+
given, use the current buffer.
196208

197209

198210
REMOVING SIGNS *:sign-unplace* *E159*
@@ -315,11 +327,12 @@ JUMPING TO A SIGN *:sign-jump* *E157*
315327
:sign jump {id} group={group} file={fname}
316328
Same but jump to the sign in group {group}
317329

318-
:sign jump {id} buffer={nr} *E934*
330+
:sign jump {id} [buffer={nr}] *E934*
319331
Same, but use buffer {nr}. This fails if buffer {nr} does not
320-
have a name.
332+
have a name. If the buffer argument is not given, use the
333+
current buffer.
321334

322-
:sign jump {id} group={group} buffer={nr}
335+
:sign jump {id} group={group} [buffer={nr}]
323336
Same but jump to the sign in group {group}
324337

325338

src/sign.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ sign_jump_cmd(
11681168
int id,
11691169
char_u *group)
11701170
{
1171-
if (buf == NULL && sign_name == NULL && group == NULL && id == -1)
1171+
if (sign_name == NULL && group == NULL && id == -1)
11721172
{
11731173
EMSG(_(e_argreq));
11741174
return;
@@ -1325,6 +1325,11 @@ parse_sign_cmd_args(
13251325
return FAIL;
13261326
}
13271327

1328+
// If the filename is not supplied for the sign place or the sign jump
1329+
// command, then use the current buffer.
1330+
if (filename == NULL && (cmd == SIGNCMD_PLACE || cmd == SIGNCMD_JUMP))
1331+
*buf = curwin->w_buffer;
1332+
13281333
return OK;
13291334
}
13301335

0 commit comments

Comments
 (0)