[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16728: 24.3.50; bug? (with-temp-buffer (insert "foo")) deactivates m
From: |
Helmut Eller |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
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