[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59311: 29.0.50; tab-bar global-mode-string affected by global-displa
From: |
Juri Linkov |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) |
> 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.
- bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers, Gabriel, 2022/11/16
- bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers,
Juri Linkov <=
- bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers, Eli Zaretskii, 2022/11/18
- bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers, Juri Linkov, 2022/11/19
- bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers, Eli Zaretskii, 2022/11/19
- bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers, Juri Linkov, 2022/11/20
- bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers, Eli Zaretskii, 2022/11/20
- bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers, Juri Linkov, 2022/11/20