From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74091: 31.0.50; string-pixel-width in mode line disables region Date: Wed, 30 Oct 2024 16:59:49 +0200 Message-ID: <86y1254owq.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36724"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74091@debbugs.gnu.org To: Eshel Yaron Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 30 16:00:39 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 1t6ABb-0009Mi-6T for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Oct 2024 16:00:39 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6AB8-0000By-Ot; Wed, 30 Oct 2024 11:00:11 -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 1t6AB2-0000BZ-2z for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2024 11:00:04 -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 1t6AB1-00076Y-KQ for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2024 11:00:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=optbKjRTKQttxQYger8nwd/L1td97vD2dRHPt1QiyJM=; b=nL4XMdmAEWRAB49PZlFV2RywTGGrNUOylfb9pcDjoaaIAkUzAJ3goqrzDKVOQxuMn9QSsCa1tKSwkeysbj1U79wsuCtXtwxoObuzHdTMm/11pfoeULHZu5Bu0qw7IxAXjsF7Z2Xg1wXZqo6Fuo+0Ih83BU0hCJxCsdF89w+Y2hDYOMrwTauFou+Tb2cBKnxe4iNbfJRi6f0b+EGLg1KkmU9MxveBOkL6tgWsbnvebyArJTIKOKiKd8mrKHqJCI+4z8vWzs+nAf9oKeIiubpsSBzNXpHSm6Aqb+DzilJsJUT02FwVowV7BtT61shFp6/fopstuisskP9Egl2a1pKFTQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6AB1-0004rK-7s for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2024 11:00:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Oct 2024 15:00:03 +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-submit@debbugs.gnu.org id=B74091.173030040018643 (code B ref 74091); Wed, 30 Oct 2024 15:00:03 +0000 Original-Received: (at 74091) by debbugs.gnu.org; 30 Oct 2024 15:00:00 +0000 Original-Received: from localhost ([127.0.0.1]:35512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6AAy-0004qd-DD for submit@debbugs.gnu.org; Wed, 30 Oct 2024 11:00:00 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:56754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6AAw-0004qX-3s for 74091@debbugs.gnu.org; Wed, 30 Oct 2024 10:59:58 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6AAq-0006xX-DY; Wed, 30 Oct 2024 10:59:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=optbKjRTKQttxQYger8nwd/L1td97vD2dRHPt1QiyJM=; b=Mw0X8RS+iM5g 5iH3G3IQ18DqUq7/AE8WYI7mFXdFu4NI0+GPm9lE1bsIOnn7lm+F1dGogu+zM2lZ3rHPDFWtGLhGD cm3Xgrak8NpaIE3pW1nZn3fjkjpjke+HTI9vzKKtH85P8Ym/UfAAFWIDo3TXsLXSQqmVQVBflU1+7 Wm2B1LZPiuQV5Mygxzd3FgV0m4HXGAgBmQkFfyogs6QVr/zFSjQ2OzszE7zCxNs/G4Dz3UzQU3IKd 9Op6JqIa/R7Zg2VPC+XnIbf6a5oqMyDQypwWRQF8lqBlwlnow1wCKDJgZcM239QiyGx42xFd9T1z7 zsomVecDLxnIKD41dzajLw==; In-Reply-To: (bug-gnu-emacs@gnu.org) 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:294561 Archived-At: > Date: Tue, 29 Oct 2024 18:27:05 +0100 > From: Eshel Yaron via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > > The new implementation of string-pixel-width has some unexpected effect > when it is called from mode-line-format, as happens for example when > mode-line-format-right-align occurs in mode-line-format: > > 1. emacs -Q > 2. (setq-default mode-line-format > '("" (:eval (progn (string-pixel-width "foo") nil)))) > 3. C-x C-f /path/to/emacs/lisp/subr.el > 4. C-SPC > 5. C-n > > 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. > 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. When you inject string-pixel-width into mode-line-format, you indirectly cause it to be called from C-n and the like, because those evaluate the mode-line format. So doing that is quite a risky thing, in general.