To: Ron Aaron <[email protected]>
cc: VIM Developers List <[email protected]>
Subject: patch 5.4n.17 (was: BUG: (5.4m,n) bogus 'buffer-variable' behaviour)
In-Reply-To: <Pine.LNX.4.10.9907070740220.2392-100000@rontosh.internal.mossbayeng.com>

Ron Aaron wrote:

> I'm  sorry.   It's documented, but it seems wrong that a buffer I just
> created and didn't delete has lost settings I set in it!  I normally
> do have 'hidden' set, but in this case I didn't ... and was rudely
> informed my buffer-variables were nonexistant!
>
> Please consider whether this is really the correct thing to do.

Well, what can we compare this with?  When the buffer is unloaded, the text
and undo information is removed.  The option values and marks remain.  Hmm, I
suppose local buffer variables are closest to options.  Ok, let's keep local
buffer variables when the buffer is unloaded.  Only free them when the buffer
is deleted.


Patch 5.4n.17
Problem:    Local buffer variables were freed when the buffer is unloaded.
           That's not logical, since options are not freed. (Ron Aaron)
Solution:   Free local buffer variables only when deleting the buffer.
Files:      src/buffer.c


*** ../vim-5.4n/src/buffer.c    Sun Jul  4 20:35:42 1999
--- src/buffer.c        Wed Jul  7 21:06:04 1999
***************
*** 291,299 ****
 #ifdef SYNTAX_HL
     syntax_clear(buf);                    /* reset syntax info */
 #endif
- #ifdef WANT_EVAL
-     var_clear(&buf->b_vars);      /* free all internal variables */
- #endif
 }

 /*
--- 291,296 ----
***************
*** 320,326 ****
 #ifdef HAVE_PYTHON
     python_buffer_free(buf);
 #endif
!
     free_buf_options(buf, TRUE);
     vim_free(buf);
 }
--- 317,325 ----
 #ifdef HAVE_PYTHON
     python_buffer_free(buf);
 #endif
! #ifdef WANT_EVAL
!     var_clear(&buf->b_vars);      /* free all internal variables */
! #endif
     free_buf_options(buf, TRUE);
     vim_free(buf);
 }

--
NEIL INNES PLAYED: THE FIRST SELF-DESTRUCTIVE MONK, ROBIN'S LEAST FAVORITE
                  MINSTREL, THE PAGE CRUSHED BY A RABBIT, THE OWNER OF A DUCK
                "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

--/-/---- Bram Moolenaar ---- [email protected] ---- [email protected] ---\-\--
 \ \    www.vim.org/iccf      www.moolenaar.net       www.vim.org    / /