From: Eli Zaretskii <eliz@gnu.org>
To: Ship Mints <shipmints@gmail.com>
Cc: 74817-done@debbugs.gnu.org, execvy@gmail.com
Subject: 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 [thread overview]
Message-ID: <86a5cgt53o.fsf@gnu.org> (raw)
In-Reply-To: <CAN+1HbrBJFRHHvKNiRv5uxj4v6VPxS_ApbHyx75hr1eF7voJyg@mail.gmail.com> (message from Ship Mints on Sun, 15 Dec 2024 15:25:19 -0500)
> From: Ship Mints <shipmints@gmail.com>
> Date: Sun, 15 Dec 2024 15:25:19 -0500
> Cc: Eval Exec <execvy@gmail.com>, 74817@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.
prev parent reply other threads:[~2024-12-28 11:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 10:35 bug#74817: 31.0.50; mode-line-format-right-align doesn't work well on header-line Eval Exec
2024-12-14 10:55 ` Eli Zaretskii
2024-12-15 20:25 ` Ship Mints
2024-12-28 11:32 ` Eli Zaretskii [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86a5cgt53o.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=74817-done@debbugs.gnu.org \
--cc=execvy@gmail.com \
--cc=shipmints@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).