[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ef-themes b3e1a7246c: Make it possible to override them
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ef-themes b3e1a7246c: Make it possible to override theme palette |
Date: |
Fri, 9 Dec 2022 23:57:35 -0500 (EST) |
branch: externals/ef-themes
commit b3e1a7246cdc7922904e6b9375bbf4941bb17522
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make it possible to override theme palette
---
README.org | 70 ++++++++++++++++++++++++++++++++++++++++++
ef-autumn-theme.el | 5 ++-
ef-bio-theme.el | 5 ++-
ef-cherie-theme.el | 5 ++-
ef-cyprus-theme.el | 5 ++-
ef-dark-theme.el | 5 ++-
ef-day-theme.el | 5 ++-
ef-deuteranopia-dark-theme.el | 5 ++-
ef-deuteranopia-light-theme.el | 5 ++-
ef-duo-dark-theme.el | 5 ++-
ef-duo-light-theme.el | 5 ++-
ef-frost-theme.el | 5 ++-
ef-light-theme.el | 5 ++-
ef-night-theme.el | 5 ++-
ef-spring-theme.el | 5 ++-
ef-summer-theme.el | 5 ++-
ef-themes.el | 48 ++++++++++++++++++++---------
ef-trio-dark-theme.el | 5 ++-
ef-trio-light-theme.el | 5 ++-
ef-tritanopia-dark-theme.el | 5 ++-
ef-tritanopia-light-theme.el | 5 ++-
ef-winter-theme.el | 5 ++-
22 files changed, 184 insertions(+), 34 deletions(-)
diff --git a/README.org b/README.org
index 36f41cd5a6..7185995d80 100644
--- a/README.org
+++ b/README.org
@@ -417,6 +417,73 @@ Other examples:
(setq ef-themes-region '(intense no-extend neutral))
#+end_src
+** Palette overrides
+:PROPERTIES:
+:CUSTOM_ID: h:4b923795-4b23-4345-81e5-d1c108a84b6a
+:END:
+#+cindex: Override color values and semantic color mappings
+
+[ Part of {{{development-version}}}. ]
+
+Each theme defines its own color palette as well as semantic color
+mappings. The former is the set of color values such as what shade of
+blue to use. The latter refers to associations between a color value
+and a syntactic construct, such as a =variable= for variables in
+programming modes or =heading-1= for level 1 headings in Org and
+others.
+
+The definition is stored in the variable =ef-NAME-palette=, where
+=NAME= is the specifier of the theme, such as ~ef-summer-palette~ for
+the ~ef-summer~ theme. Overrides for those associations are specified
+in the variable =ef-NAME-palette-overrides=.
+
+All associations take the form of =(KEY VALUE)= pairs. For example,
+the ~ef-summer-palette~ contains =(blue-warmer "#5250ef")=. Semantic
+color mappings are the same, though the =VALUE= is one of the named
+colors of the theme. For instance, =ef-summer-palette= maps the
+aforementioned =blue-warmer= to =variable= thus =(variable blue-warmer)=.
+
+The easiest way to learn about a theme's definition is to use the
+command ~describe-variable~ (bound to =C-h v= by default) and then
+search for the =ef-NAME-palette=. The resulting Help buffer will look
+like this:
+
+#+begin_example
+ef-summer-palette is a variable defined in ‘ef-summer-theme.el’.
+
+Its value is shown below.
+
+The ‘ef-summer’ palette.
+
+ This variable may be risky if used as a file-local variable.
+
+Value:
+((bg-main "#fff2f3")
+ (fg-main "#4f4073")
+
+[... Shortened for the purposes of this manual.]
+#+end_example
+
+The user can study this information to identify the overrides they
+wish to make. Then they can specify them and re-load the theme for
+changes to take effect. Sample of how to override a color value and a
+semantic mapping:
+
+#+begin_src emacs-lisp
+(setq ef-summer-palette-overrides
+ '((blue-warmer "#5230ff") ; original value is #5250ef
+ (variable cyan))) ; original value is blue-warmer
+#+end_src
+
+The overrides can contain as many associations as the user needs.
+
+Changes to color values are reflected in the preview of the theme's
+palette ([[#h:8dd67bf5-879e-46e5-b277-5bac141f53d1][Preview theme colors]]).
They are shown at the top of the
+buffer. In the above example, the first instance of =blue-warmer= is
+the override and the second is the original one.
+
+Contact me if you need further help with this.
+
* Loading a theme
:PROPERTIES:
:CUSTOM_ID: h:75d74aea-d17f-497f-a3b8-f0bf4c372de0
@@ -550,6 +617,9 @@ which reflects the given choice, like
=ef-summer-preview-colors= for the
The command ~ef-themes-preview-colors-current~ skips the minibuffer
selection process and just produces a preview for the current Ef theme.
+Overrides to color values are reflected in the buffers produced by the
+aforementioned commands ([[#h:4b923795-4b23-4345-81e5-d1c108a84b6a][Palette
overrides]]).
+
* Use colors from the active Ef theme
:PROPERTIES:
:CUSTOM_ID: h:5b74bd9e-e7f2-46b3-af2e-7c45b2e69245
diff --git a/ef-autumn-theme.el b/ef-autumn-theme.el
index 4ed9ed3a93..7f237de523 100644
--- a/ef-autumn-theme.el
+++ b/ef-autumn-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 yellow))
"The `ef-autumn' palette.")
- (ef-themes-theme ef-autumn ef-autumn-palette)
+ (defvar ef-autumn-palette-overrides nil
+ "Overrides for `ef-autumn-palette'.")
+
+ (ef-themes-theme ef-autumn ef-autumn-palette ef-autumn-palette-overrides)
(provide-theme 'ef-autumn))
diff --git a/ef-bio-theme.el b/ef-bio-theme.el
index 57b33160e8..f8b5b71de7 100644
--- a/ef-bio-theme.el
+++ b/ef-bio-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 magenta))
"The `ef-bio' palette.")
- (ef-themes-theme ef-bio ef-bio-palette)
+ (defvar ef-bio-palette-overrides nil
+ "Overrides for `ef-bio-palette'.")
+
+ (ef-themes-theme ef-bio ef-bio-palette ef-bio-palette-overrides)
(provide-theme 'ef-bio))
diff --git a/ef-cherie-theme.el b/ef-cherie-theme.el
index c21b161dac..6b21b6b5a0 100644
--- a/ef-cherie-theme.el
+++ b/ef-cherie-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 magenta-cooler))
"The `ef-cherie' palette.")
- (ef-themes-theme ef-cherie ef-cherie-palette)
+ (defvar ef-cherie-palette-overrides nil
+ "Overrides for `ef-cherie-palette'.")
+
+ (ef-themes-theme ef-cherie ef-cherie-palette ef-cherie-palette-overrides)
(provide-theme 'ef-cherie))
diff --git a/ef-cyprus-theme.el b/ef-cyprus-theme.el
index d245e02336..e4065dcac7 100644
--- a/ef-cyprus-theme.el
+++ b/ef-cyprus-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 red))
"The `ef-cyprus' palette.")
- (ef-themes-theme ef-cyprus ef-cyprus-palette)
+ (defvar ef-cyprus-palette-overrides nil
+ "Overrides for `ef-cyprus-palette'.")
+
+ (ef-themes-theme ef-cyprus ef-cyprus-palette ef-cyprus-palette-overrides)
(provide-theme 'ef-cyprus))
diff --git a/ef-dark-theme.el b/ef-dark-theme.el
index 5b8069a1b2..126815f2f5 100644
--- a/ef-dark-theme.el
+++ b/ef-dark-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 yellow))
"The `ef-dark' palette.")
- (ef-themes-theme ef-dark ef-dark-palette)
+ (defvar ef-dark-palette-overrides nil
+ "Overrides for `ef-dark-palette'.")
+
+ (ef-themes-theme ef-dark ef-dark-palette ef-dark-palette-overrides)
(provide-theme 'ef-dark))
diff --git a/ef-day-theme.el b/ef-day-theme.el
index 65f036ce66..e46ae82a62 100644
--- a/ef-day-theme.el
+++ b/ef-day-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 green-cooler))
"The `ef-day' palette.")
- (ef-themes-theme ef-day ef-day-palette)
+ (defvar ef-day-palette-overrides nil
+ "Overrides for `ef-day-palette'.")
+
+ (ef-themes-theme ef-day ef-day-palette ef-day-palette-overrides)
(provide-theme 'ef-day))
diff --git a/ef-deuteranopia-dark-theme.el b/ef-deuteranopia-dark-theme.el
index 9bee52fb3f..5b1a352a21 100644
--- a/ef-deuteranopia-dark-theme.el
+++ b/ef-deuteranopia-dark-theme.el
@@ -205,7 +205,10 @@
(rainbow-8 magenta-faint))
"The `ef-deuteranopia-dark' palette.")
- (ef-themes-theme ef-deuteranopia-dark ef-deuteranopia-dark-palette)
+ (defvar ef-deuteranopia-dark-palette-overrides nil
+ "Overrides for `ef-deuteranopia-dark-palette'.")
+
+ (ef-themes-theme ef-deuteranopia-dark ef-deuteranopia-dark-palette
ef-deuteranopia-dark-palette-overrides)
(provide-theme 'ef-deuteranopia-dark))
diff --git a/ef-deuteranopia-light-theme.el b/ef-deuteranopia-light-theme.el
index 57b299a8e8..acc1123606 100644
--- a/ef-deuteranopia-light-theme.el
+++ b/ef-deuteranopia-light-theme.el
@@ -205,7 +205,10 @@
(rainbow-8 cyan))
"The `ef-deuteranopia-light' palette.")
- (ef-themes-theme ef-deuteranopia-light ef-deuteranopia-light-palette)
+ (defvar ef-deuteranopia-light-palette-overrides nil
+ "Overrides for `ef-deuteranopia-light-palette'.")
+
+ (ef-themes-theme ef-deuteranopia-light ef-deuteranopia-light-palette
ef-deuteranopia-light-palette-overrides)
(provide-theme 'ef-deuteranopia-light))
diff --git a/ef-duo-dark-theme.el b/ef-duo-dark-theme.el
index 22c476f448..056005fbce 100644
--- a/ef-duo-dark-theme.el
+++ b/ef-duo-dark-theme.el
@@ -205,7 +205,10 @@
(rainbow-8 green-cooler))
"The `ef-duo-dark' palette.")
- (ef-themes-theme ef-duo-dark ef-duo-dark-palette)
+ (defvar ef-duo-dark-palette-overrides nil
+ "Overrides for `ef-duo-dark-palette'.")
+
+ (ef-themes-theme ef-duo-dark ef-duo-dark-palette
ef-duo-dark-palette-overrides)
(provide-theme 'ef-duo-dark))
diff --git a/ef-duo-light-theme.el b/ef-duo-light-theme.el
index 0ad7383018..d83f1ce421 100644
--- a/ef-duo-light-theme.el
+++ b/ef-duo-light-theme.el
@@ -206,7 +206,10 @@
(rainbow-8 green-cooler))
"The `ef-duo-light' palette.")
- (ef-themes-theme ef-duo-light ef-duo-light-palette)
+ (defvar ef-duo-light-palette-overrides nil
+ "Overrides for `ef-duo-light-palette'.")
+
+ (ef-themes-theme ef-duo-light ef-duo-light-palette
ef-duo-light-palette-overrides)
(provide-theme 'ef-duo-light))
diff --git a/ef-frost-theme.el b/ef-frost-theme.el
index 780dcf30d6..3411b12d12 100644
--- a/ef-frost-theme.el
+++ b/ef-frost-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 cyan-warmer))
"The `ef-frost' palette.")
- (ef-themes-theme ef-frost ef-frost-palette)
+ (defvar ef-frost-palette-overrides nil
+ "Overrides for `ef-frost-palette'.")
+
+ (ef-themes-theme ef-frost ef-frost-palette ef-frost-palette-overrides)
(provide-theme 'ef-frost))
diff --git a/ef-light-theme.el b/ef-light-theme.el
index 28c6aac5db..06f1d9c275 100644
--- a/ef-light-theme.el
+++ b/ef-light-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 yellow))
"The `ef-light' palette.")
- (ef-themes-theme ef-light ef-light-palette)
+ (defvar ef-light-palette-overrides nil
+ "Overrides for `ef-light-palette'.")
+
+ (ef-themes-theme ef-light ef-light-palette ef-light-palette-overrides)
(provide-theme 'ef-light))
diff --git a/ef-night-theme.el b/ef-night-theme.el
index 8b5c57217c..71df32e7d4 100644
--- a/ef-night-theme.el
+++ b/ef-night-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 green-warmer))
"The `ef-night' palette.")
- (ef-themes-theme ef-night ef-night-palette)
+ (defvar ef-night-palette-overrides nil
+ "Overrides for `ef-night-palette'.")
+
+ (ef-themes-theme ef-night ef-night-palette ef-night-palette-overrides)
(provide-theme 'ef-night))
diff --git a/ef-spring-theme.el b/ef-spring-theme.el
index 3b1fdc654c..f2ab6e54d4 100644
--- a/ef-spring-theme.el
+++ b/ef-spring-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 yellow-cooler))
"The `ef-spring' palette.")
- (ef-themes-theme ef-spring ef-spring-palette)
+ (defvar ef-spring-palette-overrides nil
+ "Overrides for `ef-spring-palette'.")
+
+ (ef-themes-theme ef-spring ef-spring-palette ef-spring-palette-overrides)
(provide-theme 'ef-spring))
diff --git a/ef-summer-theme.el b/ef-summer-theme.el
index ccf5af3d86..d970dec112 100644
--- a/ef-summer-theme.el
+++ b/ef-summer-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 yellow-cooler))
"The `ef-summer' palette.")
- (ef-themes-theme ef-summer ef-summer-palette)
+ (defvar ef-summer-palette-overrides nil
+ "Overrides for `ef-summer-palette'.")
+
+ (ef-themes-theme ef-summer ef-summer-palette ef-summer-palette-overrides)
(provide-theme 'ef-summer))
diff --git a/ef-themes.el b/ef-themes.el
index f2ce782bce..58f857ba19 100644
--- a/ef-themes.el
+++ b/ef-themes.el
@@ -415,15 +415,32 @@ foreground that is used with any of the intense
backgrounds."
"Return first enabled Ef theme."
(car (ef-themes--list-enabled-themes)))
-(defun ef-themes--palette (theme)
- "Return THEME palette as a symbol."
- (when theme
- (intern (format "%s-palette" theme))))
-
-(defun ef-themes--current-theme-palette ()
- "Return palette of active Ef theme, else produce `user-error'."
- (if-let* ((palette (ef-themes--palette (ef-themes--current-theme))))
- (symbol-value palette)
+(defun ef-themes--palette-symbol (theme &optional overrides)
+ "Return THEME palette as a symbol.
+With optional OVERRIDES, return THEME palette overrides as a
+symbol."
+ (when-let ((suffix (cond
+ ((and theme overrides)
+ "palette-overrides")
+ (theme
+ "palette"))))
+ (intern (format "%s-%s" theme suffix))))
+
+(defun ef-themes--palette-value (theme &optional overrides)
+ "Return palette value of THEME with optional OVERRIDES."
+ (let ((base-value (symbol-value (ef-themes--palette-symbol theme))))
+ (if overrides
+ (append (symbol-value (ef-themes--palette-symbol theme :overrides))
base-value)
+ base-value)))
+
+(defun ef-themes--current-theme-palette (&optional overrides)
+ "Return palette value of active Ef theme, else produce `user-error'.
+With optional OVERRIDES return palette value plus whatever
+overrides."
+ (if-let ((theme (ef-themes--current-theme)))
+ (if overrides
+ (ef-themes--palette-value theme :overrides)
+ (ef-themes--palette-value theme))
(user-error "No enabled Ef theme could be found")))
(defun ef-themes--choose-subset ()
@@ -552,7 +569,7 @@ symbol."
Routine for `ef-themes-preview-colors'."
(let ((palette (seq-remove (lambda (cell)
(symbolp (cadr cell)))
- (symbol-value (ef-themes--palette theme))))
+ (ef-themes--palette-value theme :overrides)))
(current-buffer buffer)
(current-theme theme))
(with-help-window buffer
@@ -1953,17 +1970,20 @@ Helper function for `ef-themes-preview-colors'."
;;;; Instantiate an Ef theme
;;;###autoload
-(defmacro ef-themes-theme (name palette)
+(defmacro ef-themes-theme (name palette &optional overrides)
"Bind NAME's color PALETTE around face specs and variables.
Face specifications are passed to `custom-theme-set-faces'.
While variables are handled by `custom-theme-set-variables'.
Those are stored in `ef-themes-faces' and
-`ef-themes-custom-variables' respectively."
+`ef-themes-custom-variables' respectively.
+
+Optional OVERRIDES are appended to PALETTE, overriding
+corresponding entries."
(declare (indent 0))
(let ((sym (gensym))
(colors (mapcar #'car (symbol-value palette))))
`(let* ((c '((class color) (min-colors 256)))
- (,sym ,palette)
+ (,sym (append ,overrides ,palette))
,@(mapcar (lambda (color)
(list color
`(let* ((value (car (alist-get ',color ,sym))))
@@ -1987,7 +2007,7 @@ Those are stored in `ef-themes-faces' and
;; inside a function.
(colors (mapcar #'car (ef-themes--current-theme-palette))))
`(let* ((c '((class color) (min-colors 256)))
- (,sym (ef-themes--current-theme-palette))
+ (,sym (ef-themes--current-theme-palette :overrides))
,@(mapcar (lambda (color)
(list color
`(let* ((value (car (alist-get ',color ,sym))))
diff --git a/ef-trio-dark-theme.el b/ef-trio-dark-theme.el
index 177b33eaf7..805f601543 100644
--- a/ef-trio-dark-theme.el
+++ b/ef-trio-dark-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 yellow-cooler))
"The `ef-trio-dark' palette.")
- (ef-themes-theme ef-trio-dark ef-trio-dark-palette)
+ (defvar ef-trio-dark-palette-overrides nil
+ "Overrides for `ef-trio-dark-palette'.")
+
+ (ef-themes-theme ef-trio-dark ef-trio-dark-palette
ef-trio-dark-palette-overrides)
(provide-theme 'ef-trio-dark))
diff --git a/ef-trio-light-theme.el b/ef-trio-light-theme.el
index 05bbd72cfc..5c8f437b40 100644
--- a/ef-trio-light-theme.el
+++ b/ef-trio-light-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 yellow-cooler))
"The `ef-trio-light' palette.")
- (ef-themes-theme ef-trio-light ef-trio-light-palette)
+ (defvar ef-trio-light-palette-overrides nil
+ "Overrides for `ef-trio-light-palette'.")
+
+ (ef-themes-theme ef-trio-light ef-trio-light-palette
ef-trio-light-palette-overrides)
(provide-theme 'ef-trio-light))
diff --git a/ef-tritanopia-dark-theme.el b/ef-tritanopia-dark-theme.el
index b9c8e6fbe2..88576c1162 100644
--- a/ef-tritanopia-dark-theme.el
+++ b/ef-tritanopia-dark-theme.el
@@ -205,7 +205,10 @@
(rainbow-8 red-faint))
"The `ef-tritanopia-dark' palette.")
- (ef-themes-theme ef-tritanopia-dark ef-tritanopia-dark-palette)
+ (defvar ef-tritanopia-dark-palette-overrides nil
+ "Overrides for `ef-tritanopia-dark-palette'.")
+
+ (ef-themes-theme ef-tritanopia-dark ef-tritanopia-dark-palette
ef-tritanopia-dark-palette-overrides)
(provide-theme 'ef-tritanopia-dark))
diff --git a/ef-tritanopia-light-theme.el b/ef-tritanopia-light-theme.el
index fb408a4d84..126c181baf 100644
--- a/ef-tritanopia-light-theme.el
+++ b/ef-tritanopia-light-theme.el
@@ -205,7 +205,10 @@
(rainbow-8 red-faint))
"The `ef-tritanopia-light' palette.")
- (ef-themes-theme ef-tritanopia-light ef-tritanopia-light-palette)
+ (defvar ef-tritanopia-light-palette-overrides nil
+ "Overrides for `ef-tritanopia-light-palette'.")
+
+ (ef-themes-theme ef-tritanopia-light ef-tritanopia-light-palette
ef-tritanopia-light-palette-overrides)
(provide-theme 'ef-tritanopia-light))
diff --git a/ef-winter-theme.el b/ef-winter-theme.el
index f17a342028..b361cfe164 100644
--- a/ef-winter-theme.el
+++ b/ef-winter-theme.el
@@ -202,7 +202,10 @@
(rainbow-8 cyan-warmer))
"The `ef-winter' palette.")
- (ef-themes-theme ef-winter ef-winter-palette)
+ (defvar ef-winter-palette-overrides nil
+ "Overrides for `ef-winter-palette'.")
+
+ (ef-themes-theme ef-winter ef-winter-palette ef-winter-palette-overrides)
(provide-theme 'ef-winter))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/ef-themes b3e1a7246c: Make it possible to override theme palette,
ELPA Syncer <=