Subject: bug#78953: 31.0.50; tab-bar-format-align-right alignment breaks if field widths change

From: Juri Linkov <[email-masked]>
Date: Fri, 04 Jul 2025 09:52:58 +0300

> When fields in `tab-bar-format' after `tab-bar-format-align-right'
> change their width between two calls, then the alignment breaks - the
> right aligned tab field jumps around. Example configuration which uses a
> `global-mode-string' with a random width:
>
> (setq tab-bar-format
>   '( tab-bar-format-tabs
>      tab-bar-format-align-right
>      tab-bar-format-global))
>
> (setq global-mode-string
>       '("|" (:eval (make-string (random 10) ?#)) "|"))
>
> (run-at-time 1 1 #'force-mode-line-update t)

Thanks, I confirm the problem.

> A more realistic configuration with a timer (and a variable pitch face)
> also shows the problem. A possible solution could be to handle
> `tab-bar-format-align-right' in `tab-bar-format-list', such that the
> functions in the `tab-bar-format' list after
> `tab-bar-format-align-right' are not called twice, such that the
> computed field width matches the displayed field.

So need to update :align-to in tab-bar-format-list.