branch: externals/modus-themes
commit 117875cb12c92f93f94b3ffff61a5446e82bd29d
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Rewrite modus-themes-get-current-theme to work with many 
custom-enabled-themes
    
    Thanks to Pierre Téchoueyres for reporting the scenario where multiple
    other themes are loaded on top of a Modus theme. This was done in
    issue 182: <https://github.com/protesilaos/modus-themes/issues/182>.
---
 modus-themes.el | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/modus-themes.el b/modus-themes.el
index 00f78e9499..df8006c212 100644
--- a/modus-themes.el
+++ b/modus-themes.el
@@ -3874,10 +3874,18 @@ With optional SHOW-ERROR, throw an error instead of 
returning nil."
       (error "Themes `%S' is not a symbol or a list of symbols" themes)))))
 
 (defun modus-themes-get-current-theme ()
-  "Return current enabled Modus theme."
-  (let ((current (car custom-enabled-themes)))
-    (when (memq current (modus-themes-get-all-known-themes))
-      current)))
+  "Return currently enabled Modus theme.
+More specifically, return the first of the currently enabled Modus
+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))
 
 (defun modus-themes--get-theme-palette-subr (theme with-overrides 
with-user-palette)
   "Get THEME palette without `modus-themes-known-p'.

Reply via email to