I have an autocmd, if ft
is qf
, it is gonna call some functions to modify the quickfix list by get/setqflist()
I know there are another pair of functions get/setloclist()
, to handle the location list.
My problem is, how to know if the current buffer is qf-list
or location-list
(They both have filetype
qf
) so that I know which functions should be called?
so far what I can think of is, assume both loc and qf lists are not empty, do some change on qf-list, and compare with current buffer, if the current buffer is changed too, it is qf-list, otherwise it should be location list. Finally roll back the changes. But I feel it is stupid... there should be better way to make the decision.
Did I miss some function/flag/variable ?
Just for new comers: as of now, there is getwininfo()
which returns dicts containing key quickfix
which can be used for the check. Also note the loclist
key.
Since getwininfo
returns a list of dict, you may use:
getwininfo(win_getid())[0]['quickfix']
which is 1 when it is a quickfix or location list window. And
getwininfo(win_getid())[0]['loclist']
which is 1 only when it is a location list.
The w:quickfix_title
variable tells you what command was used to generate the list displayed in the window. If the first letter after the colon is an l
you are in location list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With