unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: mohkale@kisara.moe
Cc: 48257@debbugs.gnu.org
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	[thread overview]
Message-ID: <83v97p43uo.fsf@gnu.org> (raw)
In-Reply-To: <20210506151653.31575A08EB@mail.kisara.moe> (mohkale@kisara.moe)

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.





  parent reply	other threads:[~2021-05-11 16:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 15:16 bug#48257: [kisara.moe] 28.0.50; Align to right doesn't account for window separator in terminal frames mohkale
2021-05-06 15:48 ` Eli Zaretskii
2021-05-06 16:05   ` bug#48257: [kisara.moe] Re: [kisara.moe] " mohkale
2021-05-06 16:43     ` Eli Zaretskii
2021-05-11 16:44 ` Eli Zaretskii [this message]
     [not found]   ` <877dk55h90.fsf@kisara.moe>
2021-05-11 17:19     ` Eli Zaretskii
2021-05-11 17:26       ` Eli Zaretskii
2021-05-11 17:40       ` bug#48257: [kisara.moe] Re: [kisara.moe] " Mohsin Kaleem
2021-07-05 21:04 ` bug#48257: " Kevin Boulain
2021-07-06 12:49   ` Eli Zaretskii
2021-07-06 17:13     ` Eli Zaretskii
     [not found]       ` <CABaj1X9fTfYcZ8bcLHvLtmseyQeVspL3-wF2pN6DC_uLgMny4A@mail.gmail.com>
2021-07-08  6:24         ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=83v97p43uo.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=48257@debbugs.gnu.org \
    --cc=mohkale@kisara.moe \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).