Friday, April 10, 2015

Re: quickfix information

On 10 April 2015, Ben Fritz <fritzophrenic@gmail.com> wrote:
> On Friday, April 10, 2015 at 5:03:40 AM UTC-5, herm...@free.fr wrote:
> > Hello,
> >
> > I'm looking for a way to have (buffer-local) variables persist in
> > quickfix buffers -- e.g. project name and compilation mode which are
> > likely (expected in my scenarios) to change between two calls to
> > :make.
> >
> > :cclose seems to trigger a wipeout of the buffer -- thus all buffer
> > variables are lost. And still when we play with getqflist(),
> > :copen/:cprev/:cnew we are able to recover the list of quickfix
> > messages. The quickfix information is not lost whilst the the buffer
> > information is. Thus, I've tried to inject an item in the quickfix
> > list, but we cannot use fields that are not expected. For instance
> >
> > let l = getqflist()
> > l[0].mydata = {'foobar': [1, 2, 42] }
> > call setqflist(l)
> >
> > echo has_key(getqflist()[0], 'mydata')
> >
> > prints 0
> >
> > I could inject a fake entry where I'd use 'nr' field as an id to
> > dictionary of quickfix buffers. But is there a better and neater way
> > to proceed ? Or the only persistent qf information is the qflist ?

No. If you pass extra data to setqflist() / setloclist(), the extra
fields are ignored. When you call getqflist() / getloclist() only the
documented fields are returned, regardless of how the current quickfix
list / loclist was created.

> I think the quickfix window title (:help w:quickfix_title) is also
> saved with the list in recent versions of Vim.

It isn't. The (relatively) recent patch about w:quickfix_title
resolves a bug, where an existing w:quickfix_title would get erased by
some operations. It has nothing to do with the actual contents of the
quickfix lists / loclists.

> You *might* be able to take advantage of this (especially since
> project name and compilation mode would probably be useful in the
> quickfix title as well).
>
> But maybe taking advantage of this would actually require the patch
> from this todo item:
>
> Patch to allow setting w:quickfix_title via setqflist() and setloclist()
> functions. (Christian Brabandt, 2013 May 8, update May 21)

This allows you to set w:quickfix_title, which is later displayed
on the status bar of the quickfix window. It doesn't allow you to save
arbitrary data to quickfix lists / loclists.

> Patch to add getlocstack() / setlocstack(). (Christian Brabandt, 2013 May 14)
> Second one. Update May 22.
> Update by Daniel Hahler, 2014 Jul 4, Aug 14, Oct 14, Oct 15.

These refer to manipulating the stack of quickfix lists / loclists.
Nothing to do with extra data.

/lcd

--
--
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: