GNU bug report logs - #62606
[PATCH] function to align mode-line elements to right

Previous Next

Package: emacs;

Reported by: hugo <at> heagren.com

Date: Sun, 2 Apr 2023 04:48:03 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #64 received at 62606 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: hugo <at> heagren.com, 62606 <at> debbugs.gnu.org
Subject: Re: bug#62606: [PATCH] function to align mode-line elements to right
Date: Fri, 14 Jul 2023 19:37:10 +0300
>> 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)




This bug report was last modified 1 year and 183 days ago.

Previous Next


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