mirror of
https://github.com/doomemacs/doomemacs
synced 2025-09-16 15:56:52 -05:00
Fix loading new themes from face-remapped buffers
E.g. If mixed-pitch-mode is enabled and you change themes, then open a new frame, the theme is messed up. Also refactor load-theme advice into one.
This commit is contained in:
@@ -598,20 +598,25 @@ behavior). Do not set this directly, this is let-bound in `doom-init-theme-h'.")
|
|||||||
(let ((doom--prefer-theme-elc t)) ; DEPRECATED in Emacs 27
|
(let ((doom--prefer-theme-elc t)) ; DEPRECATED in Emacs 27
|
||||||
(load-theme doom-theme t)))))
|
(load-theme doom-theme t)))))
|
||||||
|
|
||||||
(defadvice! doom--run-load-theme-hooks-a (theme &optional _no-confirm no-enable)
|
(defadvice! doom--load-theme-a (orig-fn theme &optional no-confirm no-enable)
|
||||||
"Set up `doom-load-theme-hook' to run after `load-theme' is called."
|
"Run `doom-load-theme-hook' on `load-theme' and fix its issues.
|
||||||
:after-while #'load-theme
|
|
||||||
|
1. Disable previously enabled themes.
|
||||||
|
2. Don't let face-remapping screw up loading the new theme
|
||||||
|
(*cough*`mixed-pitch-mode').
|
||||||
|
3. Record the current theme in `doom-theme'."
|
||||||
|
:around #'load-theme
|
||||||
|
;; HACK Run `load-theme' from an estranged buffer, where we can be assured
|
||||||
|
;; that buffer-local face remaps (by `mixed-pitch-mode', for instance)
|
||||||
|
;; won't interfere with changing themes.
|
||||||
|
(with-temp-buffer
|
||||||
|
(when-let (result (funcall orig-fn theme no-confirm no-enable))
|
||||||
(unless no-enable
|
(unless no-enable
|
||||||
(setq doom-theme theme
|
(setq doom-theme theme
|
||||||
doom-init-theme-p t)
|
doom-init-theme-p t)
|
||||||
(run-hooks 'doom-load-theme-hook)))
|
(mapc #'disable-theme (remq theme custom-enabled-themes))
|
||||||
|
(run-hooks 'doom-load-theme-hook))
|
||||||
(defadvice! doom--disable-enabled-themes-a (theme &optional _no-confirm no-enable)
|
result)))
|
||||||
"Disable previously enabled themes before loading a new one.
|
|
||||||
Otherwise, themes can conflict with each other."
|
|
||||||
:after-while #'load-theme
|
|
||||||
(unless no-enable
|
|
||||||
(mapc #'disable-theme (remq theme custom-enabled-themes))))
|
|
||||||
|
|
||||||
(unless EMACS27+
|
(unless EMACS27+
|
||||||
;; DEPRECATED Not needed in Emacs 27
|
;; DEPRECATED Not needed in Emacs 27
|
||||||
|
Reference in New Issue
Block a user