Subject: Re: bug#79141: 31.0.50; The tab-bar-format-align-right cache doesn't take face changes and per-frame faces into account

From: Eli Zaretskii <[email-masked]>
Date: Wed, 13 Aug 2025 14:19:20 +0300

> From: Steven Allen <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked]
> Date: Tue, 12 Aug 2025 12:54:13 -0700
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> From: Steven Allen <[email-masked]>
> >> Cc: [email-masked], [email-masked]
> >> Date: Tue, 12 Aug 2025 11:07:08 -0700
> >>
> >> > Anyone who needs a (possibly unreliable) caching version, it's easy
> >> > to create a copy of the existing 'tab-bar-format-align-right',
> >> > add caching to it, and use in 'tab-bar-format'.
> >>
> >> I can describe it in this case, at least:
> >>
> >> 1. Any time any face attribute is updated, the "tick" would be incremented.
> >
> > Why do you think it makes any sense to do that?  When an attribute of
> > any face is modified, Emacs discards and recomputes all the faces on
> > that frame.  How would the tick help you?
> 
> We're caching the pixel-width of the right-aligned tab-bar segment.

Ah.  But isn't it better and simpler not to cache, recomputing it anew
each time?

> Adding a `face-modification-tick' would make it possible to detect when
> face attributes have changed, allowing us to invalidate the cached
> width.

But then whatever problems caused you to cache the pixel width will
happen again once Emacs recomputes the faces (which happens quite
frequently).  So I'm not sure this will be a useful feature, at least
in your case.