branch: externals/modus-themes
commit bf9dfed400b6b42dfa8d67fe4277b5da5899cc02
Author: Pierre Téchoueyres <[email protected]>
Commit: Pierre Téchoueyres <[email protected]>
Add modus-themes--modus-theme-p predicate.
Rewrite modus-themes-get-current-theme and modus-themes--disable-themes to
use it
---
modus-themes.el | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/modus-themes.el b/modus-themes.el
index 31383c42b9..a8ca94bf99 100644
--- a/modus-themes.el
+++ b/modus-themes.el
@@ -3874,6 +3874,11 @@ With optional SHOW-ERROR, throw an error instead of
returning nil."
(t
(error "Themes `%S' is not a symbol or a list of symbols" themes)))))
+(defun modus-themes--modus-theme-p (theme)
+ (when-let* ((properties (get theme 'theme-properties))
+ (core (plist-get properties :modus-core-palette)))
+ theme))
+
(defun modus-themes-get-current-theme ()
"Return currently enabled Modus theme.
More specifically, return the first of the currently enabled Modus
@@ -3881,12 +3886,7 @@ themes among the `custom-enabled-themes'.
Assume that a Modus theme has a `theme-properties' entry of
`:modus-core-palette'."
- (seq-find
- (lambda (theme)
- (when-let* ((properties (get theme 'theme-properties))
- (core (plist-get properties :modus-core-palette)))
- theme))
- custom-enabled-themes))
+ (seq-find #'modus-themes--modus-theme-p custom-enabled-themes))
(defun modus-themes--get-theme-palette-subr (theme with-overrides
with-user-palette)
"Get THEME palette without `modus-themes-known-p'.
@@ -3919,12 +3919,7 @@ If THEME is unknown, return nil. Else return (append
OVERRIDES USER CORE)."
(mapc #'disable-theme
(if modus-themes-disable-other-themes
themes
- (seq-filter
- (lambda (theme)
- (when-let* ((properties (get theme 'theme-properties))
- (core (plist-get properties :modus-core-palette)))
- theme))
- themes))))
+ (seq-filter #'modus-themes--modus-theme-p themes))))
(defun modus-themes-load-theme (theme &optional hook)
"Load THEME while disabling other themes.