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

Antonio Romano <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
To my previous message:

Antonio Romano <[email protected]> writes:
> It says it does recalculate faces, but that's not always the case as
> we've just said that reloading the theme is needed.


I'm adding that I've been browsing custom theme codes over the web and
found this[1] in solarized-theme.el:

--8<---------------cut here---------------start------------->8---
(cl-defun solarized-update-background-mode
    (appearance &optional (frames (frame-list)))
  "Set the APPEARANCE of all frames to either 'light or 'dark.
This is not specific to Solarized – it will update the appearance of any theme
that observes the background characteristic."
  (setq frame-background-mode appearance)
  (mapc #'frame-set-background-mode frames)
  ;; Supposedly #'frame-set-background-mode updates the faces, but it doesn’t
  ;; seem to actually., so re-enable all the themes.
  (mapc #'enable-theme (reverse custom-enabled-themes))
  ;; For some reason, ‘enable-theme’ (or maybe ‘solarized’?) is resetting the
  ;; ‘frame-background-mode’, so reset it here.
  (setq frame-background-mode appearance))
--8<---------------cut here---------------end--------------->8---

So it seems that reloading the theme is the way to go, and also that I'm
not the only one confused by the way `frame-set-background-mode` operates.

[1] https://github.com/sellout/emacs-color-theme-solarized/blob/3738e588c3a58bce18dab7dca074dc23b0e63eed/solarized-theme.el#L27
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.