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#62606: [PATCH] function to align mode-line elements to right Date: Sun, 02 Apr 2023 08:47:40 +0300 Message-ID: <83355iygw3.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26338"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62606@debbugs.gnu.org To: hugo@heagren.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 02 07:48:30 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 1piqZq-0006fn-9Y for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 Apr 2023 07:48:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1piqZS-0006jx-KU; Sun, 02 Apr 2023 01:48:06 -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 1piqZP-0006jV-Kl for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 01:48:03 -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 1piqZO-0004ck-Tg for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 01:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1piqZO-0001Pb-9W for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 01:48: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: Sun, 02 Apr 2023 05:48:02 +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.16804144525242 (code B ref 62606); Sun, 02 Apr 2023 05:48:02 +0000 Original-Received: (at 62606) by debbugs.gnu.org; 2 Apr 2023 05:47:32 +0000 Original-Received: from localhost ([127.0.0.1]:38996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1piqYt-0001MU-Iv for submit@debbugs.gnu.org; Sun, 02 Apr 2023 01:47:32 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1piqYr-0001M7-DZ for 62606@debbugs.gnu.org; Sun, 02 Apr 2023 01:47:29 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1piqYl-0004Tx-Is; Sun, 02 Apr 2023 01:47:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=usR7J78GlmDoJvmuOZPdxQgMZzPvOJa3BqoiF/uUqyo=; b=Mzi+6D8NZ84c a2587cQKmIKfR5ClDEmxVAv1FLvlTnDR/y/rO4DFVk94nLwH3/5NRgXeAch10o0Mn8NXIZnMMwdkp Kfy0gqesFcBub+b1sC1O52p4VSbClTR7IES/M7YgNZhxFZqL65iHL0I361nn87N8/dtcZaRJIOFgI Q0ly2t6u0VLAPaDVjjKWJVAeXSiWAUUWshWyc8cHeqysO/UuUFwRuz+GA1MfXOpgP/5YPuyQfFGmF 7EuMXWApdwn98VV+2hPbJFPjFu3Wu/c0DwALcuglkD3ihgX/7RgwMKH6Y7UnOz4OpLAIeRmJaQo3Z V+tHcMrUNEmp/ZkxU5kdow==; Original-Received: from [87.69.77.57] (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 1piqYk-0001B8-Ko; Sun, 02 Apr 2023 01:47:22 -0400 In-Reply-To: (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:259090 Archived-At: > Date: Sat, 01 Apr 2023 23:27:31 +0100 > From: hugo@heagren.com > > I wanted to be able to right-align some elements of the mode-line. I > used `tab-bar-format-align-right' as a base and modified it to work with > the mode-line. Thanks. What would be the situations where the user could want this alignment? 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. 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? > The functin aligns to the right /fringe/ rather than the margin because > some modes (e.g. [visual-fill-column-mode]) mess around the margin size, > but the right-align should be unaffected by this. This detail should not be hard-coded, IMO. It should be up to the calling Lisp program (or maybe even user option) whether the alignment is to the right margin or to the window edge. Also, did you test this when the fringe is inside the margins and the margins have non-zero width? > + (let* ((rest (cdr (memq 'mode-line-format-right-align > + mode-line-format))) > + (rest-str (format-mode-line rest)) > + (rest-width (string-pixel-width rest-str))) The call to string-pixel-width will significantly slow down redisplay of the mode line. I wonder whether this feature should be implemented in C instead, to avoid the slowdown. On the C level, we always know the actual width of the mode-line text, and can right-align it by prepending a stretch glyph of a suitable width. > + (propertize " " 'display > + ;; The `right' spec doesn't work on TTY frames > + ;; when windows are split horizontally (bug#59620) > + (if (window-system) ^^^^^^^^^^^^^^^^^^^ This should use display-graphic-p, not window-system. Did you test this in a session which has both GUI and TTY frames?