branch: externals/ef-themes commit 9bbb2fb45ee9c3ebcfc8458ca4a1850a123dcb6b Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Include point of entry for shared overrides (extend b3e1a72) --- README.org | 10 +++++++++- ef-themes.el | 13 ++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 4da2e4d01c..1f265dc8ff 100644 --- a/README.org +++ b/README.org @@ -423,7 +423,9 @@ Other examples: :END: #+cindex: Override color values and semantic color mappings -[ Part of {{{development-version}}}. ] +[ Part of {{{development-version}}}. For a video demo of the same +idea that I implemented in the ~modus-themes~, check: +https://protesilaos.com/codelog/2022-12-17-modus-themes-v4-demo/. ] 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 @@ -437,6 +439,12 @@ The definition is stored in the variable =ef-NAME-palette=, where ~ef-summer~ theme. Overrides for those associations are specified in the variable =ef-NAME-palette-overrides=. +#+vindex: ef-themes-common-palette-overrides +The variable ~ef-themes-common-palette-overrides~ is available for +shared values. It is advised to only use this for mappings that do +not specify a color value directly. This way, the text remains +legible by getting the theme-specific color value it needs. + 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 diff --git a/ef-themes.el b/ef-themes.el index b37ce941cc..59873ad1c2 100644 --- a/ef-themes.el +++ b/ef-themes.el @@ -1969,6 +1969,17 @@ Helper function for `ef-themes-preview-colors'." ;;;; Instantiate an Ef theme +(defvar ef-themes-common-palette-overrides nil + "Set palette overrides for all the Modus themes. + +Mirror the elements of a theme's palette, overriding their value. +The palette variables are named THEME-NAME-palette, while +individual theme overrides are THEME-NAME-palette-overrides. The +THEME-NAME is one of the symbols in `modus-themes-items'. + +Individual theme overrides take precedence over these common +overrides.") + ;;;###autoload (defmacro ef-themes-theme (name palette &optional overrides) "Bind NAME's color PALETTE around face specs and variables. @@ -1983,7 +1994,7 @@ corresponding entries." (let ((sym (gensym)) (colors (mapcar #'car (symbol-value palette)))) `(let* ((c '((class color) (min-colors 256))) - (,sym (append ,overrides ,palette)) + (,sym (append ,overrides ef-themes-common-palette-overrides ,palette)) ,@(mapcar (lambda (color) (list color `(let* ((value (car (alist-get ',color ,sym))))