Re: Automatic face re-application with frame-set-background-mode
Eli Zaretskii <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <[email protected]> |
> Date: Fri, 21 Aug 2026 08:55:53 +0000 > From: Antonio Romano <[email protected]> > > Il 11 aprile 2026 15:44:30 CEST, Antonio Romano <[email protected]> ha scritto: > >Hello, > > > >I’m experimenting with themes on Emacs (using master branch) and > >noticed some behavior related to `frame-set-background-mode` that I’d > >like to clarify. > > > >I created a minimal working example theme as follows: > > > >``` > >;; -*- lexical-binding: t; -*- > >(deftheme mve-theme "Minimal MVE") > > > >(custom-theme-set-faces > > 'default > > `(default > > ((((background light)) :background "white" :foreground "black") > > (((background dark)) :background "black" :foreground "white"))) > > `(mode-line > > ((((background light)) :background "yellow" :foreground "black") > > (((background dark)) :background "red" :foreground "white")))) > > > >(provide-theme 'mve-theme) > >``` > > > >Steps I performed: > > > >Run `emacs -Q` > >Load the theme with `M-x load-theme mve-theme`. This step signals an error here: custom-theme-set-faces: Unknown theme ‘default’ So I was unable to try reproducing further. > >Call `(setopt frame-background-mode 'dark)`. > > > >Notable observations: > > > >* The fringe (unspecified in this theme) changes to black. Which is okay, right? Because its defface says: (((class color) (background dark)) :background "grey10") > >* The mode-line stays yellow. 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") > >* The default face does not change. This is true even with the > >`default` theme. Which is expected, right? > >* Syntax highlighting colors in emacs-lisp-mode update according to > >background-mode. Which is okay, right? > >It seems that some faces do get re-applied after a `background-mode` > >switch, while others do not. Even when they do, they do not honor my > >`custom-theme-set-faces` settings. No, all of the faces get recalculated. Are you talking about the default face only? > >I’m trying to understand: > > > >What conditions determine which faces are automatically recalculated > >when `frame-set-background-mode` is called? Basically, all of them are recalculated. > >Is this behavior hardcoded for built-in faces only? No. > >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. > 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.