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:
parent
c4d4780b7b
commit
0837c56430
|
@ -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
|
||||
(load-theme doom-theme t)))))
|
||||
|
||||
(defadvice! doom--run-load-theme-hooks-a (theme &optional _no-confirm no-enable)
|
||||
"Set up `doom-load-theme-hook' to run after `load-theme' is called."
|
||||
:after-while #'load-theme
|
||||
(unless no-enable
|
||||
(setq doom-theme theme
|
||||
doom-init-theme-p t)
|
||||
(run-hooks 'doom-load-theme-hook)))
|
||||
(defadvice! doom--load-theme-a (orig-fn theme &optional no-confirm no-enable)
|
||||
"Run `doom-load-theme-hook' on `load-theme' and fix its issues.
|
||||
|
||||
(defadvice! doom--disable-enabled-themes-a (theme &optional _no-confirm no-enable)
|
||||
"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))))
|
||||
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
|
||||
(setq doom-theme theme
|
||||
doom-init-theme-p t)
|
||||
(mapc #'disable-theme (remq theme custom-enabled-themes))
|
||||
(run-hooks 'doom-load-theme-hook))
|
||||
result)))
|
||||
|
||||
(unless EMACS27+
|
||||
;; DEPRECATED Not needed in Emacs 27
|
||||
|
|
Loading…
Reference in New Issue
Block a user