From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 74091-done@debbugs.gnu.org
Subject: bug#74091: 31.0.50; string-pixel-width in mode line disables region
Date: Thu, 31 Oct 2024 12:09:20 +0100 [thread overview]
Message-ID: <m11pzwplzz.fsf@macbookpro.home> (raw)
In-Reply-To: <86ldy54m2g.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 30 Oct 2024 18:01:11 +0200")
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Eshel Yaron <me@eshelyaron.com>
>> Cc: 74091@debbugs.gnu.org
>> Date: Wed, 30 Oct 2024 16:26:38 +0100
>>
>> >> At this point the region is expected to be active since we activated it
>> >> in step 4. But in step 5 the mode line is updated, which calls
>> >> string-pixel-width, which in turn unexpectedly disables the region.
>> >
>> > Thanks, should be fixed now.
>>
>> Great! That seems to work.
>
> Thanks for testing, I will close this bug.
Since we don't fully understand the issue, it may manifest in more ways.
So I think closing the bug is premature.
After looking a bit more into it, it seems like the problem has to do
with the call to kill-all-local-variables in work-buffer--release, the
following patch circumvents the unexpected behavior, although I still
don't understand why:
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 5b47deb880e..b5cbe28afad 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -361,7 +361,7 @@ work-buffer--release
(erase-buffer))
(delete-all-overlays)
(let (change-major-mode-hook)
- (kill-all-local-variables t))
+ (kill-all-local-variables))
;; Make the buffer available again.
(push buffer work-buffer--list)))
;; If the maximum number of reusable work buffers is exceeded, kill
Here's another interesting data point:
--8<---------------cut here---------------start------------->8---
(defun foo ()
(interactive)
(with-current-buffer (get-buffer-create "some-buffer")
(kill-all-local-variables t)
(insert "foo")))
--8<---------------cut here---------------end--------------->8---
Invoking this command twice in a row in subr.el deactivates the region,
while the same without the argument to kill-all-local-variables keeps
the region active.
So the problem seems to be in a lower level than string-pixel-width...
>> >> I'm not really sure why this happens...
>> >
>> > It happens because string-pixel-width modifies a buffer, and that sets
>> > deactivate-mark, which then causes the region to be deactivated when
>> > a command finishes.
>>
>> Hmm but string-pixel-width used to modify a buffer also in the old
>> implementation, and that never caused this issue...
>
> The new implementation also didn't cause this issue in some buffers.
> For example, in *scratch*. Trying to understand the logic of a bug is
> never a good investment of time.
:)
As I'm sure you know, applying a crude fix without fully understanding
the problem is likely to hide other subtle bugs that may then be harder
to investigate.
>> And in both the old
>> implementation and in the new one, the modification is in a different
>> buffer, is that expected to disable the mark in the original buffer?
>
> The variable deactivate-mark only becomes buffer-local if set;
> otherwise the global value will be changed.
Could you perhaps elaborate? I see that running a command that modifies
a different buffer does not deactivate the region in the current buffer,
which is basically what I would expect.
Best,
Eshel
next prev parent reply other threads:[~2024-10-31 11:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-29 17:27 bug#74091: 31.0.50; string-pixel-width in mode line disables region Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-30 14:59 ` Eli Zaretskii
2024-10-30 15:26 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-30 16:01 ` Eli Zaretskii
2024-10-31 11:09 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-10-31 11:41 ` Eli Zaretskii
2024-10-31 12:24 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-31 14:35 ` Eli Zaretskii
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m11pzwplzz.fsf@macbookpro.home \
--to=bug-gnu-emacs@gnu.org \
--cc=74091-done@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=me@eshelyaron.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.