🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99177

Problem with let and buffer-local variables

#99177
From: David Gillespie
Date: Wed, 17 Oct 1990 07:10
26 lines
1511 bytes
I don't know if this has been mentioned before, but it cropped up for
me recently.

If a Lisp program switches buffers while inside a "let" form that binds
a variable that was buffer-local in the original buffer, the variable
is restored in the wrong buffer:

	(set-buffer "b")
	(setq foo 'b)
	(set-buffer "a")
	(make-local-variable 'foo)
	(setq foo 'a)
	(let ((foo 'temp))
	  foo   => 'temp
	  (set-buffer "b")
	  foo   => 'b   ; This is questionable; I'd prefer to see 'temp still.
	)
	foo  => 'a      ; Wrong!  We see buffer a's local value in buffer b.
	(set-buffer "a")
	foo  => 'temp   ; Wrong!  This temporary value should be gone now.

The solution is to switch back to the original buffer before leaving the
"let".  For maximum safety, use "save-excursion" immediately inside the
"let".

								-- Dave
Technical Details
Message-ID: <9010170710.AA22897@csvax.cs.caltech.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!wuarchive!cs.utexas.edu!tut.cis.ohio-state.edu!CSVAX.CS.CALTECH.EDU!daveg

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,410681a0470e8b86,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-10-17 00:10:18 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!wuarchive!cs.utexas.edu!tut.cis.ohio-state.edu!CSVAX.CS.CALTECH.EDU!daveg
From: daveg@CSVAX.CS.CALTECH.EDU (David Gillespie)
Newsgroups: gnu.emacs.bug
Subject: Problem with let and buffer-local variables
Message-ID: <9010170710.AA22897@csvax.cs.caltech.edu>
Date: 17 Oct 90 07:10:18 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 26
Approved: bug-gnu-emacs@prep.ai.mit.edu
Posted: Wed Oct 17 08:10:18 1990