GNU bug report logs - #74817
31.0.50; mode-line-format-right-align doesn't work well on header-line

Previous Next

Package: emacs;

Reported by: Eval Exec <execvy <at> gmail.com>

Date: Thu, 12 Dec 2024 10:36:01 UTC

Severity: normal

Tags: notabug, wontfix

Found in version 31.0.50

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

Bug is archived. No further changes may be made.

Full log


Message #18 received at 74817-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ship Mints <shipmints <at> gmail.com>
Cc: 74817-done <at> debbugs.gnu.org, execvy <at> gmail.com
Subject: Re: bug#74817: 31.0.50; mode-line-format-right-align doesn't work
 well on header-line
Date: Sat, 28 Dec 2024 13:32:59 +0200
> From: Ship Mints <shipmints <at> gmail.com>
> Date: Sun, 15 Dec 2024 15:25:19 -0500
> Cc: Eval Exec <execvy <at> gmail.com>, 74817 <at> debbugs.gnu.org
> 
> To emulate the desired behavior, I lifted this from tab-bar's implementation for a proof-of-concept.
> 
> (defun header-line-format-align-right ()
>   "Align the rest of `header-line' items to the right."
>   (let* ((rest (cdr (member '(:eval (header-line-format-align-right)) header-line-format)))
>          (rest (tab-bar-format-list rest)) ; replace tab-bar-format-list with your own beyond this POC
>          (rest (mapconcat (lambda (item) (nth 2 item)) rest ""))
>          (hpos (progn
>                  (add-face-text-property 0 (length rest) 'header-line t rest)
>                  (string-pixel-width rest)))
>          (str (propertize " " 'display
>                           ;; The `right' spec doesn't work on TTY frames
>                           ;; when windows are split horizontally (bug#59620)
>                           (if (window-system)
>                               `(space :align-to (- right (,hpos)))
>                             `(space :align-to (,(- (frame-inner-width) hpos)))))))
>     `((align-right menu-item ,str ignore))))
> 
> (setq header-line-format '("TEST HEADER LINE" (:eval (header-line-format-align-right)) (lambda () "FOO
> BAR BAZ")))
> 
> One gotcha is that tab-bar-format-list relies on "rest" being a list of functions, hence the lambda at the end.
> 
> Adapt as you see fit.

No further comments in 2 weeks, so I'm now closing this bug.




This bug report was last modified 238 days ago.

Previous Next


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