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

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

bug#48257: [kisara.moe] 28.0.50; Align to right doesn't account for wind


From: Eli Zaretskii
Subject: bug#48257: [kisara.moe] 28.0.50; Align to right doesn't account for window separator in terminal frames
Date: Tue, 11 May 2021 19:44:47 +0300

tags 48257 notabug
thanks

> Date: Thu, 06 May 2021 17:16:53 +0200
> From: mohkale@kisara.moe
> 
> On terminal frames emacs doesn't account for the window separator when
> right aligning some text. Many mode-line packages which include both
> left and right hand sections are thus off alignment. I believe this is
> an issue because on GUI frames the separator is a straight line that
> takes up (essentially) no width whereas on terminal frames it takes up a
> full column.
> 
> Reproduction instruction:
> 1. Run `emacs -nw -q`
> 2. Copy the following code block into your scratch buffer and run `M-x 
> eval-buffer`.
> ```lisp
> (defvar left-mode-line-format+
>   '("foo"))
> 
> (defvar right-mode-line-format+
>   '("bar"))
> 
> (defun +align-mode-line (lhs-forms rhs-forms)
>   "Adapted from `doom-modeline-def-modeline'."
>   (let ((left-width (string-width (format-mode-line (cons "" rhs-forms)))))
>     (list lhs-forms
>           (propertize " "
>                       'display `((space :align-to
>                                         (- (+ right right-fringe right-margin)
>                                            ,left-width))))
>           rhs-forms)))
> 
> (setq
>  mode-line-format
>  '((:eval (+align-mode-line left-mode-line-format+
>                             right-mode-line-format+))))
> ```
> 3. Now run `split-window-right`.
> 
> 
> Observe that in the left window the last character in the right aligned
> mode-line section is one character too short (because the window
> separators width isn't accounted for) whereas in the right window this
> isn't an issue.

I've looked into this, and I don't think this behavior is incorrect.

:align-to references the physical dimensions of the screen, so if the
last column of the window is taken by a truncation or a continuation
glyph, or the last column of the mode line is taken by the
vertical-border glyph, the Lisp program which wants to display
something flushed to the right should take this into account, and
enlarge the offset accordingly.  Emacs allows Lisp code to control
what characters are displayed as truncation glyphs, continuation
glyphs, and vertical-border glyphs, so these aren't fixed values that
redisplay should automatically take into account.  Maybe it's somewhat
unexpected, but if you think about what :align-to does, I think (hope)
you will agree that there's no bug here.





reply via email to

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