Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve compatibility with doom-theme #76

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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