branch: externals/modus-themes
commit ec8f8a80b18e70a5c2ebef7fbc5ce0253def22d2
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Conditionally push to mappings in modus-themes-generate-palette
I think this is done now. All that remains is to (i) polish the
derived colors because some of them are not nice and (ii) check the
code again to make sure I am not being sloppy.
---
modus-themes.el | 140 ++++++++++++++++++++++++++++----------------------------
1 file changed, 71 insertions(+), 69 deletions(-)
diff --git a/modus-themes.el b/modus-themes.el
index bd41541ed9..a117457fcc 100644
--- a/modus-themes.el
+++ b/modus-themes.el
@@ -7619,17 +7619,20 @@ With optional MAPPINGS use them instead of trying to
derive new ones."
(or (eq (car name) 'bg-main)
(eq (car name) 'fg-main)))
base-colors))
- (derivatives nil)
- (color-mappings mappings)
(prefers-cool-p (cond
((and cool-or-warm-preference (memq
cool-or-warm-preference '(cool warm)))
(eq cool-or-warm-preference 'cool))
((modus-themes-color-is-warm-or-cool-p bg-main
'cool))
(t
(error "The COOL-OR-WARM-PREFERENCE must be
either `cool' or `warm', not `%S'" cool-or-warm-preference))))
+ (derived-colors nil)
+ (derived-mappings nil)
(push-derived-value-fn (lambda (name value)
(unless (assq name base-colors)
- (push (list name value) derivatives)))))
+ (push (list name value)
derived-colors))))
+ (push-mapping-fn (lambda (name value)
+ (unless (assq name mappings)
+ (push (list name value) derived-mappings)))))
;; Base entries
(funcall push-derived-value-fn 'bg-dim (modus-themes-generate-gradient
bg-main 5))
(funcall push-derived-value-fn 'bg-active
(modus-themes-generate-gradient bg-main 10))
@@ -7646,72 +7649,71 @@ With optional MAPPINGS use them instead of trying to
derive new ones."
(funcall push-derived-value-fn (intern (format "bg-%s-intense" name))
(modus-themes-generate-gradient value (if bg-main-dark-p -30 30)))
(funcall push-derived-value-fn (intern (format "bg-%s-subtle" name))
(modus-themes-generate-gradient value (if bg-main-dark-p -50 50)))
(funcall push-derived-value-fn (intern (format "bg-%s-nuanced" name))
(modus-themes-generate-gradient value (if bg-main-dark-p -70 70))))
- ;; TODO 2025-11-24: For the color mappings we want the equivalent of
push-derived-fn.
- (unless color-mappings
- ;; Mappings
- (push (list 'bg-completion (if prefers-cool-p 'bg-cyan-subtle
'bg-yellow-subtle)) color-mappings)
- (push (list 'bg-hover (if prefers-cool-p 'bg-green-intense
'bg-magenta-intense)) color-mappings)
- (push (list 'bg-hover-secondary (if prefers-cool-p 'bg-green-subtle
'bg-magenta-subtle)) color-mappings)
- (push (list 'bg-hl-line (if prefers-cool-p 'bg-cyan-nuanced
'bg-yellow-nuanced)) color-mappings)
- (push (list 'bg-paren-match (if prefers-cool-p 'bg-green-intense
'bg-yellow-subtle)) color-mappings)
- (push (list 'bg-paren-expression (if prefers-cool-p 'bg-green-nuanced
'bg-yellow-nuanced)) color-mappings)
- (push (list 'bg-region 'bg-active) color-mappings)
- (push (list 'fg-region 'fg-main) color-mappings)
-
- (push (list 'bg-mode-line-active 'bg-active) color-mappings)
- (push (list 'fg-mode-line-active 'fg-main) color-mappings)
- (push (list 'border-mode-line-active 'border) color-mappings)
- (push (list 'bg-mode-line-inactive 'bg-inactive) color-mappings)
- (push (list 'fg-mode-line-inactive 'fg-dim) color-mappings)
- (push (list 'border-mode-line-inactive 'border) color-mappings)
-
- (push (list 'modeline-err 'red-faint) color-mappings)
- (push (list 'modeline-warning 'yellow-faint) color-mappings)
- (push (list 'modeline-info 'blue-faint) color-mappings)
-
- (push (list 'bg-tab-bar 'bg-dim) color-mappings)
- (push (list 'bg-tab-current 'bg-main) color-mappings)
- (push (list 'bg-tab-other 'bg-inactive) color-mappings)
-
- (push (list 'bg-added 'bg-green-subtle) color-mappings)
- (push (list 'bg-added-faint 'bg-green-nuanced) color-mappings)
- (push (list 'bg-added-refine 'bg-green-intense) color-mappings)
- (push (list 'fg-added 'green-faint) color-mappings)
- (push (list 'fg-added-intense 'green-intense) color-mappings)
-
- (push (list 'bg-changed 'bg-yellow-subtle) color-mappings)
- (push (list 'bg-changed-faint 'bg-yellow-nuanced) color-mappings)
- (push (list 'bg-changed-refine 'bg-yellow-intense) color-mappings)
- (push (list 'fg-changed 'yellow-faint) color-mappings)
- (push (list 'fg-changed-intense 'yellow-intense) color-mappings)
-
- (push (list 'bg-removed 'bg-red-subtle) color-mappings)
- (push (list 'bg-removed-faint 'bg-red-nuanced) color-mappings)
- (push (list 'bg-removed-refine 'bg-red-intense) color-mappings)
- (push (list 'fg-removed 'red-faint) color-mappings)
- (push (list 'fg-removed-intense 'red-intense) color-mappings)
-
- (push (list 'fg-heading-0 'fg-alt) color-mappings)
- (push (list 'fg-heading-1 'fg-main) color-mappings)
- (push (list 'fg-heading-2 (if prefers-cool-p 'cyan 'yellow))
color-mappings)
- (push (list 'fg-heading-3 (if prefers-cool-p 'green 'magenta))
color-mappings)
- (push (list 'fg-heading-4 (if prefers-cool-p 'blue 'red))
color-mappings)
- (push (list 'fg-heading-5 (if prefers-cool-p 'yellow 'cyan))
color-mappings)
- (push (list 'fg-heading-6 (if prefers-cool-p 'magenta 'green))
color-mappings)
- (push (list 'fg-heading-7 (if prefers-cool-p 'red 'blue))
color-mappings)
- (push (list 'fg-heading-8 'fg-dim) color-mappings)
-
- (push (list 'bg-term-black (if bg-main-dark-p 'bg-main 'fg-main))
color-mappings)
- (push (list 'bg-term-black-bright (if bg-main-dark-p 'bg-active
'fg-dim)) color-mappings)
- (push (list 'fg-term-black (if bg-main-dark-p 'bg-main 'fg-main))
color-mappings)
- (push (list 'fg-term-black-bright (if bg-main-dark-p 'bg-active
'fg-dim)) color-mappings)
-
- (push (list 'bg-term-white (if bg-main-dark-p 'fg-dim 'bg-active))
color-mappings)
- (push (list 'bg-term-white-bright (if bg-main-dark-p 'fg-main
'bg-main)) color-mappings)
- (push (list 'fg-term-white (if bg-main-dark-p 'fg-dim 'bg-active))
color-mappings)
- (push (list 'fg-term-white-bright (if bg-main-dark-p 'fg-main
'bg-main)) color-mappings))
-
- (let* ((initial-new-palette (append base-colors derivatives))
+ ;; Mappings
+ (funcall push-mapping-fn 'bg-completion (if prefers-cool-p
'bg-cyan-subtle 'bg-yellow-subtle))
+ (funcall push-mapping-fn 'bg-hover (if prefers-cool-p 'bg-green-intense
'bg-magenta-intense))
+ (funcall push-mapping-fn 'bg-hover-secondary (if prefers-cool-p
'bg-green-subtle 'bg-magenta-subtle))
+ (funcall push-mapping-fn 'bg-hl-line (if prefers-cool-p 'bg-cyan-nuanced
'bg-yellow-nuanced))
+ (funcall push-mapping-fn 'bg-paren-match (if prefers-cool-p
'bg-green-intense 'bg-yellow-subtle))
+ (funcall push-mapping-fn 'bg-paren-expression (if prefers-cool-p
'bg-green-nuanced 'bg-yellow-nuanced))
+ (funcall push-mapping-fn 'bg-region 'bg-active)
+ (funcall push-mapping-fn 'fg-region 'fg-main)
+
+ (funcall push-mapping-fn 'bg-mode-line-active 'bg-active)
+ (funcall push-mapping-fn 'fg-mode-line-active 'fg-main)
+ (funcall push-mapping-fn 'border-mode-line-active 'border)
+ (funcall push-mapping-fn 'bg-mode-line-inactive 'bg-inactive)
+ (funcall push-mapping-fn 'fg-mode-line-inactive 'fg-dim)
+ (funcall push-mapping-fn 'border-mode-line-inactive 'border)
+
+ (funcall push-mapping-fn 'modeline-err 'red-faint)
+ (funcall push-mapping-fn 'modeline-warning 'yellow-faint)
+ (funcall push-mapping-fn 'modeline-info 'blue-faint)
+
+ (funcall push-mapping-fn 'bg-tab-bar 'bg-dim)
+ (funcall push-mapping-fn 'bg-tab-current 'bg-main)
+ (funcall push-mapping-fn 'bg-tab-other 'bg-inactive)
+
+ (funcall push-mapping-fn 'bg-added 'bg-green-subtle)
+ (funcall push-mapping-fn 'bg-added-faint 'bg-green-nuanced)
+ (funcall push-mapping-fn 'bg-added-refine 'bg-green-intense)
+ (funcall push-mapping-fn 'fg-added 'green-faint)
+ (funcall push-mapping-fn 'fg-added-intense 'green-intense)
+
+ (funcall push-mapping-fn 'bg-changed 'bg-yellow-subtle)
+ (funcall push-mapping-fn 'bg-changed-faint 'bg-yellow-nuanced)
+ (funcall push-mapping-fn 'bg-changed-refine 'bg-yellow-intense)
+ (funcall push-mapping-fn 'fg-changed 'yellow-faint)
+ (funcall push-mapping-fn 'fg-changed-intense 'yellow-intense)
+
+ (funcall push-mapping-fn 'bg-removed 'bg-red-subtle)
+ (funcall push-mapping-fn 'bg-removed-faint 'bg-red-nuanced)
+ (funcall push-mapping-fn 'bg-removed-refine 'bg-red-intense)
+ (funcall push-mapping-fn 'fg-removed 'red-faint)
+ (funcall push-mapping-fn 'fg-removed-intense 'red-intense)
+
+ (funcall push-mapping-fn 'fg-heading-0 'fg-alt)
+ (funcall push-mapping-fn 'fg-heading-1 'fg-main)
+ (funcall push-mapping-fn 'fg-heading-2 (if prefers-cool-p 'cyan 'yellow))
+ (funcall push-mapping-fn 'fg-heading-3 (if prefers-cool-p 'green
'magenta))
+ (funcall push-mapping-fn 'fg-heading-4 (if prefers-cool-p 'blue 'red))
+ (funcall push-mapping-fn 'fg-heading-5 (if prefers-cool-p 'yellow 'cyan))
+ (funcall push-mapping-fn 'fg-heading-6 (if prefers-cool-p 'magenta
'green))
+ (funcall push-mapping-fn 'fg-heading-7 (if prefers-cool-p 'red 'blue))
+ (funcall push-mapping-fn 'fg-heading-8 'fg-dim)
+
+ (funcall push-mapping-fn 'bg-term-black (if bg-main-dark-p 'bg-main
'fg-main))
+ (funcall push-mapping-fn 'bg-term-black-bright (if bg-main-dark-p
'bg-active 'fg-dim))
+ (funcall push-mapping-fn 'fg-term-black (if bg-main-dark-p 'bg-main
'fg-main))
+ (funcall push-mapping-fn 'fg-term-black-bright (if bg-main-dark-p
'bg-active 'fg-dim))
+
+ (funcall push-mapping-fn 'bg-term-white (if bg-main-dark-p 'fg-dim
'bg-active))
+ (funcall push-mapping-fn 'bg-term-white-bright (if bg-main-dark-p
'fg-main 'bg-main))
+ (funcall push-mapping-fn 'fg-term-white (if bg-main-dark-p 'fg-dim
'bg-active))
+ (funcall push-mapping-fn 'fg-term-white-bright (if bg-main-dark-p
'fg-main 'bg-main))
+
+ (let* ((new-colors (append base-colors derived-colors))
+ (new-mappings (append mappings derived-mappings))
;; We have to add one of the core palettes to make sure
;; there are no missing entries. We will then remove
;; duplicates.