Friday, September 1, 2017

Quickfix/Location list identifier feature

Hi all,

Patch 8.0.1023 added supported for the quickfix list identifier. Now
each quickfix and location list can be uniquely identified. This is
needed because the quickfix list number in the quickfix stack is not
unique and can change as new quickfix lists are added. A Vim plugin that
asynchronously adds entries to a quickfix list can use the identifier to
guarantee that the correct list is modified.

Some example uses of this feature are shown below.

To get the current quickfix list identifier:

let myid = getqflist({'id' : 0}).id

To get the identifier of the 4th quickfix list in the stack:

let myid = getqflist({'nr' : 4, 'id' : 0}).id

To get all the items in a quickfix list using the identifier:

let l = getqflist({'id' : myid, 'items' : 1})

To get the title/context/items information using the identifier:

let m = getqflist({'id' : myid, 'all' : 1})

To add entries to a quickfix list using the identifier:

call setqflist([], 'a', {'id' : myid, 'lines':["F1:10:L10"]})

To change the title of a quickfix list using the identifier:

call setqflist([], 'r', {'id' : myid, 'title' : 'newTitle'})

To remove all the entries from a quickfix list:

call setqflist([], 'r', {'id' : myid, 'items' : []})

To check whether a quickfix list with the identifier exists:

if has_key(getqflist({'id' : myid}), 'id')

To get the quickfix list number using the identifier:

echo getqflist({'id' : myid, 'nr' : 0})

To use this with location lists, replace getqflist() with getloclist() and pass
the window number.

- Yegappan

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: