unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Helmut Eller <eller.helmut@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 16728@debbugs.gnu.org
Subject: bug#16728: 24.3.50; bug? (with-temp-buffer (insert "foo")) deactivates mark in current buffer
Date: Fri, 14 Feb 2014 19:12:35 +0100	[thread overview]
Message-ID: <m2a9dt7ecs.fsf@gmail.com> (raw)
In-Reply-To: <jwvioshobsv.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Fri, 14 Feb 2014 12:21:27 -0500")

On Fri, Feb 14 2014, Stefan Monnier wrote:

>>  (list (with-temp-buffer
>>         (set (make-local-variable 'deactivate-mark) nil)
>>         (insert "foo")
>>           (let (deactivate-mark)
>>             (with-temp-buffer
>>               (insert "bar"))))
>>        deactivate-mark)
>
> The `let' above dynamically binds the `deactivate-mark' of the first
> temp-buffer.  The (insert "bar") then set the deactivate-mark in the
> second temp-buffer, which did not make it buffer-local, so it really
> sets the global deactivate-mark.  Try:
>
>    (with-temp-buffer
>      (let ((a 3)
>            (buf (current-buffer)))
>        (make-local-variable 'a)
>        (let ((a 4))
>          (with-temp-buffer
>            (message "a=%S but a=%S" (list a (local-variable-p 'a))
>                                     (with-current-buffer buf
>                                       (list a (local-variable-p 'a))))))))
>
> Interaction between let-bindings and buffer-local bindings is tricky.

This prints "a=(3 nil) but a=(4 t)". "a=(4 nil) but a=(3 t)" would be
less surprising.

Why is it this way?  This behavior of let seems non-intuitive and
rather useless to me.  I don't suppose that there is a variant of let
that does what I want?

Helmut





      reply	other threads:[~2014-02-14 18:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12  8:53 bug#16728: 24.3.50; bug? (with-temp-buffer (insert "foo")) deactivates mark in current buffer Oleh
2014-02-12 11:54 ` Helmut Eller
2014-02-14 17:21   ` Stefan Monnier
2014-02-14 18:12     ` Helmut Eller [this message]

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=m2a9dt7ecs.fsf@gmail.com \
    --to=eller.helmut@gmail.com \
    --cc=16728@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).