Skip to content

Commit

Permalink
Improve compatibility with doom-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
sellout committed Oct 21, 2024
1 parent 1b6c184 commit 4390a64
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion auto-dark.el
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ already set the theme for the current dark mode state."
(setq frame-background-mode appearance)
(mapc #'frame-set-background-mode (frame-list)))

(defmacro auto-dark--enable-theme (theme-exp)
"Inline `enable-theme' on THEME-EXP.
Doom Emacs requires `load-theme' to be used instead of `enable-theme' for it to
keep themes in sync (see doomemacs/doomemacs#8119). This expands to `load-theme'
when necessary."
(if (boundp 'doom-version)
;; We should only get here if the theme has already been loaded, so we
;; avoid confirmation. However, this is still a loophole if the theme has
;; changed since the last time it was loaded.
`(load-theme ,theme-exp t)
`(enable-theme ,theme-exp)))

(defun auto-dark--enable-themes (&optional themes)
"Re-enable THEMES, which defaults to ‘custom-enabled-themes’.
This will load themes if necessary."
Expand All @@ -249,7 +261,7 @@ This will load themes if necessary."
(condition-case nil
;; Enable instead of load when possible.
(if (custom-theme-p theme)
(enable-theme theme)
(auto-dark--enable-theme theme)
(load-theme theme))
(:success nil)
(error (list theme))))
Expand Down

0 comments on commit 4390a64

Please sign in to comment.