[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#61239: 30.0.50; Display property value `((space :align-to))` doesn't
From: |
Eli Zaretskii |
Subject: |
bug#61239: 30.0.50; Display property value `((space :align-to))` doesn't handle line numbers |
Date: |
Fri, 03 Feb 2023 10:54:35 +0200 |
tags 61239 notabug wontfix
thanks
> From: Narendra Joshi <narendraj9@gmail.com>
> Date: Thu, 02 Feb 2023 22:26:57 +0100
>
>
> The following code demonstrates the behavior:
>
> (display-line-numbers-mode +1)
> (setq header-line-format
> (concat (propertize " " 'display '((space :align-to 0))) "Column"))
>
> With line numbers displayed, the text above, i.e. "Column" doesn't align
> wit the text in the buffer. This is problematic for modes like SES mode
> (https://www.gnu.org/software/emacs/manual/html_node/ses/index.html).
The :align-to values in header-line and mode-line do not automatically
account for line numbers when display-line-numbers-mode is turned on.
This is because the display engine cannot possibly know whether the
application does or doesn't want this; we certainly don't want that
for mode-line, for example. For header lines, there's no guarantee
that the text there must align with the buffer text: that is up to the
application to decide.
So if a Lisp program wants the header-line indentation to be updated
according to the screen estate taken by line numbers, it should do the
following:
. turn on the minor mode header-line-indent-mode
. include header-line-indent-width in the :align-to expression
In your case, the following change in the :align-to should do what you
want:
(setq header-line-format
(concat (propertize " "
'display
'(space :align-to
(+ header-line-indent-width 0)))
"Column"))
You can see further examples of using this in tabulated-list-mode.el.
I see that the ELisp manual doesn't mention this minor mode, and
moreover, has some text which might mislead you into thinking that the
header-line display will automatically be updated to account for the
line numbers; I will fix the manual soon.