From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers Date: Sun, 20 Nov 2022 10:20:40 +0200 Organization: LINKOV.NET Message-ID: <86r0xyvxmr.fsf@mail.linkov.net> References: <86v8ncdbk1.fsf@mail.linkov.net> <83v8ncbqly.fsf@gnu.org> <86o7t292y3.fsf@mail.linkov.net> <83mt8m7mmq.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20231"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 59311@debbugs.gnu.org, gabriel376@hotmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 20 09:30:21 2022 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 1owfiW-00053v-7w for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Nov 2022 09:30:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owfiI-0006ms-PU; Sun, 20 Nov 2022 03:30:06 -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 1owfiE-0006mZ-QP for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 03:30:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1owfiE-0006u7-GR for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 03:30:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1owfiE-00032J-Cz for bug-gnu-emacs@gnu.org; Sun, 20 Nov 2022 03:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Nov 2022 08:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59311 X-GNU-PR-Package: emacs Original-Received: via spool by 59311-submit@debbugs.gnu.org id=B59311.166893295411593 (code B ref 59311); Sun, 20 Nov 2022 08:30:02 +0000 Original-Received: (at 59311) by debbugs.gnu.org; 20 Nov 2022 08:29:14 +0000 Original-Received: from localhost ([127.0.0.1]:42315 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owfhR-00030u-Si for submit@debbugs.gnu.org; Sun, 20 Nov 2022 03:29:14 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:60071) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owfhM-00030Q-A6 for 59311@debbugs.gnu.org; Sun, 20 Nov 2022 03:29:11 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 42F55FF805; Sun, 20 Nov 2022 08:28:59 +0000 (UTC) In-Reply-To: <83mt8m7mmq.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 19 Nov 2022 21:46:53 +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:248404 Archived-At: --=-=-= Content-Type: text/plain >> >> @@ -322,6 +322,8 @@ string-pixel-width >> >> (with-current-buffer (get-buffer-create " *string-pixel-width*") >> >> + (when display-line-numbers-mode >> >> + (display-line-numbers-mode -1)) >> >> (delete-region (point-min) (point-max)) >> >> (insert string) >> >> (car (buffer-text-pixel-size nil nil t))))) >> > >> > Yes. Or subtract what (line-number-display-width t) returns (it will >> > return zero when line-numbers are turned OFF). >> >> Shouldn't then buffer-text-pixel-size subtract line-number-display-width? >> Isn't this the responsibility of buffer-text-pixel-size, >> not responsibility of a caller like string-pixel-width? > > No, because line-numbers take space, and some use cases of > buffer-text-pixel-size want to know that. Only the caller knows whether the > line-numbers should or shouldn't be included. The principle is that we > measure the space taken in the text-area, no matter how it is used. (There > are other display features that affect the result, for example, > line-prefix.) I still don't understand why string-pixel-width should handle line-numbers that also degrades its performance. I think it should be sufficient only to disable line-numbers in internal buffers. But ok, here are both: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=string-pixel-width-line-number.patch diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 6e4d88b4df..fba817b010 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -324,7 +324,8 @@ string-pixel-width (with-current-buffer (get-buffer-create " *string-pixel-width*") (delete-region (point-min) (point-max)) (insert string) - (car (buffer-text-pixel-size nil nil t))))) + (- (car (buffer-text-pixel-size nil nil t)) + (line-number-display-width t))))) ;;;###autoload (defun string-glyph-split (string) diff --git a/lisp/display-line-numbers.el b/lisp/display-line-numbers.el index 897a88398f..cf5d353fba 100644 --- a/lisp/display-line-numbers.el +++ b/lisp/display-line-numbers.el @@ -101,7 +101,8 @@ display-line-numbers-mode (defun display-line-numbers--turn-on () "Turn on `display-line-numbers-mode'." - (unless (minibufferp) + (unless (or (minibufferp) + (string-match-p "\\` " (buffer-name))) (display-line-numbers-mode))) ;;;###autoload --=-=-=--