scrooloose | 9 Feb 12:57

vimgrep and bufread* autocommands

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

--

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

Ben Fritz | 9 Feb 20:47

Re: vimgrep and bufread* autocommands


On Feb 9, 5:57 am, scrooloose <martin.grenf...@gmail.com> 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
(Continue reading)

Christian Brabandt | 9 Feb 22:49

Re: vimgrep and bufread* autocommands

Hi Ben!

On Do, 09 Feb 2012, Ben Fritz wrote:

> On Feb 9, 5:57 am, scrooloose <martin.grenf...@gmail.com> 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.
> 
(Continue reading)


Gmane