[vim/vim] doc: signs: clarifications for priority / order (#4482)

39 views
Skip to first unread message

Daniel Hahler

unread,
Jun 3, 2019, 1:12:49 PM6/3/19
to vim/vim, Subscribed

https://github.com/vim/vim/blob/98fb65cb051f625f4ce291a9f9cdb2e54ac1e688/runtime/doc/sign.txt#L185-L187:

The priority is used to determine the
highlight group used when multiple signs are placed on the
same line.

I assume it is not just used for the highlight group, but for the sign being displayed altogether?
At least that's how I would expect it, and a quick test shows that this is the case, using:

sign define mysign1 text=s1 texthl=Error
sign define mysign2 text=s2 texthl=Todo

exe 'sign unplace * buffer='.bufnr('%')
sign place 1 line=1 name=mysign1 priority=10
sign place 2 line=1 name=mysign2 priority=20
sign place 3 line=1 name=mysign1 priority=10

echo map(sign_getplaced(bufnr('%'))[0].signs, 'v:val.name')

It displays ['mysign2', 'mysign1', 'mysign1'], and the sign text is "s2" (with its highlight).

It should also be clarified with sign_getplaced() which currently only says:

The returned signs in a buffer are ordered by their line
number.

From my observation it returns signs as being displayed (first entry is the visible one).

Something to consider here is also signs with the same ID - from my observation the last placed one is visible, regardless of priority (i.e. if placing id=1 with priority=50, and then with priority=10, it will display the 2nd one).

sign-priority appears to be clear(er) about it already.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Yegappan Lakshmanan

unread,
Jun 3, 2019, 3:22:45 PM6/3/19
to vim_dev, reply+ACY5DGECINRSEXPD6U...@reply.github.com, vim/vim, Subscribed
Hi,

On Mon, Jun 3, 2019 at 10:12 AM Daniel Hahler <vim-dev...@256bit.org> wrote:
>
> https://github.com/vim/vim/blob/98fb65cb051f625f4ce291a9f9cdb2e54ac1e688/runtime/doc/sign.txt#L185-L187:
>
> The priority is used to determine the
> highlight group used when multiple signs are placed on the
> same line.
>
> I assume it is not just used for the highlight group, but for the sign being displayed altogether?
>

Yes. The sign priority is used to determine the sign that will be
displayed in a line.

>
> At least that's how I would expect it, and a quick test shows that this is the case, using:
>
> sign define mysign1 text=s1 texthl=Error
> sign define mysign2 text=s2 texthl=Todo
>
> exe 'sign unplace * buffer='.bufnr('%')
> sign place 1 line=1 name=mysign1 priority=10
> sign place 2 line=1 name=mysign2 priority=20
> sign place 3 line=1 name=mysign1 priority=10
>
> echo map(sign_getplaced(bufnr('%'))[0].signs, 'v:val.name')
>
> It displays ['mysign2', 'mysign1', 'mysign1'], and the sign text is "s2" (with its highlight).
>
> It should also be clarified with sign_getplaced() which currently only says:
>
> The returned signs in a buffer are ordered by their line
> number.
>
> From my observation it returns signs as being displayed (first entry is the visible one).
>

Yes. The sign_getplaced() function returns all the signs placed in a buffer.
If multiple signs are placed on a line, then the signs are sorted by
their priority.
If two or more signs have the same priority, then they are sorted by their order
of placement (the last placed sign takes precedence over the older ones).

- Yegappan

vim-dev ML

unread,
Jun 3, 2019, 3:23:12 PM6/3/19
to vim/vim, vim-dev ML, Your activity
Hi,

On Mon, Jun 3, 2019 at 10:12 AM Daniel Hahler <vim-dev...@256bit.org> wrote:
>
> https://github.com/vim/vim/blob/98fb65cb051f625f4ce291a9f9cdb2e54ac1e688/runtime/doc/sign.txt#L185-L187:
>
> The priority is used to determine the
> highlight group used when multiple signs are placed on the
> same line.
>
> I assume it is not just used for the highlight group, but for the sign being displayed altogether?
>

Yes. The sign priority is used to determine the sign that will be
displayed in a line.

>
> At least that's how I would expect it, and a quick test shows that this is the case, using:
>
> sign define mysign1 text=s1 texthl=Error
> sign define mysign2 text=s2 texthl=Todo
>
> exe 'sign unplace * buffer='.bufnr('%')
> sign place 1 line=1 name=mysign1 priority=10
> sign place 2 line=1 name=mysign2 priority=20
> sign place 3 line=1 name=mysign1 priority=10
>
> echo map(sign_getplaced(bufnr('%'))[0].signs, 'v:val.name')
>
> It displays ['mysign2', 'mysign1', 'mysign1'], and the sign text is "s2" (with its highlight).
>
> It should also be clarified with sign_getplaced() which currently only says:
>
> The returned signs in a buffer are ordered by their line
> number.
>
> From my observation it returns signs as being displayed (first entry is the visible one).
>

Yes. The sign_getplaced() function returns all the signs placed in a buffer.
If multiple signs are placed on a line, then the signs are sorted by
their priority.
If two or more signs have the same priority, then they are sorted by their order
of placement (the last placed sign takes precedence over the older ones).

- Yegappan

>

Yegappan Lakshmanan

unread,
Jun 4, 2019, 11:19:52 AM6/4/19
to vim_dev, reply+ACY5DGECINRSEXPD6U...@reply.github.com, vim/vim, Subscribed
Hi,

On Mon, Jun 3, 2019 at 10:12 AM Daniel Hahler <vim-dev...@256bit.org> wrote:
>
> https://github.com/vim/vim/blob/98fb65cb051f625f4ce291a9f9cdb2e54ac1e688/runtime/doc/sign.txt#L185-L187:
>
> The priority is used to determine the highlight group used when
> multiple signs are placed on the same line.
>
> I assume it is not just used for the highlight group, but for the sign
> being displayed altogether? At least that's how I would expect it,
> and a quick test shows that this is the case, using:
>
> sign define mysign1 text=s1 texthl=Error sign define mysign2 text=s2
> texthl=Todo
>
> exe 'sign unplace * buffer='.bufnr('%') sign place 1 line=1
> name=mysign1 priority=10 sign place 2 line=1 name=mysign2 priority=20
> sign place 3 line=1 name=mysign1 priority=10
>
> echo map(sign_getplaced(bufnr('%'))[0].signs, 'v:val.name')
>
> It displays ['mysign2', 'mysign1', 'mysign1'], and the sign text is
> "s2" (with its highlight).
>
> It should also be clarified with sign_getplaced() which currently only
> says:
>
> The returned signs in a buffer are ordered by their line number.
>
> From my observation it returns signs as being displayed (first entry
> is the visible one).
>
> Something to consider here is also signs with the same ID - from my
> observation the last placed one is visible, regardless of priority
> (i.e. if placing id=1 with priority=50, and then with priority=10, it
> will display the 2nd one).
>

In this case the second placed sign updates the first sign on the line.
You can use only one sign with a given id on a line. The id can be
reused across different sign groups.

- Yegappan

vim-dev ML

unread,
Jun 4, 2019, 11:20:24 AM6/4/19
to vim/vim, vim-dev ML, Your activity
Hi,

On Mon, Jun 3, 2019 at 10:12 AM Daniel Hahler <vim-dev...@256bit.org> wrote:
>
> https://github.com/vim/vim/blob/98fb65cb051f625f4ce291a9f9cdb2e54ac1e688/runtime/doc/sign.txt#L185-L187:
>
> The priority is used to determine the highlight group used when
> multiple signs are placed on the same line.
>
> I assume it is not just used for the highlight group, but for the sign
> being displayed altogether? At least that's how I would expect it,
> and a quick test shows that this is the case, using:
>
> sign define mysign1 text=s1 texthl=Error sign define mysign2 text=s2
> texthl=Todo
>
> exe 'sign unplace * buffer='.bufnr('%') sign place 1 line=1
> name=mysign1 priority=10 sign place 2 line=1 name=mysign2 priority=20
> sign place 3 line=1 name=mysign1 priority=10
>
> echo map(sign_getplaced(bufnr('%'))[0].signs, 'v:val.name')
>
> It displays ['mysign2', 'mysign1', 'mysign1'], and the sign text is
> "s2" (with its highlight).
>
> It should also be clarified with sign_getplaced() which currently only
> says:
>
> The returned signs in a buffer are ordered by their line number.
>
> From my observation it returns signs as being displayed (first entry
> is the visible one).
>
> Something to consider here is also signs with the same ID - from my
> observation the last placed one is visible, regardless of priority
> (i.e. if placing id=1 with priority=50, and then with priority=10, it
> will display the 2nd one).
>

In this case the second placed sign updates the first sign on the line.
You can use only one sign with a given id on a line. The id can be
reused across different sign groups.

- Yegappan

Yegappan Lakshmanan

unread,
Jun 4, 2019, 11:21:54 AM6/4/19
to vim_dev, reply+ACY5DGECINRSEXPD6U...@reply.github.com, vim/vim, Subscribed
Hi,

On Mon, Jun 3, 2019 at 10:12 AM Daniel Hahler <vim-dev...@256bit.org> wrote:
>
> https://github.com/vim/vim/blob/98fb65cb051f625f4ce291a9f9cdb2e54ac1e688/runtime/doc/sign.txt#L185-L187:
>
> The priority is used to determine the
> highlight group used when multiple signs are placed on the
> same line.
>
> I assume it is not just used for the highlight group, but for the sign being displayed altogether?
>

I am attaching an update to the help text that clarifies this. I have
also added a test
for updating the priority of an already placed sign.

- Yegappan
sign.diff

vim-dev ML

unread,
Jun 4, 2019, 11:22:25 AM6/4/19
to vim/vim, vim-dev ML, Your activity
Hi,

On Mon, Jun 3, 2019 at 10:12 AM Daniel Hahler <vim-dev...@256bit.org> wrote:
>
> https://github.com/vim/vim/blob/98fb65cb051f625f4ce291a9f9cdb2e54ac1e688/runtime/doc/sign.txt#L185-L187:
>
> The priority is used to determine the
> highlight group used when multiple signs are placed on the
> same line.
>
> I assume it is not just used for the highlight group, but for the sign being displayed altogether?
>

I am attaching an update to the help text that clarifies this. I have
also added a test
for updating the priority of an already placed sign.

- Yegappan

Bram Moolenaar

unread,
Jun 4, 2019, 4:48:40 PM6/4/19
to vim...@googlegroups.com, Yegappan Lakshmanan, reply+ACY5DGECINRSEXPD6U...@reply.github.com

Yegappan wrote:

> On Mon, Jun 3, 2019 at 10:12 AM Daniel Hahler <vim-dev...@256bit.org> wrote:
> >
> > https://github.com/vim/vim/blob/98fb65cb051f625f4ce291a9f9cdb2e54ac1e688/runtime/doc/sign.txt#L185-L187:
> >
> > The priority is used to determine the
> > highlight group used when multiple signs are placed on the
> > same line.
> >
> > I assume it is not just used for the highlight group, but for the sign being displayed altogether?
> >
>
> I am attaching an update to the help text that clarifies this. I have
> also added a test
> for updating the priority of an already placed sign.

Thanks!

--
From "know your smileys":
:-& Eating spaghetti

/// Bram Moolenaar -- Br...@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 ///

vim-dev ML

unread,
Jun 4, 2019, 4:49:07 PM6/4/19
to vim/vim, vim-dev ML, Your activity

Yegappan wrote:

> On Mon, Jun 3, 2019 at 10:12 AM Daniel Hahler <vim-dev...@256bit.org> wrote:
> >
> > https://github.com/vim/vim/blob/98fb65cb051f625f4ce291a9f9cdb2e54ac1e688/runtime/doc/sign.txt#L185-L187:
> >
> > The priority is used to determine the
> > highlight group used when multiple signs are placed on the
> > same line.
> >
> > I assume it is not just used for the highlight group, but for the sign being displayed altogether?
> >
>
> I am attaching an update to the help text that clarifies this. I have
> also added a test
> for updating the priority of an already placed sign.

Thanks!

--
From "know your smileys":
:-& Eating spaghetti

/// Bram Moolenaar -- Br...@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 ///

Daniel Hahler

unread,
Jun 7, 2019, 1:10:13 PM6/7/19
to vim/vim, vim-dev ML, Comment

Thanks, closing.


You are receiving this because you commented.

Daniel Hahler

unread,
Jun 7, 2019, 1:10:14 PM6/7/19
to vim/vim, vim-dev ML, Comment

Closed #4482.


You are receiving this because you commented.

Yegappan Lakshmanan

unread,
Jun 7, 2019, 11:01:15 PM6/7/19
to vim_dev, reply+ACY5DGBJFPIKYUEGAI...@reply.github.com, vim/vim, vim-dev ML, Comment
Hi,

On Fri, Jun 7, 2019 at 10:10 AM Daniel Hahler <vim-dev...@256bit.org> wrote:
>
> Thanks, closing.
>

You may want to try changing the priorities of already placed signs on
a single line
after patch #1489.

- Yegappan

vim-dev ML

unread,
Jun 7, 2019, 11:01:39 PM6/7/19
to vim/vim, vim-dev ML, Your activity
Reply all
Reply to author
Forward
0 new messages