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

    Make sure the common overrides are accounted for in the theme's scope
---
 modus-themes.el | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/modus-themes.el b/modus-themes.el
index d5e37bcd90..980cdbbbe7 100644
--- a/modus-themes.el
+++ b/modus-themes.el
@@ -1124,6 +1124,23 @@ With optional SHOW-ERROR, throw an error instead of 
returning nil."
   (car (or (modus-themes--list-enabled-themes)
            (modus-themes--list-known-themes))))
 
+(defun modus-themes--get-theme-palette-subr (theme overrides-only)
+  "Do the work of `modus-themes-get-theme-palette' without 
`modus-themes-known-p'.
+THEME and OVERRIDES-ONLY have the meaning of that function's documentation."
+  (if-let* ((properties (get theme 'theme-properties))
+            (core-palette (symbol-value (plist-get properties 
:modus-core-palette))))
+      (let* ((user-palette (symbol-value (plist-get properties 
:modus-user-palette)))
+             (overrides-palette (symbol-value (plist-get properties 
:modus-overrides-palette)))
+             (family (plist-get properties :family))
+             (all-overrides (append
+                             overrides-palette
+                             (when (eq family 'modus-themes)
+                               modus-themes-common-palette-overrides))))
+        (if overrides-only
+            all-overrides
+          (append overrides-palette all-overrides user-palette core-palette)))
+    (error "The theme must have at least a `:modus-core-palette' property")))
+
 (defun modus-themes-get-theme-palette (&optional theme overrides-only)
   "Return palette value of active `modus-themes-get-all-known-themes' THEME.
 If THEME is nil, use the return value of `modus-themes-get-current-theme'.
@@ -1131,14 +1148,7 @@ If THEME is nil, use the return value of 
`modus-themes-get-current-theme'.
 If OVERRIDES-ONLY is non-nil, return just the overrides."
   (let ((theme (or theme (modus-themes-get-current-theme))))
     (when (modus-themes-known-p theme :err-if-needed)
-      (if-let* ((properties (get theme 'theme-properties))
-                (core-palette (symbol-value (plist-get properties 
:modus-core-palette))))
-          (let ((user-palette (symbol-value (plist-get properties 
:modus-user-palette)))
-                (overrides-palette (symbol-value (plist-get properties 
:modus-overrides-palette))))
-            (if overrides-only
-                overrides-palette
-              (append overrides-palette user-palette core-palette)))
-        (error "The theme must have at least a `:modus-core-palette' 
property")))))
+      (modus-themes--get-theme-palette-subr theme overrides-only))))
 
 (defun modus-themes--disable-themes ()
   "Disable themes per `modus-themes-disable-other-themes'."
@@ -4456,7 +4466,7 @@ corresponding entries."
        ,@(when user-palette
            (list `(add-to-list 'modus-themes-registered-items ',name)))
        (let* ((c '((class color) (min-colors 256)))
-              (,sym (append ,user-palette ,core-palette nil))
+              (,sym (modus-themes--get-theme-palette-subr ',name nil))
               ,@(mapcar (lambda (color)
                           (list color
                                 `(modus-themes--retrieve-palette-value ',color 
,sym)))

Reply via email to