59633RE: When do buffer variables become undefined?
- Jun 3, 2005That's something to check out. I've got a lot of autocommands, and I'm
jumping between buffers a lot. I'm beginning to wonder if is has something
to with the behaviour of
BufHidden Just after a buffer has become hidden. That
NOTE: When this autocommand is executed, the
current buffer "%" may be different from the
buffer being unloaded "<afile>".
which is also true for bufunload, bufdelete, etc. I guess I need to
understand exactly when 'current buffer "%" may be different' from
what I'm expecting.
--- David Fishburn <fishburn@...> wrote:
> > -----Original Message-----
> > From: Hari Krishna Dara [mailto:hari_vim@...]
> > Sent: Thursday, June 02, 2005 1:38 PM
> > To: Eric Arnold
> > Cc: vim@...
> > Subject: Re: When do buffer variables become undefined?
> > On Wed, 1 Jun 2005 at 10:03pm, Eric Arnold wrote:
> > > As I understand it, buffer variables are local and
> > persistent to each
> > > Vim buffer in which the script is executed, so once defined, they
> > > should be valid until the buffer is unloaded/deleted/wiped.
> > > I have a couple of functions like:
> > >
> > >
> > > It usually works fine, but there is some rare case I can't
> > track down
> > > where I get an error saying that b:restore_cmdheight is
> > not defined.
> > > When I restart the process, without quitting, the error is
> > gone. At
> > > first glance, it doesn't seem possible, since the init function is
> > > called a few lines before the variable is referenced. I think it
> > > might have something to do with re-"source"ing the file a
> > few times,
> > > but I can't make it happen at will.
> > I use buffer variables too but never observed this problem.
> > The only reason I can think of is that your script
> > temporarily jumps to a different buffer in the same window or
> > in a different window (which doesn't have the variable
> > defined) when the code gets executed and that is what is
> > causing the error. Put some :echomsg or :Decho (using
> > Dr.Chip's plugin) calls with the current buffer number right
> > before using the buffer variable in the problem area, and
> > verify that you are actually in the right buffer.
> Yes, I had a similar issue in the past which took sometime to figure out.
> Turned out one of my own autocmds was changing buffers and didn't change it
> back at the end of the function.
- << Previous post in topic Next post in topic >>