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


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: hugo <at> heagren.com
Cc: 62606 <at> debbugs.gnu.org
Subject: bug#62606: [PATCH] function to align mode-line elements to right
Date: Sun, 02 Apr 2023 19:19:01 +0300
> 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.
>
> 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.

Does this mean that currently `tab-bar-format-align-right'
doesn't work with `visual-fill-column-mode'?  Ok, I tried it out,
and see no problems.

> Patch attached. I want to know that the code is good before I do NEWS
> and docs etc. Obviously it would be useful to document this in info
> (elisp) Mode Line Variables and maybe in the `mode-line-format'
> docstring.

Thanks, everything works nicely when I tried your patch,
but one change was needed:

> +  (let* ((rest (cdr (memq 'mode-line-format-right-align
> +			  mode-line-format)))
> +	 (rest-str (format-mode-line rest))

Here `format-mode-line' returns an empty string when
`mode-line-format-right-align' was added in the middle
of `mode-line-format'.  For a strange reason, it expects
that `mode-line-format' should start with a string.
So everything is fine after replacing in your patch

   	 (rest-str (format-mode-line rest))
with
	 (rest-str (format-mode-line (append '("") rest)))




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.