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
1 changed files with 18 additions and 13 deletions
|
@ -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
|
|
||||||
(unless no-enable
|
|
||||||
(setq doom-theme theme
|
|
||||||
doom-init-theme-p t)
|
|
||||||
(run-hooks 'doom-load-theme-hook)))
|
|
||||||
|
|
||||||
(defadvice! doom--disable-enabled-themes-a (theme &optional _no-confirm no-enable)
|
1. Disable previously enabled themes.
|
||||||
"Disable previously enabled themes before loading a new one.
|
2. Don't let face-remapping screw up loading the new theme
|
||||||
Otherwise, themes can conflict with each other."
|
(*cough*`mixed-pitch-mode').
|
||||||
:after-while #'load-theme
|
3. Record the current theme in `doom-theme'."
|
||||||
(unless no-enable
|
:around #'load-theme
|
||||||
(mapc #'disable-theme (remq theme custom-enabled-themes))))
|
;; 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+
|
(unless EMACS27+
|
||||||
;; DEPRECATED Not needed in Emacs 27
|
;; DEPRECATED Not needed in Emacs 27
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue