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#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers Date: Fri, 18 Nov 2022 10:42:49 +0200 Message-ID: <83v8ncbqly.fsf@gnu.org> References: <86v8ncdbk1.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10831"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59311@debbugs.gnu.org, gabriel376@hotmail.com To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 18 09:43:10 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 1ovwxq-0002bF-3Q for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Nov 2022 09:43:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovwxk-0005cH-Th; Fri, 18 Nov 2022 03:43:04 -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 1ovwxi-0005bf-Qm for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 03:43: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 1ovwxi-0000My-It for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 03:43:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ovwxi-0005s6-C9 for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 03:43:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Nov 2022 08:43: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.166876097822559 (code B ref 59311); Fri, 18 Nov 2022 08:43:02 +0000 Original-Received: (at 59311) by debbugs.gnu.org; 18 Nov 2022 08:42:58 +0000 Original-Received: from localhost ([127.0.0.1]:35216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovwxe-0005rm-6p for submit@debbugs.gnu.org; Fri, 18 Nov 2022 03:42:58 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55638) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovwxY-0005rX-LH for 59311@debbugs.gnu.org; Fri, 18 Nov 2022 03:42:56 -0500 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 1ovwxT-0000Kt-36; Fri, 18 Nov 2022 03:42:47 -0500 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=iW4HfRklgazXWQ1+K+0TiOGaDYNwIyWKViE8nHsCujM=; b=i3h7BMdS24Fs ippJeMs/BSHljbF5uaoKQ1gT7/gUM+LhzqbSc0vkCqbp4nLh+P5Rn7E23haWveRh4H6uXVl8SrXlG xyy9cvEqhx5dS2uYGQy5n828875vj9Hl7wkn/ObAi7vf25FILcsrRxw8xpRGKpA3UBy0qAGI1eDv9 d2Hrv9gbUYq/Lf7Cu9QRtCKioX9nhXwJNCaofvaWt9Xfk+9JsCXoull9N969hH9Z7tYwAqg0l9Qf8 VK9LtkeHU5ltAgYHqzrSOWEui0PQMKMVZcSFMnX8yWO0CQKunfs3mOSQpVsDohbz1hHx+p8Ald1DS 9wv6MKucni14QZHXEiV4Ew==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovwxS-0002i1-JB; Fri, 18 Nov 2022 03:42:46 -0500 In-Reply-To: <86v8ncdbk1.fsf@mail.linkov.net> (message from Juri Linkov on Fri, 18 Nov 2022 09:15:02 +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:248186 Archived-At: > Cc: 59311@debbugs.gnu.org > From: Juri Linkov > Date: Fri, 18 Nov 2022 09:15:02 +0200 > > > 2) Eval the following to enable global-display-line-numbers-mode: > > > > (progn > > (global-display-line-numbers-mode 1)) > > ... > > Result: the global-mode-line is displayed in the tab-bar, right-aligned, > > with an incorrect padding on the right. See attached video. > > Thanks for the bug report. Here is a possible fix > to get the correct pixel width without taking into account > line numbers inserted to the text area of the same buffer: > > diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el > index 6e4d88b4df..92bbdfaa9c 100644 > --- a/lisp/emacs-lisp/subr-x.el > +++ b/lisp/emacs-lisp/subr-x.el > @@ -322,6 +322,8 @@ string-pixel-width > ;; Keeping a work buffer around is more efficient than creating a > ;; new temporary buffer. > (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). > But really I think the bug is in global-display-line-numbers-mode. > Maybe it should not enable display-line-numbers-mode > in internal buffers whose names start with a space? Regardless, functions that must make sure line-numbers are off should do that explicitly, or account for the line-number width in their geometry calculations. That's because whatever global-display-line-numbers-mode does, it is always possible that a particular buffer will have line-numbers enabled for some reason. > For example, here is what tab-line-mode--turn-on does: > > (defun tab-line-mode--turn-on () > (unless (or (minibufferp) > (string-match-p "\\` " (buffer-name)) > (memq major-mode tab-line-exclude-modes) > (get major-mode 'tab-line-exclude) > (buffer-local-value 'tab-line-exclude (current-buffer))) > (tab-line-mode 1))) > > But display-line-numbers--turn-on is only: > > (defun display-line-numbers--turn-on () > (unless (minibufferp) > (display-line-numbers-mode))) > > I think we should add at least (string-match-p "\\` " (buffer-name)) > to display-line-numbers--turn-on. That's a possibility, but you may find that some Lisp code somewhere assumes line-numbers are ON in a temporary buffer, e.g. because it wants to measure something that is directly related to line-numbers. So this kind of reasoning is a slippery slope, IME, and tends to introduce subtle bugs elsewhere it takes us years to find.