[Fwd: Re: When do buffer variables become undefined?]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Fwd: Re: When do buffer variables become undefined?]

A.J.Mechelynck
The message below was sent to me privately. The only answer I can give
is "if we had the full text of the incriminated vim script, we might
attempt to poke holes in it". Better ideas, anyone?


Best regards,
Tony.



-------- Original Message --------
Subject: Re: When do buffer variables become undefined?
Date: Wed, 1 Jun 2005 23:38:20 -0700 (PDT)
From: Eric Arnold <[hidden email]>
To: A. J. Mechelynck <[hidden email]>



--- "A. J. Mechelynck" <[hidden email]> wrote:

> 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:
> >
> > function! s:Init_buffer_variables()
> > if exists( 'b:initialized_RH_buf_vars' )
> > return
> > endif
> > let b:initialized_RH_buf_vars = 1
> > ...

Rats.  I messed up a last minute edit.  The following belongs
in the   s:Restore_origin_window()  script,

> >        if b:restore_cmdheight > 0
> >        let &cmdheight = b:restore_cmdheight
> >        endif
> > ...

where actual line is a simple "let":

        let b:restore_cmdheight = -1



> > endfunction
> >
> > ... do lots of stuff, including setting   b:restore_cmdheight ...
> >
> > function! s:Restore_origin_window()
> > call s:Init_buffer_variables()
> > ...

         if b:restore_cmdheight > 0
         let &cmdheight = b:restore_cmdheight
         endif

> > endfunction
> >
> > 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.
> >
>
> The above omits the part where b:restore_cmdheight is created; we see
> s:Init_buffer_variables() called from s:Restore_origin_window() but we
> don't see where s:Restore_origin_window() is called.
>
> See ":help debug-scripts" about finding out what happens within Vim,
> what is executed by sourced scripts, etc.

The problem is that the error only occurs spontaneously every few days, so
trying to catch it in the debugger isn't practical.  When I try to back
track what I did, I can never get it to happen again.  I'm trying to come
up with some hypothesis with which to attack it, the only way I know of
dealing with long-intermittent bugs.

At this point, I could release the script with a caveat that says "you might
see this error every now and then, ignore it", but ... yuck.






Loading...