help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using :align-to with non-spaces


From: Alex
Subject: Re: Using :align-to with non-spaces
Date: Tue, 10 Oct 2017 12:09:53 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Alex <agrambot@gmail.com>
>> Cc: eliz@gnu.org
>> Date: Sun, 08 Oct 2017 23:22:59 -0600
>> 
>> (setq header-line-format
>>       (concat (propertize " "
>>                           'display
>>                           '(space . (:align-to 0)))
>>               "test"))
>> 
>> (setq header-line-format
>>       (propertize "test"
>>                   'display
>>                   '(space . (:align-to 0))))
>> 
>> It's not a big deal, but it's makes things look cleaner, especially when
>> the string in question is also being propertized.
>
> The 'space' display property is of the "replacing" kind, i.e. it
> completely replaces the text which has that property.  So implementing
> what you want would need a new property at least.  Or maybe you could
> use the '(space-width FACTOR)' display spec instead, and prepending a
> single SPC character that precedes the string characters?  (This
> assumes the string itself doesn't have embedded SPC characters; if it
> does, put this display property only on the initial SPC character.)

I guess I replied to this part in Bug#28771 (sorry for fragmenting the
discussion).

> FWIW, having a 'space' display property on some whitespace character
> sounds very intuitive to me, since this feature was supposed to be
> used to display white space subject to pixel-level resolution
> considerations of a GUI frame.

It does to me as well, but it would be nice to have similar
functionality to :align-to in arbitrary strings.

Something like the following, that would align the string similar to
:align-to does a space:

(propertize "test"
            'display
            '(align-to EXPR))

where EXPR can be the same as in :align-to.

>> P.S. I noticed that the above does not take into account the space taken
>> by `display-line-numbers'.
>
> That's because it isn't clear whether it should be done for every
> header-line.  For example, the Info mode will certainly not want
> that.  So this has to be done by the Lisp program, because only it
> knows whether the text in the header line should be aligned with the
> rest of buffer text.

I don't understand. The Info mode header isn't aligned at all (for
example, toggling fringe and linum-mode (for the margin) doesn't change
the position of the info header). Only headers with an `:align-to num'
property would be affected.

Here is what the manual says about :align-to:

   For example, ‘:align-to 0’ in a header-line aligns with the first
   text column in the text area.

I would consider "the first text column" to be column 0, so the current
behaviour is incorrect.

If line-number display is treated specially, then there should also be a
`line-number' element for the :align-to and :width specs.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]