stefandtw / quickfix-reflector.vim

Change code right in the quickfix window
MIT License
340 stars 19 forks source link

BufReadPost autocommand not triggered after grep #14

Closed Konfekt closed 9 years ago

Konfekt commented 9 years ago

After :grep ... the quickfix window opens up and displays the results by the autocmd

  autocmd QuickFixCmdPost grep cwindow

However, the BufReadPost autocmd of quickfix-reflector is not triggered. Only after closing and reopening the quickfix window.

How about triggering the BufReadPost autocmd directly after the quickfix windows opens for the first time?

stefandtw commented 9 years ago

Try

  autocmd QuickFixCmdPost grep nested cwindow

See :h autocmd-nested

Konfekt commented 9 years ago

Thank you, that's nailed it. Has been bugging me for ages.

ronakg commented 8 years ago

I have the same issue when I'm using Ack to search across files. I need to close the quickfix window and open again using cwindow for the plugin to work.

I'm executing Ack like following -

nnoremap <Leader>vv :silent Ack! -k <cword> .<CR>

Konfekt commented 8 years ago

Does it work without silent ?

You need to know what Ack does. Is it coming from a plugin? If so, which one?

stefandtw commented 8 years ago

I could reproduce the problem using the option in your vimrc let g:ack_use_dispatch=2

So this executes ack in the background somehow. But I don't know how it actually fills the quickfix list. I'm guessing it either calls setqflist() directly or uses autocmds internally without nesting. Either of those would make it impossible for quickfix-reflector to notice a change in the quickfix list. Nothing I can do really.

The easy way to make it work is not to use the dispatch mechanism. Another option might be to find a way how you can call copen automatically after the quickfix list has been filled. This would guarantee quickfix-reflector to trigger.

Konfekt commented 8 years ago

Regarding the latter option, wouldn't autocmd QuickFixCmdPost * nested cwindow achieve that?

stefandtw commented 8 years ago

That's definitely worth a try! Maybe use copen instead of cwindow to make sure it's opened again, since the ack plugin already seems to open the quickfix window before.

ronakg commented 8 years ago

autocmd QuickFixCmdPost * nested copen

works well. Removing silent didn't help.