GNU bug report logs - #78953
31.0.50; tab-bar-format-align-right alignment breaks if field widths change

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Fri, 4 Jul 2025 06:41:02 UTC

Severity: normal

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

Full log


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

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: Juri Linkov <juri <at> linkov.net>
Cc: 78953 <at> debbugs.gnu.org
Subject: Re: bug#78953: 31.0.50; tab-bar-format-align-right alignment breaks
 if field widths change
Date: Fri, 04 Jul 2025 09:21:38 +0200
Juri Linkov <juri <at> linkov.net> writes:

>> 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.

Thanks for checking.

>> 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.

Yes, exactly.

Also another problem I've observed is that `string-pixel-width' is slow,
which is a problem with frequent updates/redisplays, for example when
scrolling a lot with `pixel-scroll-precision-mode'.

I suggest to update `:align-to' in `tab-bar-format-list' and also cache
the computed width and the formatted tab bar string. Then the cached
string can be compared with `equal-including-properties` and only if the
string changes, the pixel width needs to be recomputed.

Daniel




This bug report was last modified 13 days ago.

Previous Next


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