RFC: Function get a list of global/local marks

13 views
Skip to first unread message

Yegappan Lakshmanan

unread,
May 1, 2020, 11:52:27 AM5/1/20
to vim_dev
Hi all,

Currently we have the line(), col(), virtcol() and getpos() functions
to get the position of a particular mark. But we don't have a
function to get the list of local/global marks (information displayed
by the :marks command). A plugin needs to call the above functions
in a loop for various supported local/global marks to create this list.
What do you think about adding a getmarklist() function which will
return the List of placed global/local marks? The help text for this function
is below.

We have similar functions for returning the following:

argument list: argv()
buffers in a tabpage: tabpagebuflist()
buffers: getbufinfo()
change list: getchangelist()
jump list: getjumplist()
location list: getloclist()
matches: getmatches()
quickfix list: getqflist()
signs: sign_getdefined(), sign_getplaced()
tabpages: gettabinfo()
tags: taglist()
terminals: term_list()
timers: timer_info()
windows: getwininfo()

Thanks,
Yegappan

======================================================
getmarklist([{expr}]
               Returns a |List| with information about the global marks or the
               local marks placed in a buffer. |mark|

               The optional {expr} argument specifies a buffer. For the use
               of {expr}, see |bufname()|. If specified, returns the
               local marks defined in buffer {expr}. If the {expr} argument
               is not supplied, then returns information about all the global
               marks.

               Each item in the retuned List is a |Dict| with the following:
                   name - name of the mark prefixed by "'"
                   pos - a |List| with the position of the mark:
                               [bufnum, lnum, col, off]
                         Refer to |getpos()| for more information.
                   file - file name

               Refer to |getpos()| for getting information about a specific
               mark.


Tony Mechelynck

unread,
May 1, 2020, 12:34:48 PM5/1/20
to Yegappan Lakshmanan, vim_dev
On Fri, May 1, 2020 at 5:52 PM Yegappan Lakshmanan <yega...@gmail.com> wrote:
>
> Hi all,
>
> Currently we have the line(), col(), virtcol() and getpos() functions
> to get the position of a particular mark. But we don't have a
> function to get the list of local/global marks (information displayed
> by the :marks command). A plugin needs to call the above functions
> in a loop for various supported local/global marks to create this list.
> What do you think about adding a getmarklist() function which will
> return the List of placed global/local marks? The help text for this function
> is below.

In the meantime (until you get it into the C code) I suppose your
plugin could get the output of :marks into a variable by means of
:redir and parse that: it seems fairly straightforward: one heading
line, then repeatedly <mark name> <line> <column> <file or text> with
one or more spaces before each.

Best regards,
Tony.

Yegappan Lakshmanan

unread,
May 1, 2020, 1:44:59 PM5/1/20
to Tony Mechelynck, vim_dev
Hi Tony,

Yes. The existing plugins like the one below are parsing the output of
the :marks command to get this information:


If there is a built-in function that returns this information in a Vim native
type, then it will be much easier for plugins to consume this information.

Regards,
Yegappan

Ben Jackson

unread,
May 2, 2020, 6:36:12 AM5/2/20
to vim_dev
I don't use `:marks` in any of my plugins, but if I did, I would _much_ prefer a function returning them as a list/dict than having to parse the output of exectute( 'marks' )

So +1 to this, and +1 to adding one for popups too.
Reply all
Reply to author
Forward
0 new messages