[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/standard-themes 15620a57bb: Make it possible to have re
From: |
ELPA Syncer |
Subject: |
[elpa] externals/standard-themes 15620a57bb: Make it possible to have recursive palette mapping |
Date: |
Wed, 4 Jan 2023 07:58:27 -0500 (EST) |
branch: externals/standard-themes
commit 15620a57bbfe288028aecae836be1f266b04b7f5
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make it possible to have recursive palette mapping
This means that a semantic colour mapping in the palette can have as
its value another mapping. The setup will find the underlying colour
or return the safe 'unspecified' value.
---
standard-themes.el | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/standard-themes.el b/standard-themes.el
index 018d69af4b..649510120c 100644
--- a/standard-themes.el
+++ b/standard-themes.el
@@ -2008,6 +2008,27 @@ Helper function for `standard-themes-preview-colors'."
;;; Theme macros
+(defun standard-themes--retrieve-palette-value (color palette)
+ "Return COLOR from PALETTE.
+Use recursion until COLOR is retrieved as a string. Refrain from
+doing so if the value of COLOR is not a key in the PALETTE.
+
+Return `unspecified' if the value of COLOR cannot be determined.
+This symbol is accepted by faces and is thus harmless.
+
+This function is used in the macros `standard-themes-theme',
+`standard-themes-with-colors'."
+ (let ((value (car (alist-get color palette))))
+ (cond
+ ((or (stringp value)
+ (eq value 'unspecified))
+ value)
+ ((and (symbolp value)
+ (memq value (mapcar #'car palette)))
+ (standard-themes--retrieve-palette-value value palette))
+ (t
+ 'unspecified))))
+
;;;###autoload
(defmacro standard-themes-theme (name palette &optional overrides)
"Bind NAME's color PALETTE around face specs and variables.
@@ -2025,10 +2046,7 @@ corresponding entries."
(,sym (append ,overrides standard-themes-common-palette-overrides
,palette))
,@(mapcar (lambda (color)
(list color
- `(let* ((value (car (alist-get ',color ,sym))))
- (if (stringp value)
- value
- (car (alist-get value ,sym))))))
+ `(standard-themes--retrieve-palette-value
',color ,sym)))
colors))
(custom-theme-set-faces ',name ,@standard-themes-faces)
(custom-theme-set-variables ',name
,@standard-themes-custom-variables))))
@@ -2049,10 +2067,7 @@ corresponding entries."
(,sym (standard-themes--current-theme-palette :overrides))
,@(mapcar (lambda (color)
(list color
- `(let* ((value (car (alist-get ',color ,sym))))
- (if (stringp value)
- value
- (car (alist-get value ,sym))))))
+ `(standard-themes--retrieve-palette-value
',color ,sym)))
colors))
(ignore c ,@colors) ; Silence unused variable warnings
,@body)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/standard-themes 15620a57bb: Make it possible to have recursive palette mapping,
ELPA Syncer <=