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

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

bug#62606: [PATCH] function to align mode-line elements to right


From: Eli Zaretskii
Subject: bug#62606: [PATCH] function to align mode-line elements to right
Date: Sun, 02 Apr 2023 08:47:40 +0300

> Date: Sat, 01 Apr 2023 23:27:31 +0100
> From: hugo@heagren.com
> 
> I wanted to be able to right-align some elements of the mode-line. I
> used `tab-bar-format-align-right' as a base and modified it to work with
> the mode-line.

Thanks.

What would be the situations where the user could want this alignment?

One possible issue with right alignment is that when the total size of
the mode-line text changes (e.g., the mode lighter changes), the
leftmost part of it will move horizontally, something that could be
unpleasant and even annoying.

Also, what happens if the mode-line text is longer than the window
width.  What are user expectations in that case, and does :align-to
meet those expectations?

> The functin aligns to the right /fringe/ rather than the margin because
> some modes (e.g. [visual-fill-column-mode]) mess around the margin size,
> but the right-align should be unaffected by this.

This detail should not be hard-coded, IMO.  It should be up to the
calling Lisp program (or maybe even user option) whether the alignment
is to the right margin or to the window edge.

Also, did you test this when the fringe is inside the margins and the
margins have non-zero width?

> +  (let* ((rest (cdr (memq 'mode-line-format-right-align
> +                       mode-line-format)))
> +      (rest-str (format-mode-line rest))
> +      (rest-width (string-pixel-width rest-str)))

The call to string-pixel-width will significantly slow down redisplay
of the mode line.  I wonder whether this feature should be implemented
in C instead, to avoid the slowdown.  On the C level, we always know
the actual width of the mode-line text, and can right-align it by
prepending a stretch glyph of a suitable width.

> +    (propertize " " 'display
> +             ;; The `right' spec doesn't work on TTY frames
> +             ;; when windows are split horizontally (bug#59620)
> +             (if (window-system)
                ^^^^^^^^^^^^^^^^^^^
This should use display-graphic-p, not window-system.

Did you test this in a session which has both GUI and TTY frames?





reply via email to

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