Re: Automatic face re-application with frame-set-background-mode

Eli Zaretskii <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
> From: Antonio Romano <[email protected]>
> Cc: [email protected]
> Date: Fri, 21 Aug 2026 14:35:52 +0000
> 
> Eli Zaretskii <[email protected]> writes:
> > This step signals an error here:
> >
> >   custom-theme-set-faces: Unknown theme ‘default’
> >
> > So I was unable to try reproducing further.
> 
> 
> That totally slipped my eye. Sorry. Here's a version that works on my
> side:

That still signals an error about an unknown theme 'mve'.

> > Not here, it doesn't: it becomes this:
> >
> >     (((class color grayscale) (min-colors 88) (background dark))
> >      :box (:line-width -1 :style released-button)
> >      :background "grey20" :foreground "white")
> 
> If `mve` theme is applied, then it does stay yellow. Tell me if you
> concur with this behaviour. Unlike the uncostumized face discussed right
> above (fringe), this face does not get recalculated to its dark
> spec. This is inconsistent and makes me doubt about its intended usage.

I think the intended usage is that the background mode is set _before_
the theme's faces are applied.

> >> >* The default face does not change. This is true even with the
> >> >`default` theme.
> > Which is expected, right?
> 
> This makes the less sense. With `emacs -Q`, setting
> `frame-background-mode` to 'dark then you'll notice that there are
> recomputed faces for dark background but the `default` background stays
> the light one. If you open C-x C-f you'll se cyan text on white
> background.

Again, you have it backwards: AFAIU, the background mode should be
known _before_ the default faces are determined.

> >> At this point I'm pretty sure that `frame-set-backgroud-mode` only
> >> recalculates faces for those that are neither user-customized nor themed. I
> >> wonder what's the rationale behind that and if it's an intended behaviour.
> >
> > The rationale could be that calling frame-set-backgroud-mode at
> > arbitrary points makes no sense.  The background mode is determined by
> > the frame's background color, so it should be applied when we first
> > show a frame, or when the frame's background color changes.
> 
> `frame-background-mode` is a user option, thus it seems to me that it
> should be called at arbitrary points. I thought it was the source of
> truth for determining the background color.

It's the other way around, actually: the background color is the
source for determining the background mode.

> >> >Are there plans or best practices for making theme faces reactive to
> >> >background-mode changes without manually reapplying the theme?
> >
> > I don't understand the question, please elaborate.
> 
> Implying that `frame-background-mode` is a user option (which is
> debatable), how should one make a theme that accounts for such
> specification? With what I've seen above, this acts in inconsistent
> ways, or maybe I'm just abusing or misusing it.

Load the theme after the background mode is set.  Does that behave as
expected?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.