Fwd: Re: local autocommand
- I meant to send this mail to the group, hit reply instead of reply all.
--- Hari Krishna Dara <hari_vim@...> wrote:
> Date: Fri, 27 Sep 2002 12:14:38 -0700 (PDT)__________________________________________________
> From: Hari Krishna Dara <hari_vim@...>
> Subject: Re: local autocommand
> To: kaminsky@...
> --- Moshe Kaminsky <kaminsky@...> wrote:
> > Hi,
> > I would like a certain command to be executed before I close the buffer
> > (say, on the BufUnload au event), but only for this buffer (or actually
> > for this file type). The problem is that if I define an autocommand,
> > even inside the ftplugin, it is global and will take place from now on
> > for every buffer I close (I can't identify the file by a pattern). What
> > I need is a local autocommand. Is there something like this, or is there
> > some other way to do this?
> > Thanks,
> > Moshe
> There is nothing like a local autocommand, but you can easily work-around by
> disabling the autocommands for those buffers that you are not interested,
> a buffer local variable.
> aug MyGroup
> au BufUnload <file pattern> call <SID>DoSomething()
> aug! END
> " Assumes that the current buffer is the buffer that you are interested in.
> let b:doSomethingActive = 1
> function! s:DoSomething()
> if !exists("b:doSomethingActive") || ! b:doSomethingActive
> " Really do something.
> " If the autocommand should apply only once, optionally clear the buffer
> " variable.
> unlet b:doSomethingActive
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!