[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: let vs. buffer local bindings
From: |
Kim F. Storm |
Subject: |
Re: let vs. buffer local bindings |
Date: |
11 May 2002 00:14:44 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50 |
"Stefan Monnier" <monnier+gnu/address@hidden> writes:
> > Gareth Owen <address@hidden> has found a peculiar
> > interference between let and buffer local bindings.
>
> Gerd has fixed one of the bad interactions between buffer-local and let-bound
> variables, but we can't fix them all. Or at least, I think that fixing
> them such that there's a clear semantics will mean changing the current
> semantics in a way that would break compatibility.
Thanks Stefan.
I understand what's going on now.
Considering that Gerd's fix has indeed improved emacs's behaviour in
this area, I think we need to change the elisp manual to reflect this.
Specifically, the following warning:
*Warning:* When a variable has buffer-local values in one or more
buffers, you can get Emacs very confused by binding the variable with
`let', changing to a different current buffer in which a different
binding is in effect, and then exiting the `let'. This can scramble
the values of the buffer-local and default bindings.
should be reworded into something less dramatic, e.g.
*Warning:* When a variable has buffer-local values in one or
more buffers, binding the variable with `let' and changing to a
different current buffer in which a different binding is in
effect, and then exiting the `let', the variable may not be
restored to the value it had before the let.
Also, the example illustrating this is no longer valid, as the value of foo
is correct when we return to buffer "a", ie. the example should read:
(setq foo 'b)
(set-buffer "a")
(make-local-variable 'foo)
(setq foo 'a)
(let ((foo 'temp))
;; foo => 'temp ; let binding in buffer "a"
(set-buffer "b")
;; foo => 'b ; the global value since foo is not local in "b"
BODY...)
foo => 'b ; we are still in buffer "b", but exiting the let
; restored the local value in buffer "a"
(set-buffer "a") ; which can be seen here:
foo => 'a ; we are back to the local value in buffer "a"
--
Kim F. Storm <address@hidden> http://www.cua.dk