Fix load-theme not disabling old themes in Emacs 26

In Emacs 26, the old themes must be disabled *before* the new one is
loaded, otherwise it will fail to do so. In 27+ this isn't necessary,
and it's preferred that we do it after the theme loads, so we can be
absolutely sure the theme was successfully enabled, before we disable
the others!
This commit is contained in:
Henrik Lissner 2020-05-21 04:33:39 -04:00
parent c4e8aa0baa
commit a262527a7f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -634,6 +634,15 @@ behavior). Do not set this directly, this is let-bound in `doom-init-theme-h'.")
result))) result)))
(when! (not EMACS27+) (when! (not EMACS27+)
;; DEPRECATED `doom--load-theme-a' handles this for us after the theme is
;; loaded, but this only works on Emacs 27+. Disabling old themes
;; must be done *before* the theme is loaded in Emacs 26.
(defadvice! doom--disable-previous-themes-a (theme &rest no-confirm no-enable)
"Disable other themes when loading a new one."
:before #'load-theme
(unless no-enable
(mapc #'disable-theme (remq theme custom-enabled-themes))))
;; DEPRECATED Not needed in Emacs 27 ;; DEPRECATED Not needed in Emacs 27
(defadvice! doom--prefer-compiled-theme-a (orig-fn &rest args) (defadvice! doom--prefer-compiled-theme-a (orig-fn &rest args)
"Have `load-theme' prioritize the byte-compiled theme. "Have `load-theme' prioritize the byte-compiled theme.