[patch] allow setting of w:quickfix_title via setqflist()/setloclist() functions

358 views
Skip to first unread message

Christian Brabandt

unread,
May 7, 2013, 5:03:54 PM5/7/13
to vim...@vim.org
Bram,
this patch allows to directly set the w:quickfix_title using
setqflist()/setloclist() functions. Since the w:quickfix_title is
already stored inside each quickfix list, it makes sense to have it also
being settable using VimL functions. This allows plugin writers to
handle existing quickfix lists better (e.g. they can use the
w:quickfix_title variable to tag and identify quickfix lists).


regards,
Christian
setqflist_title.diff

Ben Fritz

unread,
May 7, 2013, 6:15:13 PM5/7/13
to vim...@googlegroups.com, vim...@vim.org, erva...@gmail.com
Hi, Christian!

The maintainer of Eclim, Eric Van Dewoestine, sent me a patch to try once which not only allowed setting the quickfix title but it also made :colder and :cnewer restore that title.

I can't tell from looking quickly, does your patch allow this as well?

I never dug deeply enough into the first one to give him feedback one way or another. I remember it had compiler errors that looked worrisome to me.

I wanted this patch to fix something in Eclim that has bugged me for a while, that there is very little info on WHAT search resulted in a given quickfix list. But as mentioned I hadn't really gotten around to trying out the patch.

Eric Van Dewoestine

unread,
May 7, 2013, 6:31:15 PM5/7/13
to Ben Fritz, vim...@googlegroups.com, vim...@vim.org
Attached is the patch that Ben is referring to. I never got around to
dealing with the compiler warning (my experience w/ c is severely
limited).

--
eric
qftitle.patch

Bram Moolenaar

unread,
May 8, 2013, 12:04:44 AM5/8/13
to Christian Brabandt, vim...@vim.org
The documentation update appears to be missing.

--
GALAHAD hurries to the door and pushes through it. As he leaves the room
we CUT TO the reverse to show that he is now in a room full of bathing
and romping GIRLIES, all innocent, wide-eyed and beautiful. They smile
enchantingly at him as he tries to keep walking without being diverted by
the lovely sights assaulting his eyeballs.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

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

Christian Brabandt

unread,
May 8, 2013, 1:40:06 AM5/8/13
to vim...@googlegroups.com
On Wed, May 8, 2013 00:15, Ben Fritz wrote:
> The maintainer of Eclim, Eric Van Dewoestine, sent me a patch to try once
> which not only allowed setting the quickfix title but it also made :colder
> and :cnewer restore that title.
>
> I can't tell from looking quickly, does your patch allow this as well?

Yes, this automatically happens, if a quickfix list contains a title.
Looking at that patch, it seems, it introduces some new functions
setqftitle()/getqftitle() I am not sure this is needed, since you can
simply set and query the variable w:quickfix_title

regards,
Christian

Christian Brabandt

unread,
May 8, 2013, 1:41:30 AM5/8/13
to Bram Moolenaar, vim...@vim.org
On Wed, May 8, 2013 06:04, Bram Moolenaar wrote:
>
> Christian Brabandt wrote:
>
>> Bram,
>> this patch allows to directly set the w:quickfix_title using
>> setqflist()/setloclist() functions. Since the w:quickfix_title is
>> already stored inside each quickfix list, it makes sense to have it also
>> being settable using VimL functions. This allows plugin writers to
>> handle existing quickfix lists better (e.g. they can use the
>> w:quickfix_title variable to tag and identify quickfix lists).
>
> The documentation update appears to be missing.

Upps, sorry. I'll attach a new patch soon (when I have access to my
development machine again).

regards,
Christian

Eric Van Dewoestine

unread,
May 8, 2013, 9:13:45 AM5/8/13
to vim...@googlegroups.com
The problem with setting w:quickfix_title directly is that the title
is not properly stored with the list and so it's lost when using
cnewer/colder.

The advantage of having separate functions is that you can set the
title without having to replace the existing list:

call setqftitle('something meaningful')
vs
call setqflist(getqflist(), 'r', 'something meaningful')

However, while testing your patch it seems I can't overwrite the
existing title to make it something more meaningful when using replace
('r') or append ('a'). In those cases the argument seems to be
ignored. So when making use of cexpr to build my quickfix list, I'm
still stuck with the default title vim generates or setting
w:quickfix_title directly and losing that title when navigating the
quickfix lists history.

I'm not dead set on having separate functions like in my patch, but
not being able to update the persistent title of an existing list
makes your patch far less useful in my usage. Can that aspect be
remedied?

--
eric

Christian Brabandt

unread,
May 8, 2013, 2:30:21 PM5/8/13
to vim...@vim.org
Hi Bram!

On Mi, 08 Mai 2013, Bram Moolenaar wrote:

>
> The documentation update appears to be missing.

Updated patch attached. Includes documentation and fixes the issue
mentioned so far plus allows setting the w:quickfix_title using
setwinvar().

Mit freundlichen Gr��en
Christian
--
Die Wissenschaft ist der Verstand der Welt, die Kunst ihre Seele.
-- Maxim Gorkij
setqflist_title.diff

Christian Brabandt

unread,
May 8, 2013, 2:32:01 PM5/8/13
to vim...@googlegroups.com
Hi Eric!
Please try the updated patch. I haven't yet created on extra functions,
but if this is preferred, I'll change it. Opinions?

Mit freundlichen Gr��en
Christian
--
Um einen falschen Gedanken mit Erfolg zu widerlegen, mu� man
bekanntlich ein ganzes Buch schreiben, und den, der den Ausspruch
getan hat, �berzeugt man doch nicht.
-- Otto von Bismarck

Eric Van Dewoestine

unread,
May 8, 2013, 3:47:39 PM5/8/13
to vim...@googlegroups.com
Works much better now, thank you.

> I haven't yet created on extra functions,
> but if this is preferred, I'll change it. Opinions?

I'm fine with using setwinvar instead of having dedicated functions.
It avoids the need for an exists() call to retain backwards
compatibility in scripts.

> Mit freundlichen Gr��en
> Christian

--
eric

Bram Moolenaar

unread,
May 8, 2013, 11:31:34 PM5/8/13
to Christian Brabandt, vim...@vim.org

Christian Brabandt wrote:

> Hi Bram!
>
> On Mi, 08 Mai 2013, Bram Moolenaar wrote:
>
> > The documentation update appears to be missing.
>
> Updated patch attached. Includes documentation and fixes the issue
> mentioned so far plus allows setting the w:quickfix_title using
> setwinvar().

Thanks. I'll add it to the todo list.

--
Eight Megabytes And Continually Swapping.

Christian Brabandt

unread,
May 11, 2013, 5:29:29 PM5/11/13
to vim...@vim.org
On Mi, 08 Mai 2013, Christian Brabandt wrote:

> Updated patch attached. Includes documentation and fixes the issue
> mentioned so far plus allows setting the w:quickfix_title using
> setwinvar().

Another update, that fixes failure of test10.

regards,
Christian
--
Die Managerkrankheit ist eine Epidemie, die durch den Uhrzeiger
hervorgerufen und durch den Terminkalender �bertragen wird.
-- John Ernst Steinbeck
setqflist_title.diff

Bram Moolenaar

unread,
May 11, 2013, 6:18:59 PM5/11/13
to Christian Brabandt, vim...@vim.org

Christian Brabandt wrote:

> On Mi, 08 Mai 2013, Christian Brabandt wrote:
>
> > Updated patch attached. Includes documentation and fixes the issue=20
> > mentioned so far plus allows setting the w:quickfix_title using=20
> > setwinvar().
>
> Another update, that fixes failure of test10.

Thanks.


--
MORTICIAN: What?
CUSTOMER: Nothing -- here's your nine pence.
DEAD PERSON: I'm not dead!
MORTICIAN: Here -- he says he's not dead!
CUSTOMER: Yes, he is.
DEAD PERSON: I'm not!
The Quest for the Holy Grail (Monty Python)

Daniel Hahler

unread,
Feb 14, 2014, 8:37:15 AM2/14/14
to vim...@googlegroups.com, vim...@vim.org
> Another update, that fixes failure of test10.

This patch changes the default title (?) from ":setloclist()" to "setloclist()".

I have no simple test case, and have not investigated further, but I've noticed this, because Syntastic checks for this, before overwriting it (via "call setwinvar(win, 'quickfix_title', ':SyntasticCheck ' . self._name)").

The check could get changed to make the ":" optional, but I guess it's better to keep the default.

I think the following hunk might be involved:

diff --git a/src/quickfix.c b/src/quickfix.c
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -914,13 +914,7 @@
qi->qf_curlist = qi->qf_listcount++;
vim_memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T)));
if (qf_title != NULL)
- {
- char_u *p = alloc((int)STRLEN(qf_title) + 2);
-
- qi->qf_lists[qi->qf_curlist].qf_title = p;
- if (p != NULL)
- sprintf((char *)p, ":%s", (char *)qf_title);
- }
+ qi->qf_lists[qi->qf_curlist].qf_title = vim_strsave(qf_title);
}

/*


Regards,
Daniel.

Christian Brabandt

unread,
Feb 15, 2014, 4:48:15 PM2/15/14
to vim...@googlegroups.com

On Fr, 14 Feb 2014, Daniel Hahler wrote:

> > Another update, that fixes failure of test10.
>
> This patch changes the default title (?) from ":setloclist()" to
> "setloclist()".

The reason for leaving out the colon was so that it wouldn't confuse the
user and will not leave the impression, that there exists a :setloclist
ex command. But note, that I don't have a strong feeling about it
anyhow.

Best,
Christian
--
"Life is too important to take seriously."
-- Corky Siegel

Daniel Hahler

unread,
Jul 4, 2014, 6:22:39 AM7/4/14
to vim...@googlegroups.com
Am Samstag, 15. Februar 2014 22:48:15 UTC+1 schrieb Christian Brabandt:
> On Fr, 14 Feb 2014, Daniel Hahler wrote:
> > > Another update, that fixes failure of test10.

> > This patch changes the default title (?) from ":setloclist()" to
> > "setloclist()".

> The reason for leaving out the colon was so that it wouldn't confuse the
> user and will not leave the impression, that there exists a :setloclist
> ex command. But note, that I don't have a strong feeling about it
> anyhow.


I have updated the patch to use the old default titles, as mentioned earlier:

diff --git a/src/eval.c b/src/eval.c
index 2f7da3d..b366223 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -16733,7 +16733,7 @@ set_qf_ll_list(wp, list_arg, action_arg, title_arg, rettv)
return; /* type error; errmsg already given */
}
if (title == NULL)
- title = (char_u*)(wp == NULL ? "setqflist()" : "setloclist()");
+ title = (char_u*)(wp == NULL ? ":setqflist()" : ":setloclist()");

if (l != NULL && set_errorlist(wp, l, action, title) == OK)
rettv->vval.v_number = 0;


FWIW, I have created a branch (based on a Git mirror) to track this patch:
https://github.com/blueyed/vim/compare/setqflist_title

The patch can be seen also by adding ".patch" to the URL:
https://github.com/blueyed/vim/compare/setqflist_title.patch

It would be nice to get it applied/included finally.


Regards,
Daniel.

setqflist_title.diff

Daniel Hahler

unread,
Aug 14, 2014, 11:17:16 AM8/14/14
to vim...@googlegroups.com
I have updated the patch to work with current master/tip:

https://github.com/blueyed/vim/compare/setqflist_title_2

The patch can be seen also by adding ".patch" to the URL:

https://github.com/blueyed/vim/compare/setqflist_title_2.patch

It did not apply cleanly anymore and after fixing the conflict, "test10" was failing: there were two colons instead of one in the quickfix title ("::cf" vs. ":cf").

This patch is shorter than the previous one, mainly because the handling of ":" gets done in a central place now, and it has been removed from `ex_make` etc.


Regards,
Daniel.

setqflist_title_2.diff

Bram Moolenaar

unread,
Aug 14, 2014, 2:46:23 PM8/14/14
to Daniel Hahler, vim...@googlegroups.com

Daniel Hahler wrote:

> I have updated the patch to work with current master/tip:
>
> https://github.com/blueyed/vim/compare/setqflist_title_2
>
> The patch can be seen also by adding ".patch" to the URL:
> https://github.com/blueyed/vim/compare/setqflist_title_2.patch
>
> It did not apply cleanly anymore and after fixing the conflict,
> "test10" was failing: there were two colons instead of one in the
> quickfix title ("::cf" vs. ":cf").
>
> This patch is shorter than the previous one, mainly because the
> handling of ":" gets done in a central place now, and it has been
> removed from `ex_make` etc.

Thanks for the update. You did fix the failing test, right?


--
How To Keep A Healthy Level Of Insanity:
14. Put mosquito netting around your work area. Play a tape of jungle
sounds all day.

Daniel Hahler

unread,
Aug 17, 2014, 10:58:15 AM8/17/14
to vim...@googlegroups.com, google-gr...@thequod.de, Christian Brabandt
Am Donnerstag, 14. August 2014 20:46:23 UTC+2 schrieb Bram Moolenaar:
> Daniel Hahler wrote:
>
> > I have updated the patch to work with current master/tip:
> > https://github.com/blueyed/vim/compare/setqflist_title_2
>
> > The patch can be seen also by adding ".patch" to the URL:
> > https://github.com/blueyed/vim/compare/setqflist_title_2.patch
>
> > It did not apply cleanly anymore and after fixing the conflict,
> > "test10" was failing: there were two colons instead of one in the
> > quickfix title ("::cf" vs. ":cf").
>
> > This patch is shorter than the previous one, mainly because the
> > handling of ":" gets done in a central place now, and it has been
> > removed from `ex_make` etc.

> Thanks for the update. You did fix the failing test, right?

Yes, although I did not fix the failing test, but the patch.

I would appreciate to get feedback from Christian on this new patch.


Regards,
Daniel.

Christian Brabandt

unread,
Aug 17, 2014, 1:57:14 PM8/17/14
to vim...@googlegroups.com
Looks good for me.

Best,
Christian
--
Alle schaffen hart für Knete, nur nicht Otto, der spielt Lotto.

Daniel Hahler

unread,
Oct 14, 2014, 5:28:40 PM10/14/14
to vim...@googlegroups.com
There was a problem with the previous patch, which should have used the new "save_curwin" variable.

I've also moved the handling of "quickfix_title" to the bottom of "setwinvar", to also handle cases where "&foo" gets set - I am not sure if that makes sense.

I am attaching the refreshed patch again.

vim-setqflist_title_2.diff

Daniel Hahler

unread,
Oct 15, 2014, 1:40:54 PM10/15/14
to vim...@googlegroups.com
Another refresh: the previous patch had a wrong `vim_free(v)`, which could cause a segfault.
vim-setqflist_title_2.diff

Daniel Hahler

unread,
May 7, 2015, 4:36:01 PM5/7/15
to vim...@googlegroups.com
@Bram,

what do you think about the patch?

I have not checked if it still applies (I have it in my local branch), but came across it being missing a few times recently.

It's very useful, so please consider applying it.


Thanks,
Daniel.

Bram Moolenaar

unread,
May 10, 2015, 4:16:29 AM5/10/15
to Daniel Hahler, vim...@googlegroups.com
It's in the todo list.

--
If you put 7 of the most talented OSS developers in a room for a week
and asked them to fix a bug in a spreadsheet program, in 1 week
you'd have 2 new mail readers and a text-based web browser.

Jason Franklin

unread,
Jul 17, 2017, 9:33:18 AM7/17/17
to vim_dev, google-gr...@thequod.de
Hi Everyone,

This is just a friendly ping concerning this patch.

I recently came across the documentation for patch 7.4.378, which appears to have been overwritten by later work. There is a lot of information here, and I can't go through all of it at the moment.

However, since I've been prototyping a plugin that helps users manipulate the quickfix/location lists, I wanted to ask for the status of this new feature. It is critical to the functioning of my plugin, so I hope it gets added! By the way, Bram, I can't find this item in "todo.txt", so I don't know if the idea has been abandoned.

Thanks for all the work you guys have done!

-- Jason

Yegappan Lakshmanan

unread,
Jul 17, 2017, 10:52:17 AM7/17/17
to vim_dev, google-gr...@thequod.de
Hi,

On Mon, Jul 17, 2017 at 6:04 AM, Jason Franklin
<jrfra...@georgiasouthern.edu> wrote:
> On Sunday, May 10, 2015 at 4:16:29 AM UTC-4, Bram Moolenaar wrote:
>> Daniel Hahler wrote:
>>
>> > @Bram,
>> >
>> > what do you think about the patch?
>> >
>> > I have not checked if it still applies (I have it in my local branch), but came across it being missing a few times recently.
>> >
>> > It's very useful, so please consider applying it.
>>
>> It's in the todo list.
>>
>
> Hi Everyone,
>
> This is just a friendly ping concerning this patch.
>
> I recently came across the documentation for patch 7.4.378, which appears to
> have been overwritten by later work. There is a lot of information here, and
> I can't go through all of it at the moment.
>
> However, since I've been prototyping a plugin that helps users manipulate the
> quickfix/location lists, I wanted to ask for the status of this new feature.
> It is critical to the functioning of my plugin, so I hope it gets added! By
> the way, Bram, I can't find this item in "todo.txt", so I don't know if the
> idea has been abandoned.
>

You can set the quickfix list title using the setqflist() function:

:call setqflist([], 'a', {'title' : 'My title'})

If the quickfix window is opened, the w:quickfix_title variable is also updated
with the new title.

- Yegappan

Jason Franklin

unread,
Jul 17, 2017, 11:20:11 AM7/17/17
to vim_dev, google-gr...@thequod.de

Thank you very much!

Yegappan Lakshmanan

unread,
Jul 17, 2017, 12:29:44 PM7/17/17
to vim_dev, Daniel Hahler
Hi,
BTW, your plugin can also store a context with every quickfix list using

:call setqflist([], 'a', {'context' : <any vim variable>})

and retrieve the context using

:let ctx = getqflist({'context' : 1})

- Yegappan

Jason Franklin

unread,
Jul 17, 2017, 12:59:04 PM7/17/17
to vim_dev, google-gr...@thequod.de
On Monday, July 17, 2017 at 12:29:44 PM UTC-4, yega...@gmail.com wrote:
> Hi,
>

That's interesting! I don't actually see that anywhere in the documentation. Is that an undocumented feature?

-- Jason

Christian Brabandt

unread,
Jul 17, 2017, 1:19:45 PM7/17/17
to vim_dev
> That's interesting! I don't actually see that anywhere in the
> documentation. Is that an undocumented feature?

That is pretty new functionality, it comes with 8.0.0606. It should be
documented however.

Best,
Christian
--
Genie ist oft nur die Fähigkeit, auf ungewöhnliche Art zu schauen.
-- William James

Jason Franklin

unread,
Jul 17, 2017, 1:25:56 PM7/17/17
to vim...@googlegroups.com
Excellent. I'll need to include a version check in my plugin to disable functionality that relies on these features.

Should I start at patch 8.0.0.606?

Thanks!

----------------------------------------
Jason R. Franklin
Associate Systems Software Developer
Enterprise Technology Solutions


Georgia Southern University
P.O. Box 8088
Statesboro, GA 30460
912.478.5639



--
--
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 a topic in the Google Groups "vim_dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/X7VVPd4Do5s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Brabandt

unread,
Jul 17, 2017, 1:36:00 PM7/17/17
to vim...@googlegroups.com

On Mo, 17 Jul 2017, Jason Franklin wrote:

> Excellent. I'll need to include a version check in my plugin to disable
> functionality that relies on these features.
>
> Should I start at patch 8.0.0.606?

Depends™ on your requirements. If you know, that your plugin will always
only be run on the latest version of Vim, you don't need the check. If
you don't know where your plugin will be running, than perhaps use
release 8.0 as a starting point. Then other users might complain,
because their Ubuntu LTS 16.04 version only provides a vim 7.4.1689.

Then however, if you need async, you definitely should start with a 8.0
dependency. But whatever you do, make sure you document your minimum
version requirement.

For new plugins, I usually start with the latest major version and only
add additional checks, if users start to complain and the functionality
can be added with reasonable effort to older Vims.

Best,
Christian

Yegappan Lakshmanan

unread,
Jul 17, 2017, 11:40:19 PM7/17/17
to vim_dev
Hi,

On Mon, Jul 17, 2017 at 9:59 AM, Jason Franklin
<jrfra...@georgiasouthern.edu> wrote:
> On Monday, July 17, 2017 at 12:29:44 PM UTC-4, yega...@gmail.com wrote:
>> Hi,
>>
It is a new feature and is documented in the latest versions of the
eval.txt file.

- Yegappan
Reply all
Reply to author
Forward
0 new messages