Monday, February 6, 2012

Re: folding quickfix list based on the command which created it

On 11:33 Mon 06 Feb , Ben Fritz wrote:
> I am trying to make a quickfix folding solution for my Vim config,
> which does something different based on what command created the
> quickfix list.
>
> Currently, I'm folding all results from the same file together for the
> various 'grep' commands, and I'm folding away all but errors and
> warnings for compiler commands.
>
> But I'm not happy with my detection of the command which created the
> quickfix window.
>
> I've tried using w:quickfix_title, but I have discovered this variable
> does not get set until sometime after the filetype autocmd fires. So,
> I've needed to set up my foldexpr to check the w:quickfix_title
> variable every single time its invoked to determine which behavior to
> use. Additionally, in order to apply the proper method initially, I
> needed to create a BufWinEnter autocmd which will do :let
> &foldexpr=&foldexpr to re-calculate all the folds on a quickfix
> window, since the w:quickfix_title variable is not defined when the
> filetype plugin fires.
>
> So my first question is, is there a better way to detect the command
> or command type which set the quickfix list?
>
> My next problem, is that I use a couple plugins which set up the
> quickfix list themselves, using the setqflist() function. For these
> quickfix lists, w:quickfix_title is not set at all! And, I'm not
> certain how a plugin could accomplish setting this variable, if after
> setting the quickfix list in the plugin, the user just uses the
> normal :copen, :cclose, etc. commands to manipulate the quickfix
> window. I note that the w:quickfix_title variable is restored when
> using :colder and :cnewer, so it has to be stored somewhere and
> associated with the list it belongs to.
>
> So my next question is, is there a way to associate a w:quickfix_title
> with a given quickfix list created with the setqflist() function?
>
> --
> 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

Hi,

I have a suggestion for the first problem: you can try QuickFixCmdPost.

I was trying to do a similar thing: to filter quick fix list when user issues
:cgetfile. I came up with a patch, which adds an autocommand-event, well there
is one for that: QuickFixCmdPre (and QuickFixCmdPost) (it was not handling
:cgetfile), but it does the job for :grep (which you mentioned). If you are
interested I can send you the patch.

Best,
Marcin

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

No comments: