[gnu.emacs.bug] Bug in specbind

jbw@bucsb.UUCP (Joe Wells) (10/08/88)

GNU Emacs 18.52.2

There is a bug in the treatment of buffer-local-variables by
specbind() and unbind_to() in eval.c.  This bug manifests itself in
the following general situation:

(make-variable-buffer-local 'variable)
(set-buffer "foo")
(setq variable 'old-value)
(let ((variable 'new-value))
  (set-buffer "bar"))

The result is as follows:

    in buffer "foo", symbol "variable" has value 'new-value
    in buffer "bar", symbol "variable" has value 'old-value

This bug is triggered by shrink-window-if-larger-than-buffer, in
electric.el.  If the window argument to this function displays a
buffer other than the current buffer, this results in trashing the
values of buffer-read-only and buffer-file-name in both buffers.

I have not developed a fix to the general problem, as I unfortunately
lack the disk space (or permission) required to hack the C code, but
here is a short fix for shrink-window-if-larger-than-buffer, so that
it no longer triggers this bug.

Joe Wells
INTERNET: jbw%bucsf.bu.edu@bu-it.bu.edu
UUCP: ...!harvard!bu-cs!bucsf!jbw

*** electric-fix.el	Fri Oct  7 20:11:03 1988
--- /usr/gnu/dist-18.52/lisp/electric.el	Sat May 16 02:22:00 1987
***************
*** 32,39
  	  (n 0)
  	  (window-min-height 0)
  	  (buffer-read-only nil)
! 	  (modified (buffer-modified-p))
! 	  (buffer (current-buffer)))
        (unwind-protect
  	  (progn
  	    (select-window window)

--- 32,38 -----
  	  (n 0)
  	  (window-min-height 0)
  	  (buffer-read-only nil)
! 	  (modified (buffer-modified-p)))
        (unwind-protect
  	  (progn
  	    (select-window window)
***************
*** 46,54
  	(delete-region (point-min) (point))
  	(set-buffer-modified-p modified)
  	(goto-char p)
! 	(select-window w)
! 	(set-buffer buffer)))))
! 
        
  ;; This loop is the guts for non-standard modes which retain control
  ;; until some event occurs.  It is a `do-forever', the only way out is to

--- 45,52 -----
  	(delete-region (point-min) (point))
  	(set-buffer-modified-p modified)
  	(goto-char p)
! 	(select-window w)))))
!       
        
  ;; This loop is the guts for non-standard modes which retain control
  ;; until some event occurs.  It is a `do-forever', the only way out is to