From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <83v97p43uo.fsf@gnu.org> References: <20210506151653.31575A08EB@mail.kisara.moe> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2137"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48257@debbugs.gnu.org To: mohkale@kisara.moe Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 11 18:45:28 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lgVVg-0000Po-Hh for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 May 2021 18:45:28 +0200 Original-Received: from localhost ([::1]:52164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgVVf-0002C0-F6 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 May 2021 12:45:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgVVK-00029H-0M for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 12:45:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lgVVG-00008o-KT for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 12:45:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lgVVG-0003tM-IB for bug-gnu-emacs@gnu.org; Tue, 11 May 2021 12:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 May 2021 16:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48257 X-GNU-PR-Package: emacs Original-Received: via spool by 48257-submit@debbugs.gnu.org id=B48257.162075149114928 (code B ref 48257); Tue, 11 May 2021 16:45:02 +0000 Original-Received: (at 48257) by debbugs.gnu.org; 11 May 2021 16:44:51 +0000 Original-Received: from localhost ([127.0.0.1]:37233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lgVV4-0003sc-Q7 for submit@debbugs.gnu.org; Tue, 11 May 2021 12:44:51 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lgVV2-0003sJ-6s; Tue, 11 May 2021 12:44:48 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:56182) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgVUw-0008S1-LN; Tue, 11 May 2021 12:44:42 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3986 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgVUw-0004T0-51; Tue, 11 May 2021 12:44:42 -0400 In-Reply-To: <20210506151653.31575A08EB@mail.kisara.moe> (mohkale@kisara.moe) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:206257 Archived-At: 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.