emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ef-themes ab7a23d8e5: Make it possible to have recursiv


From: ELPA Syncer
Subject: [elpa] externals/ef-themes ab7a23d8e5: Make it possible to have recursive palette mapping
Date: Wed, 4 Jan 2023 07:57:49 -0500 (EST)

branch: externals/ef-themes
commit ab7a23d8e5e94bc6f181eec419ae63c23f60f190
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.
---
 ef-themes.el | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/ef-themes.el b/ef-themes.el
index 0035e2e84e..a17fcff8ba 100644
--- a/ef-themes.el
+++ b/ef-themes.el
@@ -1982,6 +1982,27 @@ Helper function for `ef-themes-preview-colors'."
 
 ;;; Theme macros
 
+(defun ef-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 `ef-themes-theme',
+`ef-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)))
+      (ef-themes--retrieve-palette-value value palette))
+     (t
+      'unspecified))))
+
 ;;;; Instantiate an Ef theme
 
 ;;;###autoload
@@ -2001,10 +2022,7 @@ corresponding entries."
             (,sym (append ,overrides ef-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))))))
+                              `(ef-themes--retrieve-palette-value ',color 
,sym)))
                       colors))
        (custom-theme-set-faces ',name ,@ef-themes-faces)
        (custom-theme-set-variables ',name ,@ef-themes-custom-variables))))
@@ -2025,10 +2043,7 @@ corresponding entries."
             (,sym (ef-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))))))
+                              `(ef-themes--retrieve-palette-value ',color 
,sym)))
                       colors))
        (ignore c ,@colors)            ; Silence unused variable warnings
        ,@body)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]