From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#73005: [REGRESSION, BISECTED]: line numbers disappear when pressing `df` in evil-mode Date: Mon, 04 Nov 2024 22:50:31 +0300 Message-ID: <39782a4575a20bb496a245421e416f3439436377.camel@yandex.ru> References: <378550cb5821f2a459742bb78b960280024ee30a.camel@yandex.ru> <86a5go7o1r.fsf@gnu.org> <86frqf5zlj.fsf@gnu.org> <5a9e9405-170d-42b9-84b0-7dd7579895d9@orange.fr> <86v7za4pld.fsf@gnu.org> <8634lt5qhm.fsf@gnu.org> <5a81252802dcbb126988b85b7b15cbc4f9036fe0.camel@yandex.ru> <9d9e5323-d970-4edc-a953-32318be1cf9a@orange.fr> <86msifuopd.fsf@gnu.org> <31d2fd23-b57c-450b-8594-f74f38d2ecd9@orange.fr> <868qtzuf75.fsf@gnu.org> <50008fbe-eeac-4923-8643-f963009529c7@orange.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22938"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.54.0 Cc: 73005@debbugs.gnu.org To: David Ponce , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 04 20:52:23 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 1t837e-0005l9-Bq for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 04 Nov 2024 20:52:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t837N-00008p-05; Mon, 04 Nov 2024 14:52:05 -0500 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 1t837K-00008I-No for bug-gnu-emacs@gnu.org; Mon, 04 Nov 2024 14:52:03 -0500 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 1t837K-0006NM-FF for bug-gnu-emacs@gnu.org; Mon, 04 Nov 2024 14:52:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=T25oPYsBwdS2gN3PL/ZOxOOmIbwMz8AAV3nSsHkGwW4=; b=OAumtFa4vjG9po7SKGqnm+i8iF45CX0MoSXtmpG7+cJZ0y69xSlN6sjKimofNt4OuUcbgdJ1QlEJ/tYoNt6B621JiahmZjtg2+nFx2beME+aQkljtb3xD0zqPmv3Ljn6lE1+PELBttWnRbCaoGoDXRlakJB5/GgNySQK/yONWiz2nNQ9ufUYTLaUab8RdKbL7VN8qr1g4I5CNdV+IpUAxGh6ENhtwRxX0mMoaEbuATTnhDsD3BfwkOwtXMkYK3lqpO6WlYZ9r248SnVmuCw/6iMXh2YMN3pFl/i42laF1Oe2PXd6UJUZBl9ou01qMvJp+AGKvujBwpkrOvSoqqQo5A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t837K-0007AX-9q for bug-gnu-emacs@gnu.org; Mon, 04 Nov 2024 14:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 04 Nov 2024 19:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73005 X-GNU-PR-Package: emacs Original-Received: via spool by 73005-submit@debbugs.gnu.org id=B73005.173074987427526 (code B ref 73005); Mon, 04 Nov 2024 19:52:02 +0000 Original-Received: (at 73005) by debbugs.gnu.org; 4 Nov 2024 19:51:14 +0000 Original-Received: from localhost ([127.0.0.1]:41946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t836X-00079s-Ia for submit@debbugs.gnu.org; Mon, 04 Nov 2024 14:51:14 -0500 Original-Received: from forward502d.mail.yandex.net ([178.154.239.210]:56048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t836T-00079h-FB for 73005@debbugs.gnu.org; Mon, 04 Nov 2024 14:51:11 -0500 Original-Received: from mail-nwsmtp-smtp-production-main-24.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-24.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7c8d:0:640:44ed:0]) by forward502d.mail.yandex.net (Yandex) with ESMTPS id 1628A60E15; Mon, 4 Nov 2024 22:50:33 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-24.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id Vol4pYVOeOs0-0a6oA2oV; Mon, 04 Nov 2024 22:50:32 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1730749832; bh=T25oPYsBwdS2gN3PL/ZOxOOmIbwMz8AAV3nSsHkGwW4=; h=References:Date:In-Reply-To:Cc:To:From:Subject:Message-ID; b=JwieZTVkNRfuYwzOS5oPbCFRnmvVWa+AwlbTNjNyVDBzuncSATkknZciNBjP15Fr1 Namhfhvp2m4zipxWdO0pGys9nzhxJDr6rGzgJJ3a/tfrmmaWcmDcTaKCtoKnKTd07G Xl03ZpP9Zi4zOQ2FcUkX8alP12sCpGvt5+R1xZJY= Authentication-Results: mail-nwsmtp-smtp-production-main-24.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru In-Reply-To: <50008fbe-eeac-4923-8643-f963009529c7@orange.fr> 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:294879 Archived-At: On Mon, 2024-11-04 at 20:39 +0100, David Ponce wrote: > I forgot to reply to all. Sorry. > =C2=A0=20 > On 04/11/2024 5:38 PM, Eli Zaretskii wrote: > > > Date: Mon, 4 Nov 2024 14:58:09 +0100 > > > Cc: Hi-Angel@yandex.ru, 73005@debbugs.gnu.org > > > From: David Ponce > > >=20 > > > > > 2024-11-04=C2=A0 David Ponce=C2=A0 > > > > >=20 > > > > > * subr-x.el (string-pixel-width): Set text property > > > > > `display-line-numbers-disable' instead of changing > > > > > the > > > > > buffer-local value of `display-line-numbers'.=C2=A0 Fix > > > > > bug#73005. > > > >=20 > > > > Thanks, I will look into this when I have time.=C2=A0 It isn't > > > > urgent. > > >=20 > > > No problem for me.=C2=A0 At the same time, maybe you can shed some > > > light > > > on why initializing the local variable `display-line-numbers' in > > > the > > > work buffer interferes with the setting in other buffer?=C2=A0 I'm > > > probably > > > missing something in the current implementation. > >=20 > > Without looking at the code, my first guess would be that you > > change > > the global default value, not the buffer-local value.=C2=A0 The fact > > that > > you kill-all-local-variables might have something to do with that. >=20 > I cannot see where it could happen in the code. >=20 > However, I think I have more or less figured out what could be going > on. >=20 > `display-line-numbers' is a special variable that when changed causes > the > current buffer to be redisplayed in the current window (see frame.el > from > line 3194). >=20 > It seems that, when `string-pixels-width' sets the value of > `display-line-numbers' to nil locally in the working buffer, this > triggers > a redisplay of the buffer in the selected window, and the line > numbers to > disappear.=C2=A0 When the working buffer is later recycled and local > variables > killed, it seems that this does not trigger buffer redisplay, and the > line > numbers therefore remain disabled, as observed in the simple recipe > provided > by Konstantin. Thank you, great research! But note that problem is not triggered by setting `display-line-numbers` to nil (even though it's part of the equation). Instead it is triggered specifically by (kill-all-local- variables), and removing this call makes problem go away. > =C2=A0 If you just evaluate (setq display-line-numbers display-line- > numbers) > after Konstantin's recipe, the current buffer is redisplayed and the > line > numbers appear again, because `string-pixel-width' didn't change the > global value > of `display-line-numbers'. A more curious way to get line numbers is evaluating just `display- line-numbers`, i.e. without any modification. > If I modify `string-pixel-width' to add > `(setq display-line-numbers display-line-numbers)' before to return > the result, > line numbers are not deactivated: >=20 > (defun string-pixel-width (string &optional buffer) > =C2=A0=C2=A0 "Return the width of STRING in pixels. > If BUFFER is non-nil, use the face remappings from that buffer when > determining the width. > If you call this function to measure pixel width of a string > with embedded newlines, it returns the width of the widest > substring that does not include newlines." > =C2=A0=C2=A0 (declare (important-return-value t)) > =C2=A0=C2=A0 (if (zerop (length string)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0 > =C2=A0=C2=A0=C2=A0=C2=A0 ;; Keeping a work buffer around is more efficien= t than creating > a > =C2=A0=C2=A0=C2=A0=C2=A0 ;; new temporary buffer. > =C2=A0=C2=A0=C2=A0=C2=A0 (prog1 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (with-work-buffer > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; If `display-line-numbers' is enab= led in internal > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; buffers (e.g. globally), it break= s width calculation > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; (bug#59311).=C2=A0 Disable `line-= prefix' and `wrap-prefix', > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; for the same reason. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq display-line-numbers nil > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = line-prefix nil wrap-prefix nil) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if buffer > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq-local = face-remapping-alist > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (with-current-= buffer buffer > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fa= ce-remapping-alist)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (kill-local-variable 'fa= ce-remapping-alist)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; Avoid deactivating the region as = side effect. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let (deactivate-mark) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (insert string)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; Prefer `remove-text-properties' t= o `propertize' to avoid > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; creating a new string on each cal= l. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (remove-text-properties > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (point-min) (point-max) '(line= -prefix nil wrap-prefix nil)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (car (buffer-text-pixel-size nil nil= t))) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq display-line-numbers display-l= ine-numbers)))) >=20 > However, using the `display-line-numbers-disable' property to > temporarily > disable line numbers in `string-pixels-width', without involving > redisplay, > seems a better approach to me. >=20 > Regarding Konstantin recipe, `string-pixel-width' is called by `tab- > bar-auto-width' > when (lookup-key global-map [tab-bar]) is evaluated. >=20 > Thanks