Quickfix List vs Location List

315 views
Skip to first unread message

Kent Sibilev

unread,
Aug 5, 2016, 4:49:09 PM8/5/16
to vim_dev
Currently it's hard to distinguish between Quickfix or Location list windows.

Unless I'm mistaken, but when either window is open the only way I could check
which one is open is by using :ls and checking if it reports the name of any
buffer as "[Quickfix List]" or "[Location List]".

I think it would be much easier if function bufname() had a second argument and when it's not zero it would return a special buffer name. Please see the patch attached.

Regards,
Kent

bufname_special.patch

Bram Moolenaar

unread,
Aug 6, 2016, 1:02:18 PM8/6/16
to Kent Sibilev, vim_dev
The problem with this solution is that the names are translated.
A more direct solution would be better.

The 'buftype' option is "quickfix" for both quickfix and location list.
We can't change that without causing problems.

Perhaps we should add a buftype({expr}) function, that can get the
buffer type of any buffer, and make a difference between "quickfix" and
"loclist".


--
BLACK KNIGHT: The Black Knight always triumphs. Have at you!
ARTHUR takes his last leg off. The BLACK KNIGHT's body lands upright.
BLACK KNIGHT: All right, we'll call it a draw.
"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 ///

Kent Sibilev

unread,
Aug 7, 2016, 4:12:55 PM8/7/16
to vim_dev, ksib...@gmail.com
On Saturday, August 6, 2016 at 1:02:18 PM UTC-4, Bram Moolenaar wrote:
>
> The problem with this solution is that the names are translated.
> A more direct solution would be better.
>
> The 'buftype' option is "quickfix" for both quickfix and location list.
> We can't change that without causing problems.
>
> Perhaps we should add a buftype({expr}) function, that can get the
> buffer type of any buffer, and make a difference between "quickfix" and
> "loclist".

I see. Even though it's quite awkward to add a new function just to accommodate this particular case, i'm attaching my attempt to implement it.

Regards,
Kent.

buftype.patch

LCD 47

unread,
Aug 8, 2016, 4:03:22 AM8/8/16
to vim_dev
Wait, isn't the title already supposed to tell you that?

/lcd

Kent Sibilev

unread,
Aug 8, 2016, 11:31:05 AM8/8/16
to vim_dev
On Monday, August 8, 2016 at 4:03:22 AM UTC-4, LCD 47 wrote:

>
> Wait, isn't the title already supposed to tell you that?
>

What do you mean by title?

Regards,
Kent.

LCD 47

unread,
Aug 8, 2016, 12:44:56 PM8/8/16
to vim_dev
From the manual (":h :copen"):

: The window will have the w:quickfix_title variable set
: which will indicate the command that produced the
: quickfix list. This can be used to compose a custom
: status line if the value of 'statusline' is adjusted
: properly.

By default the status line of the quickfix open shows "[Quickfix
List]" or "[Location List]", followed by the w:quickfix_title variable
described above. Some of the plugins that customize status lines choose
to ignore that information. I don't think this is something that needs
to be fixed in Vim.

/lcd

Nikolay Aleksandrovich Pavlov

unread,
Aug 8, 2016, 1:04:31 PM8/8/16
to vim_dev
w:quickfix_title cannot be used: e.g. install
https://github.com/rking/ag.vim and run `:Ag -w test` then `:LAg -w
test`. If you use :copen and :lopen then you will see that in both
cases `w:quickfix_title` is `:ag --vimgrep -w test`: completely
useless.

`[Quickfix List]` vs `[Location List]` can neither be used because
they are translated as Bram said. Also parsing anything to get this
information sounds like a bad idea.

---

By the way, I remember some patches that add functions returning
information about buffer/window/tabpage. It would be logical if
information regarding whether given buffer contains
quickfix/location/no list was included there.

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

Kent Sibilev

unread,
Aug 8, 2016, 3:12:13 PM8/8/16
to vim_dev
On Monday, August 8, 2016 at 12:44:56 PM UTC-4, LCD 47 wrote:

> By default the status line of the quickfix open shows "[Quickfix
> List]" or "[Location List]", followed by the w:quickfix_title variable
> described above. Some of the plugins that customize status lines choose
> to ignore that information. I don't think this is something that needs
> to be fixed in Vim.

That's my point. There is no reliable way to distinguish if we are dealing with
a quickfix or a location window. Considering that you have to use different set of
commands to handle these windows, this information has to be easily obtainable. But
as of right now, it's not the case. w:quickfix_window can be modified, which means it
is not a reliable source.

Also status line uses buf_spname() function that is not exposed via API and as Bram
mentioned returns values that are translated.

Regards,
Kent

Bram Moolenaar

unread,
Aug 8, 2016, 5:27:17 PM8/8/16
to Kent Sibilev, vim_dev
Yes, it is unexpected to have this function. But I can see it's useful.
Would there be a better solution somehow?
Perhaps using one of the existing quickfix functions?


--
While it's true that many normal people whould prefer not to _date_ an
engineer, most normal people harbor an intense desire to _mate_ with them,
thus producing engineerlike children who will have high-paying jobs long
before losing their virginity.
(Scott Adams - The Dilbert principle)

Yegappan Lakshmanan

unread,
Aug 8, 2016, 7:37:46 PM8/8/16
to vim_dev
Hi,
I agree. The patch to get information about a buffer/window/tab page
is at:

https://github.com/vim/vim/pull/833

The information about the quickfix/location list window/buffer can be
added to this patch.

Another alternative is the patch I sent two weeks ago to extend the
getqflist() and getloclist() functions. The returned dictionary contains
the 'winid' key which has the window ID of the quickfix or location
list window.

- Yegappan

h_east

unread,
Aug 10, 2016, 4:16:11 AM8/10/16
to vim_dev, ksib...@gmail.com
Hi Bram and list,

2016-8-9(Tue) 6:27:17 UTC+9 Bram Moolenaar:


> Kent Sibilev wrote:
>
> > On Saturday, August 6, 2016 at 1:02:18 PM UTC-4, Bram Moolenaar wrote:
> > >
> > > The problem with this solution is that the names are translated.
> > > A more direct solution would be better.
> > >
> > > The 'buftype' option is "quickfix" for both quickfix and location list.
> > > We can't change that without causing problems.
> > >
> > > Perhaps we should add a buftype({expr}) function, that can get the
> > > buffer type of any buffer, and make a difference between "quickfix" and
> > > "loclist".
> >
> > I see. Even though it's quite awkward to add a new function just to
> > accommodate this particular case, i'm attaching my attempt to
> > implement it.
>
> Yes, it is unexpected to have this function. But I can see it's useful.
> Would there be a better solution somehow?
> Perhaps using one of the existing quickfix functions?

Do you remember this thread?

We can't handle type which it's quickfix or location-list.
https://groups.google.com/d/msg/vim_dev/GIjn9QRyLag/M_8AJ5_UkMoJ

It also listed on the TODO.
TODO> Patch to check whether a buffer is quickfix or a location list.
TODO> (Yasuhiro Matsumoto, 2014 Dec 9)

I've arranged with several correct mistakes of this patch.
It will be `w:quickfix_type` is set. In the same way as the `w:quickfix_title`.
The values are 'quickfix' or 'location'.

What about an attached patch?
--
Best regards,
Hirohito Higashi (a.k.a. h_east)

add_quickfix_type_variable.patch

Bram Moolenaar

unread,
Aug 10, 2016, 4:32:16 PM8/10/16
to h_east, vim_dev, ksib...@gmail.com
I think we should avoid adding more w: variables. They can interfere
with what a user sets. The more we add the bigger the chance that it
goes wrong.

--
A)bort, R)etry, P)lease don't bother me again

h_east

unread,
Aug 12, 2016, 5:33:09 AM8/12/16
to vim_dev, h.eas...@gmail.com, ksib...@gmail.com
Hi Bram,

2016-8-11(Thu) 5:32:16 UTC+9 Bram Moolenaar:

Okay. I understand.
Let's remove the following one from Todo list.

TODO> Patch to check whether a buffer is quickfix or a location list.
TODO> (Yasuhiro Matsumoto, 2014 Dec 9)

--

Nicola

unread,
Aug 12, 2016, 7:37:16 AM8/12/16
to vim...@vim.org
Wouldn't it be possible to expose the %q value of the status line
through a function (say, expand("<qf>"))?

Nicola


Nikolay Aleksandrovich Pavlov

unread,
Aug 12, 2016, 7:52:18 AM8/12/16
to vim_dev, vim-dev Mailingliste
How is this supposed to help? Remember that %q is *translated* and
thus cannot be used for checking. Also exposing this was already
discussed.

>
> Nicola

Yegappan Lakshmanan

unread,
Aug 13, 2016, 9:51:01 PM8/13/16
to vim_dev
Hi all,

On Mon, Aug 8, 2016 at 4:37 PM, Yegappan Lakshmanan <yega...@gmail.com> wrote:
>
>>
>> By the way, I remember some patches that add functions returning
>> information about buffer/window/tabpage. It would be logical if
>> information regarding whether given buffer contains
>> quickfix/location/no list was included there.
>>
>
> I agree. The patch to get information about a buffer/window/tab page
> is at:
>
> https://github.com/vim/vim/pull/833
>
> The information about the quickfix/location list window/buffer can be
> added to this patch.
>

I am attaching a patch to add two new fields to the dict returned
by the getwininfo() function. The 'qfwin' field is set to true for the
quickfix window and the 'llwin' field is set to true for the location
list window.

In this patch I also made some other minor changes. Updated the
help text for getwinfo() and gettabinfo() to alphabetically sort the
field names. Used the FOR_ALL_BUFFERS() and FOR_ALL_TABPAGES()
macros for walking all the buffers and tab pages in the f_getbufinfo(),
f_gettabinfo() and f_getwininfo() functions.

- Yegappan
qfwintype.diff

Bram Moolenaar

unread,
Aug 14, 2016, 11:33:15 AM8/14/16
to Yegappan Lakshmanan, vim_dev

Yegappan wrote:

> On Mon, Aug 8, 2016 at 4:37 PM, Yegappan Lakshmanan <yega...@gmail.com> wrote:
> >
> >>
> >> By the way, I remember some patches that add functions returning
> >> information about buffer/window/tabpage. It would be logical if
> >> information regarding whether given buffer contains
> >> quickfix/location/no list was included there.
> >>
> >
> > I agree. The patch to get information about a buffer/window/tab page
> > is at:
> >
> > https://github.com/vim/vim/pull/833
> >
> > The information about the quickfix/location list window/buffer can be
> > added to this patch.
> >
>
> I am attaching a patch to add two new fields to the dict returned
> by the getwininfo() function. The 'qfwin' field is set to true for the
> quickfix window and the 'llwin' field is set to true for the location
> list window.
>
> In this patch I also made some other minor changes. Updated the
> help text for getwinfo() and gettabinfo() to alphabetically sort the
> field names. Used the FOR_ALL_BUFFERS() and FOR_ALL_TABPAGES()
> macros for walking all the buffers and tab pages in the f_getbufinfo(),
> f_gettabinfo() and f_getwininfo() functions.

Thanks.

I find "qfwin" and "llwin" a bit obscure. And they always have opposite
values.

I think it would be more useful to have one flag that means the window
is a quickfix window, since that means it behaves differently. And
another flag to tell us whether it's showing quickfix errors or a
location list. Perhaps they could be named "quickfix" and "loclist"?
This reflects the value of 'buftype' and setloclist().

--
hundred-and-one symptoms of being an internet addict:
26. You check your mail. It says "no new messages." So you check it again.

Yegappan Lakshmanan

unread,
Aug 14, 2016, 8:49:58 PM8/14/16
to Bram Moolenaar, vim_dev
Hi Bram,
I am attaching an updated patch that implements the above.

- Yegappan
qfwintype.diff

Yegappan Lakshmanan

unread,
Aug 14, 2016, 10:57:48 PM8/14/16
to vim_dev
Hi,

On Sun, Aug 14, 2016 at 5:49 PM, Yegappan Lakshmanan
I am attaching an updated patch. In this patch, I have added more tests
to check for the various information returned by the getbufinfo(), getwininfo()
and gettabinfo() functions.

- Yegappan
qfwintype.diff

Bram Moolenaar

unread,
Aug 15, 2016, 4:17:13 PM8/15/16
to Yegappan Lakshmanan, vim_dev
Thanks!

--
I have a drinking problem -- I can't afford it.
Reply all
Reply to author
Forward
0 new messages