From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: hugo@heagren.com Newsgroups: gmane.emacs.bugs Subject: bug#62606: [PATCH] function to align mode-line elements to right Date: Mon, 05 Jun 2023 21:45:17 +0100 Message-ID: <4b872ecc12e3995d5b7dfffa580e297d@heagren.com> References: <83355iygw3.fsf@gnu.org> <83mt2hfrr4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3788"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Roundcube Webmail/1.6.0 Cc: 62606@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 05 22:46:23 2023 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 1q6H5q-0000nM-Gc for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jun 2023 22:46:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6H5Y-0006qg-8w; Mon, 05 Jun 2023 16:46:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6H5W-0006qU-CC for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 16:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q6H5V-0002tx-VO for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 16:46:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q6H5V-0002f9-Qx for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 16:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: hugo@heagren.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Jun 2023 20:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62606 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 62606-submit@debbugs.gnu.org id=B62606.168599792710190 (code B ref 62606); Mon, 05 Jun 2023 20:46:01 +0000 Original-Received: (at 62606) by debbugs.gnu.org; 5 Jun 2023 20:45:27 +0000 Original-Received: from localhost ([127.0.0.1]:50424 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q6H4w-0002eH-HR for submit@debbugs.gnu.org; Mon, 05 Jun 2023 16:45:26 -0400 Original-Received: from whuk14.whukhost.com ([5.77.41.174]:45452) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q6H4u-0002e2-De for 62606@debbugs.gnu.org; Mon, 05 Jun 2023 16:45:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=heagren.com ; s=default; h=Content-Transfer-Encoding:Content-Type:Message-ID:References: In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=N9zA45jmLEjO3r2Ogr9aNJd76iXkUxm9FtNY+HUt2Jg=; b=E0QJyVDEBuanEYJY+vFFz36dMh mRh9PA5LRXCMqoedg8hacWfWulLMY3wo1/1NHvr0NJsMe4X6Jc9VPwpJh3rNuf8OM1T+pYaUM48JM jsXn4bY5+E+74Q7hThHnPYy8HmcZrJUGB5BiJMFji8fX1XdhpWXrPbZkIlWHsWOa+RHbJDyFdeYe9 2ZiA/tGdvW9POuNqJWscpzf4F1w/PPP92QwFs7DpEsRs+MrtEx9E14TzwKE0j0UXYg9CREDU/B8D6 oEGSOkbsGdrubievcLqCHGWUGpY49aPPl9dJwc1naQWW7rpCuJ/3nUNM/twhQ/AmOBZpa7jzdu/V0 Qni2v+hQ==; Original-Received: from [::1] (port=42154 helo=whuk14.whukhost.com) by whuk14.whukhost.com with esmtpa (Exim 4.96) (envelope-from ) id 1q6H4n-003IBY-2U; Mon, 05 Jun 2023 21:45:17 +0100 In-Reply-To: <83mt2hfrr4.fsf@gnu.org> X-Sender: hugo@heagren.com X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - whuk14.whukhost.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - heagren.com X-Get-Message-Sender-Via: whuk14.whukhost.com: authenticated_id: hugo@heagren.com X-Authenticated-Sender: whuk14.whukhost.com: hugo@heagren.com 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263030 Archived-At: On 2023-05-06 15:39, Eli Zaretskii wrote: > > > 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. > > > > This doesn't happen with my proposed setup (though I agree it would be > > annoying if it did!). The user includes the symbol > > `mode-line-format-right-align' in their mode line format. This is a > > variable which holds a mode-line construct `(:> eval > > (mode-line-format-right-align))'. So whenever the mode-line is reloaded > > (and therefore, whenever the length could change), the space used to pad > > the right-aligned part to the right is recalculated. > > That recalculation is what I alluded to: the space will be different > depending on the size of the mode-line text. I confess I am very confused. Let's say we have a modeline like this, with parts L (left-aligned), M (middle - displays as empty space) and R (right-aligned): |--L--|-------M-------|-R-| Foo bar X If L gets longer then: - M will get shorter - R will stay the same So we get: |--L-----|----M-------|-R-| Foo barrrr X Is this what you're worried about? If so, I don't think it's much of a cause for concern. I modelled my function on `tab-bar-format-align-right', which works in a very similar way. It also strikes me that something like this happens anyway already: if we have a mode-line with just a left-aligned lighter, and the lighter gets longer (or shorter), then the space between the end of the lighter and the edge of the screen (i.e. M+R) gets smaller (or bigger). Isn't this to be expected? If this isn't the effect you're worried about, could you explain in more detail? > > > 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? > > > > Then the text overflows to the right. > > I'm not sure everyone will agree with your expectations. The only alternative I can think of is that the right-aligned part stay visible, and the other text overflows 'behind' it. Personally I don't think this would make much sense, but I can see that some people might prefer it. I suppose the best thing to do would be to add an option to control the behaviour, but I've had a look at the code and I have no idea how to implement the other version---the current behaviour is what happens by default and it just seemed right to me. > > > This should use display-graphic-p, not window-system. > > > > Fixed. > > > > > Did you test this in a session which has both GUI and TTY frames? > > > > Yes, it behaves correctly (i.e. right-aligns in both, even when the > > same buffer is simultaneously displayed in both). > > And if then you delete all the GUI frames and only the TTY frames > remain? Same effect -- the right-aligned part is still right-aligned in the remaining TTY frames. Hope that helps. Hugo