From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74091: 31.0.50; string-pixel-width in mode line disables region Date: Thu, 31 Oct 2024 12:09:20 +0100 Message-ID: References: <86y1254owq.fsf@gnu.org> <86ldy54m2g.fsf@gnu.org> Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3436"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74091-done@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 31 12:10:22 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t6T4I-0000jU-49 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 31 Oct 2024 12:10:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6T3z-0004cJ-HO; Thu, 31 Oct 2024 07:10:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6T3y-0004c7-GA for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 07:10:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t6T3y-0003Dn-3h for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 07:10:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=08zPeG7NxCBM2RdAdNoNCUWFGYkI+Sdk7iBMBBjX9QE=; b=Cc1BzDN5ZzrFzol1y+B1Go5uA5m4DipSNn2MsQayRo9pPLot28To01TB4zsHJCkOKf7URd3Py3Zz9UMhVoR1TPeh7aiQIN8jdELXjLwipNRqGj9aHWmqhI/rpy2Ufb+BPvgpK4vN6f4LyZm2okW8NdbAko0DH2Z0100vJdV6reTMOmuMavY2eJiJdkFkusm2dTf0arc/47dRuG1k4CbF96Rz+tS8qL9gUNrTGfpbpkF4lnAogUwqLK94jouPW+AcXv6odx+aEPLuvxVWt7baM4YzGBIg1Zk9e8MtCqjrD3q4CtX1MNhBgB/yGOpd9eyDSxhgCSfe7EK3ShjwEuof6Q==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6T3x-0004Fo-VI for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 07:10:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Oct 2024 11:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74091 X-GNU-PR-Package: emacs Original-Received: via spool by 74091-done@debbugs.gnu.org id=D74091.173037296616309 (code D ref 74091); Thu, 31 Oct 2024 11:10:01 +0000 Original-Received: (at 74091-done) by debbugs.gnu.org; 31 Oct 2024 11:09:26 +0000 Original-Received: from localhost ([127.0.0.1]:41661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6T3N-0004Ez-NM for submit@debbugs.gnu.org; Thu, 31 Oct 2024 07:09:26 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:46426 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6T3L-0004En-Ij for 74091-done@debbugs.gnu.org; Thu, 31 Oct 2024 07:09:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1730372963; bh=TRym44UnC+qVCurLZ+wiM3PqKLhUtwbZZxF4Bz0ulL4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Tqzute+5VO7+LahDb/SxA+Rj6MKSPuzduEs6Y5ZPHaiD7AmFSTdHbDJN+qUaVPvmB oQ1RfhcMTOwd2i566EJm5gkVz6qCaRW/i4o1uKNKFj2sxO6aMGzhEqDQZWdXm13t27 w5IOJhskkbfXHcQDQnKfI+lE5g5KJCGoGHWoB/5rsTKmdxYxbnyBClbWMTQL1jJvnM GQlUZGDlKibLMTYdiL3RkNbZS7kVXb469ronMO3ba8u/P7icO2g3YCtbkvoCP/fCLr N11CWneUnD8vDUfbSLP7MwbrISpnklhUYoNE8WUIXeNS9IG5b3e1Y1sipgN0ZLyTtH 9X4hVQvlsSpZw== In-Reply-To: <86ldy54m2g.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 30 Oct 2024 18:01:11 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:294618 Archived-At: Eli Zaretskii writes: >> From: Eshel Yaron >> 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