[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/alect-themes 27bdbbf 047/269: Add support for substituting
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/alect-themes 27bdbbf 047/269: Add support for substituting colors |
Date: |
Thu, 21 Oct 2021 17:58:46 -0400 (EDT) |
branch: elpa/alect-themes
commit 27bdbbf97a8bffc958da81e20ba8e9dee140d193
Author: Alex Kost <alezost@gmail.com>
Commit: Alex Kost <alezost@gmail.com>
Add support for substituting colors
---
alect-themes.el | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/alect-themes.el b/alect-themes.el
index 71751a7..f560b1d 100644
--- a/alect-themes.el
+++ b/alect-themes.el
@@ -1208,6 +1208,60 @@ static char *gnus-pointer[] = {
(vc-annotate-background ,(gc 'bg-2))
))))
+(defun alect-substitute-color (theme-name plist prop)
+ "Substitute color name for property PROP in property list PLIST.
+
+Return plist with substituted color value. Replace a color only
+if PROP contains such color name (symbol from `alect-colors').
+
+This function is destructive: PLIST may not stay the same.
+
+See `alect-substitute-colors-in-plist' for details."
+ (let ((color-name (plist-get plist prop))
+ color-val)
+ (and (symbolp color-name)
+ (setq color-val (alect-get-color theme-name color-name))
+ (setq plist (plist-put plist prop color-val)))
+ plist))
+
+(defun alect-substitute-colors-in-plist (theme-name plist)
+ "Substitute color names in property list PLIST with color values.
+
+Color values (strings) are defined by color names (symbols) for a
+specified theme THEME-NAME from `alect-colors' variable. Replace
+colors for the `:foreground' and `:background' properties. If
+there is also `:box' property in PLIST, replace its `:color'
+property as well.
+
+Return plist with substituted colors. This function is
+destructive: PLIST may not stay the same."
+ (setq plist (alect-substitute-color theme-name plist :foreground))
+ (setq plist (alect-substitute-color theme-name plist :background))
+ (let ((box-plist (plist-get plist :box)))
+ (and box-plist
+ (setq box-plist (alect-substitute-color theme-name box-plist :color))
+ (setq plist (plist-put plist :box box-plist))))
+ plist)
+
+(defun alect-substitute-colors-in-faces (theme-name faces)
+ "Substitute color names in a list FACES with color values.
+
+FACES is a list of face specifications accepted by
+`custom-theme-set-faces'.
+
+Return a list of faces with substituted colors. This function is
+destructive: FACES may not stay the same.
+
+See `alect-substitute-colors-in-plist' for details."
+ (mapcar (lambda (face)
+ (list (car face)
+ (mapcar (lambda (spec)
+ (list (car spec)
+ (alect-substitute-colors-in-plist
+ theme-name (cadr spec))))
+ (cadr face))))
+ faces))
+
(defun alect-override-faces (original overriding)
"Override faces from ORIGINAL list with faces from OVERRIDING list.
@@ -1236,7 +1290,8 @@ For INVERT, see `alect-get-color'."
(theme-vals (alect-get-customization theme invert))
(theme-faces (alect-override-faces
(car theme-vals)
- alect-overriding-faces))
+ (alect-substitute-colors-in-faces
+ theme alect-overriding-faces)))
(theme-vars (cdr theme-vals)))
;; FIXME is there a way to avoid this?: variables are not set with
;; `custom-theme-set-variables' if they have not been defined yet
- [nongnu] elpa/alect-themes 324846b 020/269: Modify some header faces, (continued)
- [nongnu] elpa/alect-themes 324846b 020/269: Modify some header faces, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 205fc96 031/269: Update links to screenshots, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 1dff81a 032/269: Add a link to imgur album, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 7aa0a21 033/269: Add magit faces, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 90d116e 034/269: Add magit screenshots, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 91e0db8 035/269: Generalize date/time faces, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes fab91c0 036/269: Generalize faces for selected items, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 00181ec 038/269: Update package commentary, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes faf3f53 039/269: Add `alect-prompt' face, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 786cb90 043/269: Inherit comment delimiter from comment face, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 27bdbbf 047/269: Add support for substituting colors,
ELPA Syncer <=
- [nongnu] elpa/alect-themes 61dac55 051/269: Update README, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes b0a96eb 063/269: Modify red colors for the dark theme, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes ba7beed 007/269: Add .gitignore, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes b51ffad 012/269: Update README, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes e25ff17 008/269: Update package commentary, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 2591fdd 013/269: Add faces for sh-mode, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes fbf0829 011/269: Update colors sample, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes dc88e28 015/269: Add customization type for `alect-colors' variable, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 3139f1a 017/269: Add description of customizing color palettes, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 95c7091 021/269: Combine `alect-get-faces' and `alect-get-vars', ELPA Syncer, 2021/10/21