Re: vimgrep and bufread* autocommands
- Hi Ben!
On Do, 09 Feb 2012, Ben Fritz wrote:
> On Feb 9, 5:57 am, scrooloose <martin.grenf...@...> wrote:
> > Gentlemen, Im having some issues with vimgrep and an autocommand that
> > is defined on bufreadpost.
> > I dont want my autocmd to fire while vimgrep is running, but that is
> > what is currently happening since vimgrep opens every file it scans
> > into a vim buffer. I would have thought vim would disable autocommands
> > when running vimgrep for efficiency, but apparently not!
> > The short story is that I want an autocommand definition like this:
> > autocmd bufreadpost * if VimgrepIsNotRunning() | echo 'foo' | endif
> > So far my only idea is to add a couple more autocommands on
> > QuickFixCmdPre and QuickFixCmdPost to set a magic flag to say that a
> > quickfix command is running. That would probably work, but I can also
> > see it causing more bugs, and its a pretty crap solution in general.
> > Any suggestions would be welcome :)
> > FYI, this issue came to light in this bug report in syntastic -https://github.com/scrooloose/syntastic/issues/161
> I was going to suggest using :noautocmd to perform the vimgrep, but
> then I saw that you're trying to fix a plugin to let the user
> use :vimgrep normally.
> IIUC, autocmds are not disabled when running vimgrep, in order to
> allow things like reading Zip files, detecting file encoding when
> Vim's built-in detection fails, and the like, which are frequently
> accomplished in BufReadPre/BufReadPost autocmds.
> I actually think your idea of using QuickFixCmdPre/Post may be your
> best option.
I thought so too. May be, it would be a good idea, to have yet another
v: variable, that is set to whatever autocommand is triggered or empty
if there is none. May be even a second one, so one could match the
pattern as well.
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