Friday, August 30, 2013

What is the best way to distinguish the current buffer is location list or quickfix list?

Hi all,

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, 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.

the location list and qf list both could be empty or both were filled with data.


Did I miss some function/flag/variable ?


In fact I've asked the question at SO:

one answer from @romainl suggested using the variable w:quickfix_title. check if the command was beginning with ":l(L)" after I tested a little there are some cases need to be careful:

- the qf/loc list was filled by a script, (using setqflist()/setloclist()), the value of the variable would be the function name. so this could be checked too
- if user manually open an empty quickfixlist, e.g. :copen , reading the variable will throw exception. it could be ok too, because it seems that we cannot manually open an empty location list by :lopen.

- I don't know if there are other (corner) situations, will break the check.


what would be the best way to detect, which list window I am in?

thanx in advance


Kent

--
--
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/groups/opt_out.

No comments: