Hi all,
On Tue, Jul 9, 2019 at 12:53 PM Bram Moolenaar <[email protected]> wrote:
>
> Yegappan wrote:
>
> > On Mon, Jul 1, 2019 at 1:38 PM Bram Moolenaar <[email protected]> wrote:
> > >
> > > >
> > > > I have created PR #4602 (https://github.com/vim/vim/pull/4602) for this.
> > > > I have simplified the sign_place(), sign_unplace() and sign_getplaced()
> > > > functions. Took some time to make these changes as the sign tests
> > > > heavily
> > > > use these functions. Note that this change is not backward compatible.
> > >
> > > The sign functions were added more than half a year ago. I don't think
> > > a change that is not backward compatible will be appreciated.
> > >
> > > I think for sign_define() we can support both the old arguments and a
> > > list argument. for sign_getplaced() we don't need changes. For
> > > place/unplace add a new "list" function:
> > >
> > > sign_define({name} [, {dict}])
> > > sign_define({list})
> > >
> > > sign_getplaced([{expr} [, {dict}]])
> > >
> > > sign_place({id}, {group}, {name}, {expr} [, {dict}])
> > > sign_placelist({list})
> > >
> > > sign_unplace({group} [, {dict}])
> > > sign_unplacelist({list})
> > >
> > > Does that sound reasonable?
> > >
> >
> > I have created PR #4636 that implements the above functions.
> >
> > https://github.com/vim/vim/pull/4636
>
> Thanks! It looks good. I'll wait a couple of days to give others a
> chance to comment.
>
I am including the documentation update from the PR below.
Let me know if you have any comments on the new functionality.
- Yegappan
--------------------------------------------------------------------------------------------------
sign_define({name} [, {dict}])
sign_define({list})
Define a new sign named {name} or modify the attributes of an
existing sign. This is similar to the |:sign-define| command.
Prefix {name} with a unique text to avoid name collisions.
There is no {group} like with placing signs.
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.
The one argument {list} can be used to define a list of signs.
Each list item is a dictionary with the above items in {dict}
and a 'name' item for the sign name.
Returns 0 on success and -1 on failure. When the one argument
{list} is used, then returns a List of values one for each
defined sign.
Examples:
call sign_define("mySign", {"text" : "=>", "texthl" :
\ "Error", "linehl" : "Search"})
call sign_define([{'name' : 'sign1', 'text' : '=>'},
\ {'name' : 'sign2', 'text' : '!!'}])
sign_undefine([{name}])
sign_undefine({list})
Deletes a previously defined sign {name}. This is similar to
the |:sign-undefine| command. If {name} is not supplied, then
deletes all the defined signs.
The one argument {list} can be used to undefine a list of
signs. Each list item is the name of a sign.
Returns 0 on success and -1 on failure. For the one argument
{list} call, returns a list of values one for each undefined
sign.
Examples:
" Delete a sign named mySign
call sign_undefine("mySign")
" Delete signs 'sign1' and 'sign2'
call sign_undefine(["sign1", "sign2"])
" Delete all the signs
call sign_undefine()
sign_placelist({list})
Place one or more signs. This is similar to the
|sign_place()| function. The {list} argument specifies the
List of signs to place. Each list item is a dict with the
following sign attributes:
buffer buffer name or number. For the
accepted values, see |bufname()|.
group sign group. {group} functions as a
namespace for {id}, thus two groups
can use the same IDs. If not specified
or set to an empty string, then the
global group is used. See
|sign-group| for more information.
id sign identifier. If not specified or
zero, then a new unique identifier is
allocated. Otherwise the specified
number is used. See |sign-identifier|
for more information.
lnum line number in the buffer {expr} where
the sign is to be placed. For the
accepted values, see |line()|.
name name of the sign to place. See
|sign_define()| for more information.
priority priority of the sign. When multiple
signs are placed on a line, the sign
with the highest priority is used. If
not specified, the default value of 10
is used. See |sign-priority| for more
information.
If {id} refers to an existing sign, then the existing sign is
modified to use the specified {name} and/or {priority}.
Returns a List of sign identifiers. If failed to place a
sign, the corresponding list item is set to -1.
Examples:
" Place sign s1 with id 5 at line 20 and id 10 at line
" 30 in buffer a.c
let [n1, n2] = sign_place([{'id' : 5, 'name' : 's1',
\ 'buffer' : 'a.c', 'lnum' : 20},
\ {'id' : 10, 'name' : 's1',
\ 'buffer' : 'a.c', 'lnum' : 30}])
" Place sign s1 in buffer a.c at line 40 and 50
" with auto-generated identifiers
let [n1, n2] = sign_place([{'name' : 's1',
\ 'buffer' : 'a.c', 'lnum' : 40},
\ {'name' : 's1', 'buffer' : 'a.c',
\ 'lnum' : 50}])
sign_unplacelist({list})
Remove previously placed signs from one or more buffers. This
is similar to the |sign_unplace()| function.
The {list} argument specifies the List of signs to remove.
Each list item is a dict with the following sign attributes:
buffer buffer name or number. For the accepted
values, see |bufname()|. If not specified,
then the specified sign is removed from all
the buffers.
group sign group name. If not specified or set to an
empty string, then the global sign group is
used. If set to '*', then all the groups
including the global group are used.
id sign identifier. If not specified, then all
the signs in the specified group are removed.
Returns a List where an entry is set to 0 if the corresponding
sign was successfully removed or -1 on failure.
Example: >
" Remove sign with id 10 from buffer a.vim and sign
" with id 20 from buffer b.vim
call sign_unplace([{'id' : 10, 'buffer' : "a.vim"},
\ {'id' : 20, 'buffer' : 'b.vim'}])
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/CAAW7x7kNB_PjO2oTOWnpEA8%2BCG7QdV-AyiZT%3DprFLeb3tp7yyA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.