unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org,  Dave Pearson <davep.news@davep.org>,
	Gareth Owen <usenet@gwowen.freeserve.co.uk>
Subject: Re: let vs. buffer local bindings
Date: 11 May 2002 00:14:44 +0200	[thread overview]
Message-ID: <5xlmard50r.fsf@kfs2.cua.dk> (raw)
In-Reply-To: <200205101915.g4AJFSk21990@rum.cs.yale.edu>

"Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:

> > Gareth Owen <usenet@gwowen.freeserve.co.uk> 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 <storm@cua.dk> http://www.cua.dk

  reply	other threads:[~2002-05-10 22:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-10 14:21 let vs. buffer local bindings Kim F. Storm
2002-05-10 13:22 ` Gareth Owen
2002-05-10 13:48   ` Dave Pearson
2002-05-10 14:53   ` Kim F. Storm
2002-05-10 13:32 ` Andreas Schwab
2002-05-10 15:31   ` Kim F. Storm
2002-05-10 19:15 ` Stefan Monnier
2002-05-10 22:14   ` Kim F. Storm [this message]
2002-05-12 16:34     ` Richard Stallman
2002-05-13 20:07       ` Kim F. Storm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5xlmard50r.fsf@kfs2.cua.dk \
    --to=storm@cua.dk \
    --cc=davep.news@davep.org \
    --cc=emacs-devel@gnu.org \
    --cc=usenet@gwowen.freeserve.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).