GNU bug report logs - #59311
29.0.50; tab-bar global-mode-string affected by global-display-line-numbers

Previous Next

Package: emacs;

Reported by: Gabriel <gabriel376 <at> hotmail.com>

Date: Wed, 16 Nov 2022 16:11:02 UTC

Severity: normal

Found in version 29.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Gabriel <gabriel376 <at> hotmail.com>
Cc: 59311 <at> debbugs.gnu.org
Subject: bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers
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)))))

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?

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.




This bug report was last modified 2 years and 261 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.