GNU bug report logs - #46476
Feature request: Right-aligning part of the modeline

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Paweł Kraśnicki <paul.krasnicki@HIDDEN>; Keywords: confirmed; dated Sat, 13 Feb 2021 01:08:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) confirmed. Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 46476 <at> debbugs.gnu.org:


Received: (at 46476) by debbugs.gnu.org; 13 Feb 2021 18:08:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 13 13:08:41 2021
Received: from localhost ([127.0.0.1]:34998 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lAzLU-00017Y-Ub
	for submit <at> debbugs.gnu.org; Sat, 13 Feb 2021 13:08:41 -0500
Received: from eggs.gnu.org ([209.51.188.92]:52374)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lAzLR-00017H-QL
 for 46476 <at> debbugs.gnu.org; Sat, 13 Feb 2021 13:08:39 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:54403)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lAzLM-000168-LR; Sat, 13 Feb 2021 13:08:32 -0500
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4315
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1lAzLM-0002dn-3R; Sat, 13 Feb 2021 13:08:32 -0500
Date: Sat, 13 Feb 2021 20:08:30 +0200
Message-Id: <837dnbden5.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: =?utf-8?Q?Pawe=C5=82_Kra=C5=9Bnicki?= <paul.krasnicki@HIDDEN>
In-Reply-To: <CAPZgK76fK9xBLv+v-Hsf0cKGUyVODaDgf4zhyma0YTnpFEkNmQ@HIDDEN>
 (message from =?utf-8?Q?Pawe=C5=82_Kra=C5=9Bnicki?= on Sat, 13 Feb 2021
 18:45:14 +0100)
Subject: Re: bug#46476: Feature request: Right-aligning part of the modeline
References: <CAPZgK760cvavCQm0RDY=J_O-F8EtsOnnOi-=B3C6jHMUz8inXQ@HIDDEN>
 <83ft20e5z0.fsf@HIDDEN>
 <CAPZgK776KeZpvSX--bL-nf=cQTMLYah-BkeJpE45TmaTaBBkRA@HIDDEN>
 <83a6s7dhv0.fsf@HIDDEN>
 <CAPZgK76fK9xBLv+v-Hsf0cKGUyVODaDgf4zhyma0YTnpFEkNmQ@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46476
Cc: 46476 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> From: Paweł Kraśnicki <paul.krasnicki@HIDDEN>
> Date: Sat, 13 Feb 2021 18:45:14 +0100
> Cc: 46476 <at> debbugs.gnu.org
> 
> > If people use :align-to, then what would be the advantage of providing
> > %-constructs to produce the same?
> 
> Well, the only advantage is that people wouldn't need to install an external
> package or write a short but advanced piece of Lisp. I think that right
> alignment is such a commonly used feature that it would be good to have it
> accessible very easily. (Center alignment and segments are less popular.)
> I actually got the idea for using %= in particular from Vim, which has right
> alignment under this %-construct.

This currently seems to be somewhat problematic, given the recursive
manner in which the mode line elements are produced by the display
code.

> > That'd require two passes to generate the mode-line display, right?
> 
> I think so. Emacs would have to first expand the modeline constructs in the
> segments separately into some internal data structure, then decide which ones to
> actually display.

Patches welcome.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46476; Package emacs. Full text available.

Message received at 46476 <at> debbugs.gnu.org:


Received: (at 46476) by debbugs.gnu.org; 13 Feb 2021 17:45:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 13 12:45:32 2021
Received: from localhost ([127.0.0.1]:34989 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lAyz6-0000ZU-NL
	for submit <at> debbugs.gnu.org; Sat, 13 Feb 2021 12:45:32 -0500
Received: from mail-pl1-f174.google.com ([209.85.214.174]:44051)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paul.krasnicki@HIDDEN>) id 1lAyz5-0000ZG-7J
 for 46476 <at> debbugs.gnu.org; Sat, 13 Feb 2021 12:45:31 -0500
Received: by mail-pl1-f174.google.com with SMTP id a24so1471225plm.11
 for <46476 <at> debbugs.gnu.org>; Sat, 13 Feb 2021 09:45:31 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=DASkGPlPUSRHWpW5QzZ/mNTQrksRRvO6ZhvAPGJ0P6o=;
 b=BTZwb2vPU4A6l+e0bmKq8IkPryJ4cNPMM2H8WbCWwnDcwLn2E9og7sQk0SHpSLxlR0
 hg/+UTwMuIfTuGsxDhbk/qMQOLbi5wSx5JjmE/+D2dnVN0a2L/cj51U5q2v+AIwnc8ws
 08CNPxipyrEiSWwoC67m1X/qHPpW6tyA8n2Uj4rkIbMSuXs7dLtY3EJBxVuLnUcS22rB
 EpkKBrkQP5VNQrnkA7OlTzNa/LHbw4oY2FdWmyACgHG9iqy0Ovi6vd0lz4SQgTjjfjsl
 HeNdpgC0TNv4j0UZiI/RD00jHlQePjvU9vFp+PxP7wytSqyHDryLdDKpyDwkIsZ70DUx
 Y1pA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=DASkGPlPUSRHWpW5QzZ/mNTQrksRRvO6ZhvAPGJ0P6o=;
 b=bjhn4u+srfdiKezVTbulQWUdnAvcwdggBJYD47wq6+WX26iuqwD/xSw5aGVUQ7+mc/
 ieHrig5TK+WB4TXpdMV1dTtN9qpXreYSdd8J/yQGrfeCTi+bIiEb2jovifBuq4KJ40nb
 0ahPwJn9ehWjxPom/YJOMcxrpXjD5nogRlKpxcUYER1fOx7kc/63PhXBTpWOq6wpI7le
 Xyq0r0lsoqaAmteKqj7QjPb58JAh4wMkTb2XILyBs0RXY3tNJfQzb0ITpjaq7R7bDrGz
 7gRGwnecECU5IaNGDde31JwDlMW4p9Ao7O+x9CrLiKopCuUJfsx3++KKRpRnoZJSOxrR
 p3Yg==
X-Gm-Message-State: AOAM533PUKjCJi/NdJ8x2rp8VAeMTYjiy9ivp3E3Xb/yr7UIIGo7UIdR
 IfEEv7EpkFVoUrvWy1JSFIQ+RoMj09GGFySx32cfkWnQh9xAjsnU
X-Google-Smtp-Source: ABdhPJz9CQ7v3t628uh7mWNk8nRsp0xMpgv90JIxRNTzuBHh9BX41V8REKuyF0rUZUG181iz7oVA1+i5CzsBXRdQSOk=
X-Received: by 2002:a17:902:6bc7:b029:e3:672:f741 with SMTP id
 m7-20020a1709026bc7b02900e30672f741mr7674797plt.44.1613238325221; Sat, 13 Feb
 2021 09:45:25 -0800 (PST)
MIME-Version: 1.0
References: <CAPZgK760cvavCQm0RDY=J_O-F8EtsOnnOi-=B3C6jHMUz8inXQ@HIDDEN>
 <83ft20e5z0.fsf@HIDDEN>
 <CAPZgK776KeZpvSX--bL-nf=cQTMLYah-BkeJpE45TmaTaBBkRA@HIDDEN>
 <83a6s7dhv0.fsf@HIDDEN>
In-Reply-To: <83a6s7dhv0.fsf@HIDDEN>
From: =?UTF-8?B?UGF3ZcWCIEtyYcWbbmlja2k=?= <paul.krasnicki@HIDDEN>
Date: Sat, 13 Feb 2021 18:45:14 +0100
Message-ID: <CAPZgK76fK9xBLv+v-Hsf0cKGUyVODaDgf4zhyma0YTnpFEkNmQ@HIDDEN>
Subject: Re: bug#46476: Feature request: Right-aligning part of the modeline
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 46476
Cc: 46476 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> If people use :align-to, then what would be the advantage of providing
> %-constructs to produce the same?

Well, the only advantage is that people wouldn't need to install an external
package or write a short but advanced piece of Lisp. I think that right
alignment is such a commonly used feature that it would be good to have it
accessible very easily. (Center alignment and segments are less popular.)
I actually got the idea for using %= in particular from Vim, which has right
alignment under this %-construct.

> That'd require two passes to generate the mode-line display, right?

I think so. Emacs would have to first expand the modeline constructs in the
segments separately into some internal data structure, then decide which ones to
actually display.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46476; Package emacs. Full text available.

Message received at 46476 <at> debbugs.gnu.org:


Received: (at 46476) by debbugs.gnu.org; 13 Feb 2021 16:59:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 13 11:59:09 2021
Received: from localhost ([127.0.0.1]:34977 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lAyGD-0007uF-MH
	for submit <at> debbugs.gnu.org; Sat, 13 Feb 2021 11:59:09 -0500
Received: from eggs.gnu.org ([209.51.188.92]:41672)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lAyGB-0007tW-R1
 for 46476 <at> debbugs.gnu.org; Sat, 13 Feb 2021 11:59:08 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:52763)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lAyG6-0005ra-J4; Sat, 13 Feb 2021 11:59:02 -0500
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3957
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1lAyG4-000266-1p; Sat, 13 Feb 2021 11:59:01 -0500
Date: Sat, 13 Feb 2021 18:58:59 +0200
Message-Id: <83a6s7dhv0.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: =?utf-8?Q?Pawe=C5=82_Kra=C5=9Bnicki?= <paul.krasnicki@HIDDEN>
In-Reply-To: <CAPZgK776KeZpvSX--bL-nf=cQTMLYah-BkeJpE45TmaTaBBkRA@HIDDEN>
 (message from =?utf-8?Q?Pawe=C5=82_Kra=C5=9Bnicki?= on Sat, 13 Feb 2021
 17:30:16 +0100)
Subject: Re: bug#46476: Feature request: Right-aligning part of the modeline
References: <CAPZgK760cvavCQm0RDY=J_O-F8EtsOnnOi-=B3C6jHMUz8inXQ@HIDDEN>
 <83ft20e5z0.fsf@HIDDEN>
 <CAPZgK776KeZpvSX--bL-nf=cQTMLYah-BkeJpE45TmaTaBBkRA@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46476
Cc: 46476 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> From: Paweł Kraśnicki <paul.krasnicki@HIDDEN>
> Date: Sat, 13 Feb 2021 17:30:16 +0100
> Cc: 46476 <at> debbugs.gnu.org
> 
> > Can you describe how is this done in Lisp?
> 
> Sure. The most common solution is to use a text property that displays a space
> with the `:align-to' property. Here's a simplified version of the code from the
> popular `powerline' package:

If people use :align-to, then what would be the advantage of providing
%-constructs to produce the same?

> > The immediate question about this I have is what to do when the
> > mode-line string is too long for the window's width?  Right now, we
> > simply chop the stuff on the right that doesn't fit, but if the
> > mode-line string has 2 or 3 different part, that should be revised,
> > right?
> 
> I'm not sure. With the current Lisp solutions, the modeline gets chopped on the
> right too, and it seems that people either don't mind that at all, or they use
> custom "segment" logic. The idea here is that the modeline is composed of a few
> segments, with each having a priority number. As the window shrinks, the
> segments get hidden in discrete jumps starting from the lowest priority, until
> only the segment(s) with the highest priority number remain. I think there may
> not be any demand for an intermediate solution that would let the user configure
> hiding with granularity of left/center/right.

That'd require two passes to generate the mode-line display, right?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46476; Package emacs. Full text available.

Message received at 46476 <at> debbugs.gnu.org:


Received: (at 46476) by debbugs.gnu.org; 13 Feb 2021 16:30:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 13 11:30:37 2021
Received: from localhost ([127.0.0.1]:34927 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lAxoa-0007BD-NN
	for submit <at> debbugs.gnu.org; Sat, 13 Feb 2021 11:30:36 -0500
Received: from mail-pf1-f182.google.com ([209.85.210.182]:36545)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paul.krasnicki@HIDDEN>) id 1lAxoX-0007Au-Ey
 for 46476 <at> debbugs.gnu.org; Sat, 13 Feb 2021 11:30:36 -0500
Received: by mail-pf1-f182.google.com with SMTP id z15so1543418pfc.3
 for <46476 <at> debbugs.gnu.org>; Sat, 13 Feb 2021 08:30:33 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=LbRwrwuTnQ0MiZJ1m20NJqZEht0EP5aVipIlGQBtpHA=;
 b=I1q72aWORfa0OLqjQDzjM02P1OndrmCDjnyFgwI6lrYvwrc05/tQmMCK5RIfyyHA9K
 yxs9jVzTlcLIO8mePl6zagJs8Jj8e/1IRcP1tW9tXzd5YBaM05CRGnT8VmmyDjN7SK4D
 576GJ0IyF5y3/6Kg/3lgQQqCQ2bwms7TsGR7ozcc1VoH3jCeJaDQo+/IQASBrP5ORNnD
 CXEQPyDXO9FSm031fwTkNwFEKZcOAr+J+q0oTVFMloED4YV4yVWTXFsqxD4AAo+AWqEY
 ZZYSos8DIY8QrnpmfYCwrRYD5NAvTmFCg4YXmIgcPZ42L+DNHWBP8eXzhe+3CudU4c87
 +KJw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=LbRwrwuTnQ0MiZJ1m20NJqZEht0EP5aVipIlGQBtpHA=;
 b=gNAWmHG5bD/mWRggqIY9pcsVhpVVnlvkKL8RRxa4hcrfZyHNxBJZIMFlVJZSAY9ZJX
 Ucfiq1DBoTCvgaD6ksKx3QBZyHso1hHctAQomSnq9Leh9xvC2rDm8yAo4iVncbs4C2eF
 z4PitVsf3aU9k1qpt7bIOmqOO6Ei/JiGlpHgnLTRwifqKjhj+sPGYeeodVhr7EYPcG2k
 G2DWlP2fUCPsA3fLR8VZO/j8bqpvrf/b10I3ss7DOIub54N8SGEI362JBjf+ovKsdJ/r
 xzdi8nKlE9Gi6cMm7al54yZv9KJkDbPoNmP8+R8dTHsCVd6v5QKc5Vd6CKS0fCLQoQPp
 7OOw==
X-Gm-Message-State: AOAM532bhbzBrJJzjqzLBVWxUcuuk6d67swqTLbMemTf/bHRixC3rcIA
 qD0p/SI2I6Ksre3enoqpDPlSQCJqMzehV9eatkA=
X-Google-Smtp-Source: ABdhPJyJFcsJDmhVmUAJzSUhbTo+hnMStwuYr/adOuNMfBNol7xPKxQeXlit1CZpGeXoCNH2leOZlse+o3vIuy2OMyU=
X-Received: by 2002:a62:ce82:0:b029:1d9:1872:294b with SMTP id
 y124-20020a62ce820000b02901d91872294bmr7701804pfg.36.1613233827241; Sat, 13
 Feb 2021 08:30:27 -0800 (PST)
MIME-Version: 1.0
References: <CAPZgK760cvavCQm0RDY=J_O-F8EtsOnnOi-=B3C6jHMUz8inXQ@HIDDEN>
 <83ft20e5z0.fsf@HIDDEN>
In-Reply-To: <83ft20e5z0.fsf@HIDDEN>
From: =?UTF-8?B?UGF3ZcWCIEtyYcWbbmlja2k=?= <paul.krasnicki@HIDDEN>
Date: Sat, 13 Feb 2021 17:30:16 +0100
Message-ID: <CAPZgK776KeZpvSX--bL-nf=cQTMLYah-BkeJpE45TmaTaBBkRA@HIDDEN>
Subject: Re: bug#46476: Feature request: Right-aligning part of the modeline
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 46476
Cc: 46476 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> Can you describe how is this done in Lisp?

Sure. The most common solution is to use a text property that displays a space
with the `:align-to' property. Here's a simplified version of the code from the
popular `powerline' package:

(defvar ml-text-scale-factor 1.0
  "Ratio of mode-line text size to default text size, as a float.
This is needed to make sure the text is properly aligned.")

(defun ml-fill-to-center (reserve face)
  "Return empty space to the center, leaving RESERVE space on the right."
  (setq reserve (* ml-text-scale-factor reserve))
  (propertize " "
              'display `((space :align-to (- (+ center (.5 . right-margin))
                                             ,reserve
                                             (.5 . left-margin))))
              'face face))

(defun ml-fill-to-right (reserve face)
  "Return empty space, leaving RESERVE space on the right."
  (setq reserve (* ml-text-scale-factor reserve))
  (when (and window-system (eq 'right (get-scroll-bar-mode)))
    (setq reserve (- reserve 2))) ; May be 3 instead of 2 with some toolkits?
  (propertize " "
              'display `((space :align-to (- (+ right right-fringe right-margin)
                                             ,reserve)))
              'face face))

(defun ml-render-2-part (left right &optional fill-face)
  "Show a modeline with left and right aligned parts."
  (concat left
          (ml-fill-to-right (string-width (format-mode-line right)) fill-face)
          right))

(defun ml-render-3-part (left center right &optional fill-face)
  "Show a modeline with left, center, and right aligned parts."
  (concat left
          (ml-fill-to-center (/ (string-width (format-mode-line center)) 2.0)
                             fill-face)
          center
          (ml-fill-to-right (string-width (format-mode-line right)) fill-face)
          right))

;; (setq mode-line-format '((:eval (ml-render-2-part "l" "r"))))
;; (setq mode-line-format '((:eval (ml-render-3-part "lllll" "c" "r"))))

> The immediate question about this I have is what to do when the
> mode-line string is too long for the window's width?  Right now, we
> simply chop the stuff on the right that doesn't fit, but if the
> mode-line string has 2 or 3 different part, that should be revised,
> right?

I'm not sure. With the current Lisp solutions, the modeline gets chopped on the
right too, and it seems that people either don't mind that at all, or they use
custom "segment" logic. The idea here is that the modeline is composed of a few
segments, with each having a priority number. As the window shrinks, the
segments get hidden in discrete jumps starting from the lowest priority, until
only the segment(s) with the highest priority number remain. I think there may
not be any demand for an intermediate solution that would let the user configure
hiding with granularity of left/center/right.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46476; Package emacs. Full text available.

Message received at 46476 <at> debbugs.gnu.org:


Received: (at 46476) by debbugs.gnu.org; 13 Feb 2021 08:18:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 13 03:18:25 2021
Received: from localhost ([127.0.0.1]:33514 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lAq8H-0002rP-8w
	for submit <at> debbugs.gnu.org; Sat, 13 Feb 2021 03:18:25 -0500
Received: from eggs.gnu.org ([209.51.188.92]:41494)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lAq8C-0002r9-Am
 for 46476 <at> debbugs.gnu.org; Sat, 13 Feb 2021 03:18:23 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:45221)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lAq87-0007kx-3i; Sat, 13 Feb 2021 03:18:15 -0500
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3161
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1lAq86-0003CO-2j; Sat, 13 Feb 2021 03:18:14 -0500
Date: Sat, 13 Feb 2021 10:18:11 +0200
Message-Id: <83ft20e5z0.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: =?utf-8?Q?Pawe=C5=82_Kra=C5=9Bnicki?= <paul.krasnicki@HIDDEN>
In-Reply-To: <CAPZgK760cvavCQm0RDY=J_O-F8EtsOnnOi-=B3C6jHMUz8inXQ@HIDDEN>
 (paul.krasnicki@HIDDEN)
Subject: Re: bug#46476: Feature request: Right-aligning part of the modeline
References: <CAPZgK760cvavCQm0RDY=J_O-F8EtsOnnOi-=B3C6jHMUz8inXQ@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 46476
Cc: 46476 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> From: Paweł Kraśnicki
>  <paul.krasnicki@HIDDEN>
> Date: Fri, 12 Feb 2021 23:59:26 +0100
> 
> Many people who use Emacs with significant customization have their modeline
> split into left and right aligned parts. I've also seen the Lisp code for this
> in several packages.

Can you describe how is this done in Lisp?

> I think it would be useful to have this feature as a
> %-construct so that the users who want it wouldn't have to install a package or
> write custom Lisp that uses the `display' text property.
> 
> Everything after this construct would be aligned to the right. For example,
> assuming the construct was %=, the mode-line-format
> 
> "l%=r"
> 
> would cause the modeline in a 20 character wide window to look like
> 
> l                  r
> 
> It could also be useful to generalize this to centering, though I've seen this
> used less often. Then, the mode-line-format
> 
> "lllll%=c%=r"
> 
> would cause the modeline to look like
> 
> lllll     c        r

The immediate question about this I have is what to do when the
mode-line string is too long for the window's width?  Right now, we
simply chop the stuff on the right that doesn't fit, but if the
mode-line string has 2 or 3 different part, that should be revised,
right?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#46476; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Feb 2021 01:07:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 12 20:07:27 2021
Received: from localhost ([127.0.0.1]:33245 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lAjPB-00079x-W0
	for submit <at> debbugs.gnu.org; Fri, 12 Feb 2021 20:07:27 -0500
Received: from lists.gnu.org ([209.51.188.17]:50980)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <paul.krasnicki@HIDDEN>) id 1lAhPZ-00040f-6x
 for submit <at> debbugs.gnu.org; Fri, 12 Feb 2021 17:59:42 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:32806)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <paul.krasnicki@HIDDEN>)
 id 1lAhPY-0003DW-UY
 for bug-gnu-emacs@HIDDEN; Fri, 12 Feb 2021 17:59:40 -0500
Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:51957)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <paul.krasnicki@HIDDEN>)
 id 1lAhPX-0004w6-BY
 for bug-gnu-emacs@HIDDEN; Fri, 12 Feb 2021 17:59:40 -0500
Received: by mail-pj1-x1033.google.com with SMTP id fa16so441694pjb.1
 for <bug-gnu-emacs@HIDDEN>; Fri, 12 Feb 2021 14:59:38 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=J9YwBRVaH/eaygmTzYSZ1/LJH9WTjEuHsWZKjCQBMcI=;
 b=tujMR/xmE3KH7iFM+++7I8dxRXzNNHS2PQk0rITwQQp3BPs/KY8v2jk83QmMASdzYS
 BKjG0WtzcC4CN7moDjgG7oRCwFkKN2m9I2hrk8fZtlZ8a7Qq7vFWBnBEBetF7pQgCEry
 3gSWFXb6WfGJTgGXogGIBI9U7jN6OhpLL/nULc6473d5KyEAP/5PwaregE0iKo3bIO8d
 +Ux617Lv95GbnoBSHQHSr5F079O/EJM5zmR9wtr47N7VUr8ehHOfBF2xHuANDsRR4Yrg
 arjVYZheuGEmolC5gbdVwDaA6trCnixYGMfPf8QbRHbS8PsxZDw8kCfKzzYH29K/g2mi
 jf+g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=J9YwBRVaH/eaygmTzYSZ1/LJH9WTjEuHsWZKjCQBMcI=;
 b=ex6AQpy0buN8pElGi6NHECun+yvQSBdTG/loAhCEMf0FQXlxZ0REOGQNy3/JFzXEO7
 26IwUFDnI07U7oL7Nh4PczNHw/EsoyRxyo3v+qjmr56kNfRtaNuswxNzlHrfPwjvayib
 H55D54OQeiWKK0JIT3mt6tvMdn4uK8LmRrg75reXOaWKmYpIojwOena55xiQCJbpSqQe
 OkkQnu+GdG39zw6Sa6ckCrhWRo19Ao1YEVfIY3EaW5jxctklKTfPCfMUI4D/Qia3DIlf
 hVlMqTG1rGVp4W/FmQqQk/ve71EeumkxE5PAnUQG19FKRw/uqmE6i4qdBpfNJdUmYxRN
 KX1A==
X-Gm-Message-State: AOAM531AqShZDBCkCJ5CGxSejf4uSVdVepKquPb8Bed3I9hHOV83fSOP
 KwxB/c+UhiFQVtLpDg02n9SKm+96sGtww5la9nYKK3DKw3U+Ug==
X-Google-Smtp-Source: ABdhPJxOl0K23cGjdtzvCgchHD302TbP9yhyD2+W63XeNa3PSsL3bok9BaLAHx4hr3hn6Tq23AhhHaPPgibEB7qbiaE=
X-Received: by 2002:a17:90a:5d0d:: with SMTP id
 s13mr4661301pji.156.1613170777143; 
 Fri, 12 Feb 2021 14:59:37 -0800 (PST)
MIME-Version: 1.0
From: =?UTF-8?B?UGF3ZcWCIEtyYcWbbmlja2k=?= <paul.krasnicki@HIDDEN>
Date: Fri, 12 Feb 2021 23:59:26 +0100
Message-ID: <CAPZgK760cvavCQm0RDY=J_O-F8EtsOnnOi-=B3C6jHMUz8inXQ@HIDDEN>
Subject: Feature request: Right-aligning part of the modeline
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Received-SPF: pass client-ip=2607:f8b0:4864:20::1033;
 envelope-from=paul.krasnicki@HIDDEN; helo=mail-pj1-x1033.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 12 Feb 2021 20:07:25 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Many people who use Emacs with significant customization have their modeline
split into left and right aligned parts. I've also seen the Lisp code for this
in several packages. I think it would be useful to have this feature as a
%-construct so that the users who want it wouldn't have to install a package or
write custom Lisp that uses the `display' text property.

Everything after this construct would be aligned to the right. For example,
assuming the construct was %=, the mode-line-format

"l%=r"

would cause the modeline in a 20 character wide window to look like

l                  r

It could also be useful to generalize this to centering, though I've seen this
used less often. Then, the mode-line-format

"lllll%=c%=r"

would cause the modeline to look like

lllll     c        r




Acknowledgement sent to Paweł Kraśnicki <paul.krasnicki@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#46476; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 21 Apr 2021 03:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.