all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Gabriel <gabriel376@hotmail.com>
Cc: 59311@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	[thread overview]
Message-ID: <86v8ncdbk1.fsf@mail.linkov.net> (raw)
In-Reply-To: <SJ0PR06MB8609CBBF9BB3764192E612328B079@SJ0PR06MB8609.namprd06.prod.outlook.com> (Gabriel's message of "Wed, 16 Nov 2022 13:10:07 -0300")

> 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.





  reply	other threads:[~2022-11-18  7:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 16:10 bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers Gabriel
2022-11-18  7:15 ` Juri Linkov [this message]
2022-11-18  8:42   ` Eli Zaretskii
2022-11-18  9:46     ` Juanma Barranquero
2022-11-18 11:48       ` Eli Zaretskii
2022-11-19 19:03     ` Juri Linkov
2022-11-19 19:46       ` Eli Zaretskii
2022-11-20  8:20         ` Juri Linkov
2022-11-20  8:36           ` Eli Zaretskii
2022-11-20 18:02             ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86v8ncdbk1.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=59311@debbugs.gnu.org \
    --cc=gabriel376@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.