From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#62606: [PATCH] function to align mode-line elements to right Date: Fri, 14 Jul 2023 19:37:10 +0300 Organization: LINKOV.NET Message-ID: <86pm4usb45.fsf_-_@mail.linkov.net> References: <83jzvdijbb.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4343"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: hugo@heagren.com, 62606@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 14 18:45: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 1qKLv0-0000vk-Uf for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Jul 2023 18:45:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKLuh-0006vF-VQ; Fri, 14 Jul 2023 12:45:03 -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 1qKLug-0006uZ-LM for bug-gnu-emacs@gnu.org; Fri, 14 Jul 2023 12:45:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qKLug-000583-Cs for bug-gnu-emacs@gnu.org; Fri, 14 Jul 2023 12:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qKLuf-0006to-W7 for bug-gnu-emacs@gnu.org; Fri, 14 Jul 2023 12:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Jul 2023 16:45: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.168935308926483 (code B ref 62606); Fri, 14 Jul 2023 16:45:01 +0000 Original-Received: (at 62606) by debbugs.gnu.org; 14 Jul 2023 16:44:49 +0000 Original-Received: from localhost ([127.0.0.1]:43357 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qKLuS-0006t5-Sf for submit@debbugs.gnu.org; Fri, 14 Jul 2023 12:44:49 -0400 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:54143) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qKLuR-0006sd-DY for 62606@debbugs.gnu.org; Fri, 14 Jul 2023 12:44:47 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 66BE260006; Fri, 14 Jul 2023 16:44:39 +0000 (UTC) In-Reply-To: (GNU bug Tracking System's message of "Thu, 06 Jul 2023 07:36:02 +0000") X-GND-Sasl: juri@linkov.net 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:265112 Archived-At: >> Hope that's all good. > > Thanks, installed on the master branch, and closing the bug. I customized the mode-line to use variable-pitch fonts with (set-face-attribute 'mode-line nil :inherit '(variable-pitch)) that produces wrong right-alignment. This problem was already fixed in `tab-bar-format-align-right' by using `add-face-text-property'. This patch does the same for the mode-line: diff --git a/lisp/bindings.el b/lisp/bindings.el index f1a75b080be..047492e82d4 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -338,7 +338,10 @@ mode--line-format-right-align (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))) + (rest-width (progn + (add-face-text-property + 0 (length rest-str) 'mode-line t rest-str) + (string-pixel-width rest-str)))) (propertize " " 'display ;; The `right' spec doesn't work on TTY frames ;; when windows are split horizontally (bug#59620)