branch: externals/modus-themes
commit 72ed98f7864f36007b2c1fd539fda503daa529a3
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Implement modus-themes--get-theme-sort
This makes it easier to place the return value of
'modus-themes-get-theme-palette'
in a 'let*' because something like '(cursor red-warmer)' will come
after '(red-warmer "#ff0000")'.
This might help me sort out the woes with the excessive lisp nesting
of modus-themes-with-colors (see commits 5e77bff and 4514036), but
looks appropriate anyway.
---
modus-themes.el | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/modus-themes.el b/modus-themes.el
index 0d07e1a374..52dce407fe 100644
--- a/modus-themes.el
+++ b/modus-themes.el
@@ -3850,6 +3850,15 @@ With optional SHOW-ERROR, throw an error instead of
returning nil."
(when (memq current (modus-themes-get-themes))
current)))
+(defun modus-themes--get-theme-sort (colors)
+ "Sort all COLORS in the theme's palette.
+Put all named colors before semantic color mappings. A named color is a
+symbol whose value is a string. A semantic color mapping is a symbol
+whose value is another symbol, which ultimately resolves to a string or
+`unspecified'."
+ (nconc (seq-filter (lambda (color) (stringp (cadr color))) colors)
+ (seq-remove (lambda (color) (stringp (cadr color))) colors)))
+
(defun modus-themes--get-theme-palette-subr (theme with-overrides
with-user-palette)
"Get THEME palette without `modus-themes-known-p'.
WITH-OVERRIDES and WITH-USER-PALETTE are described in
@@ -3858,9 +3867,8 @@ WITH-OVERRIDES and WITH-USER-PALETTE are described in
(core-palette (symbol-value (plist-get properties
:modus-core-palette))))
(let* ((user-palette (when with-user-palette (symbol-value (plist-get
properties :modus-user-palette))))
(overrides-palette (when with-overrides (symbol-value (plist-get
properties :modus-overrides-palette))))
- (all-overrides (when with-overrides
- (append overrides-palette
modus-themes-common-palette-overrides))))
- (append all-overrides user-palette core-palette))
+ (all-overrides (when with-overrides (append overrides-palette
modus-themes-common-palette-overrides))))
+ (modus-themes--get-theme-sort (append 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 with-overrides
with-user-palette)