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 18:01:11 +0200 Message-ID: <86ldy54m2g.fsf@gnu.org> References: <86y1254owq.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39480"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74091-done@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 17:04:20 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 1t6BBE-000A6T-Be for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Oct 2024 17:04:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B95-0004en-47; Wed, 30 Oct 2024 12:02:07 -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 1t6B91-0004Xt-Gv for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2024 12:02:03 -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 1t6B91-0008U9-7Q for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2024 12:02: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=ojaqy+ho3o4JZ2/xPmk/KTPi8b9fAYJ21flVNm8TEno=; b=n571cRvC2j47jdtNqgOJctJZs3j3qoKbhfpuOzjcfEz0rGUuinpJZ+fQzaAFKwnTTRhE2YD/px5b4iKbvK+zS02nwBJLmfwN/ds9WA99sok7A57sFhEh+OlK6WKt5pYluYo/KpH9K4IHXRLfJzp20S8BEc72PScOUIuIm8phklZZ9puonsTwLzB7pBRlIGHg2n2svM6XVrcRAAlsnjmHYB5GeGkh8QU+0F4j/EngCoZMW3T2ouCDTxHWhBNTZPm/CsaNoWBTqEkLERxbvzgwPa2+23io709Y7Jj99PmU+rnMs/dQHfODq1FoLlNQEcXKjzKLlfuWrjFZ8gw9EnQlKA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6B90-00079q-S6 for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2024 12:02:02 -0400 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Oct 2024 16:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 74091 X-GNU-PR-Package: emacs Mail-Followup-To: 74091@debbugs.gnu.org, eliz@gnu.org, me@eshelyaron.com Original-Received: via spool by 74091-done@debbugs.gnu.org id=D74091.173030408327470 (code D ref 74091); Wed, 30 Oct 2024 16:02:02 +0000 Original-Received: (at 74091-done) by debbugs.gnu.org; 30 Oct 2024 16:01:23 +0000 Original-Received: from localhost ([127.0.0.1]:35869 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6B8N-00078z-5K for submit@debbugs.gnu.org; Wed, 30 Oct 2024 12:01:23 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41962) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6B8K-00078s-Cx for 74091-done@debbugs.gnu.org; Wed, 30 Oct 2024 12:01:22 -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 1t6B8E-0008Pl-R1; Wed, 30 Oct 2024 12:01:14 -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=ojaqy+ho3o4JZ2/xPmk/KTPi8b9fAYJ21flVNm8TEno=; b=LS1pcVbnAHyT mQHyjJX6BOEmHw9UTa4OGbAC6UfukURILFtTMD6kcZ0kDU4qrHb3l5BFctekbdtq4inJgLPjr0AOI ytDLDzhPT3DRcvlevePpNSnTPSfSa+vHYoBj5vLgxqOZvOkas89eJnu/ZfKxQ9ctq22fWtNl4Rqhg 43FmRsCqdAFWO4NuAmR+2mfpEJp/rwGtsKIo1I4I0iRw72Odc2blR2abVsx19GT8cJ+82rhzrEeDA K1OEePhdy9bnVk7nqjZu7/Fkz1RGl6BKsxatrLJgKJjtTbjqAyzftzmj53Bor+kAaUlr0BxtQFjD5 gEHwtdWkxxTcNRrwB6ojpw==; In-Reply-To: (message from Eshel Yaron on Wed, 30 Oct 2024 16:26:38 +0100) 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:294570 Archived-At: > 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. > >> 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. > 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. > > 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. > > Well, that's how Emacs implements mode-line-format-right-align :) One reason why I don't like it. mode-line-format is evaluated in many more contexts than most people realize, so putting arbitrary calls there without a good understanding what those calls do and how is not the best idea, although it will mostly work.