branch: externals/modus-themes
commit 88fca8fd42af01856474966227bdeb7a720e3db0
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Change how we get the palette for modus-themes-with-colors
This makes it so derivative theme actually get their own colours
instead of those coming from the core theme. Same for user-defined
palette overrides.
Another advantage of this approach is that we keep a separation of
concerns between the different uses we have for the palettes we
retrieve and the structure we want them to have. I prefer this over a
helper function that has to behave according to some optional
parameter.
This is in response to issue 175 by Fritz Gabo, which reports a bug
about derivative themes not getting the right colours when using
modus-themes-with-colors:
<https://github.com/protesilaos/modus-themes/issues/175>.
Also thanks to Roshan Shariff for testing my suggested changes (i.e.
this diff) and informing me of getting the expected results out of them.
---
doc/modus-themes.info | 34 +++++++++++++++----------------
doc/modus-themes.org | 24 +++++++++++-----------
modus-themes.el | 55 ++++++++++++++++++++++++++++-----------------------
3 files changed, 59 insertions(+), 54 deletions(-)
diff --git a/doc/modus-themes.info b/doc/modus-themes.info
index 658134281e..8bc0db7084 100644
--- a/doc/modus-themes.info
+++ b/doc/modus-themes.info
@@ -6449,18 +6449,18 @@ Ideas and user feedback
Olaf Meeuwissen, Oliver Epper, Pablo Stafforini, Paul Poloskov,
Pengji Zhang, Pete Kazmier, Peter Wu, Philip Kaludercic, Pierre
Téchoueyres, Przemysław Kryger, Robert Hepple, Roman Rudakov,
- Russell Sim, Ryan Phillips, Rytis Paškauskas, Rudolf Adamkovič, Sam
- Kleinman, Samuel Culpepper, Saša Janiška, Shreyas Ragavan, Simon
- Pugnet, Stéphane Marks, Steve Downey, Tassilo Horn, Thanos Apollo,
- Thibaut Verron, Thomas Heartman, Togan Muftuoglu, Tony Zorman, Trey
- Merkley, Tomasz Hołubowicz, Toon Claes, Uri Sharf, Utkarsh Singh,
- Vincent Foley, Zoltan Kiraly. As well as users: Ben,
- CsBigDataHub1, Emacs Contrib, Eugene, Fourchaux, Fredrik, Moesasji,
- Nick, Summer Emacs, TheBlob42, TitusMu, Trey, bepolymathe,
- bit9tream, bangedorrunt, case-lambda, chainedghost, derek-upham,
- doolio, fleimgruber, gitrj95, iSeeU, jixiuf, ltmsyvag, okamsn,
- pedro-nonfree, pRot0ta1p, shimeike, shipmints, soaringbird,
- tumashu, wakamenod.
+ Roshan Shariff, Russell Sim, Ryan Phillips, Rytis Paškauskas,
+ Rudolf Adamkovič, Sam Kleinman, Samuel Culpepper, Saša Janiška,
+ Shreyas Ragavan, Simon Pugnet, Stéphane Marks, Steve Downey,
+ Tassilo Horn, Thanos Apollo, Thibaut Verron, Thomas Heartman, Togan
+ Muftuoglu, Tony Zorman, Trey Merkley, Tomasz Hołubowicz, Toon
+ Claes, Uri Sharf, Utkarsh Singh, Vincent Foley, Zoltan Kiraly. As
+ well as users: Ben, CsBigDataHub1, Emacs Contrib, Eugene,
+ Fourchaux, Fredrik, Moesasji, Nick, Summer Emacs, TheBlob42,
+ TitusMu, Trey, bepolymathe, bit9tream, bangedorrunt, case-lambda,
+ chainedghost, derek-upham, doolio, fleimgruber, gitrj95, iSeeU,
+ jixiuf, ltmsyvag, okamsn, pedro-nonfree, pRot0ta1p, shimeike,
+ shipmints, soaringbird, tumashu, wakamenod.
Packaging
Basil L. Contovounesios, Eli Zaretskii, Glenn Morris, Mauro Aranda,
@@ -7300,11 +7300,11 @@ Node: Sources of the themes268176
Node: Issues you can help with269072
Node: Patches require copyright assignment to the FSF270464
Node: Acknowledgements272686
-Node: GNU Free Documentation License277263
-Node: Indices302426
-Node: Function index302605
-Node: Variable index306800
-Node: Concept index311163
+Node: GNU Free Documentation License277279
+Node: Indices302442
+Node: Function index302621
+Node: Variable index306816
+Node: Concept index311179
End Tag Table
diff --git a/doc/modus-themes.org b/doc/modus-themes.org
index 5fb307bc8d..a3379912ab 100644
--- a/doc/modus-themes.org
+++ b/doc/modus-themes.org
@@ -6257,18 +6257,18 @@ The Modus themes are a collective effort. Every bit of
work matters.
Foreest, Nicolas De Jaeghere, Nicolas Semrau, Olaf Meeuwissen,
Oliver Epper, Pablo Stafforini, Paul Poloskov, Pengji Zhang, Pete
Kazmier, Peter Wu, Philip Kaludercic, Pierre Téchoueyres, Przemysław
- Kryger, Robert Hepple, Roman Rudakov, Russell Sim, Ryan Phillips,
- Rytis Paškauskas, Rudolf Adamkovič, Sam Kleinman, Samuel Culpepper,
- Saša Janiška, Shreyas Ragavan, Simon Pugnet, Stéphane Marks, Steve
- Downey, Tassilo Horn, Thanos Apollo, Thibaut Verron, Thomas
- Heartman, Togan Muftuoglu, Tony Zorman, Trey Merkley, Tomasz
- Hołubowicz, Toon Claes, Uri Sharf, Utkarsh Singh, Vincent Foley,
- Zoltan Kiraly. As well as users: Ben, CsBigDataHub1, Emacs Contrib,
- Eugene, Fourchaux, Fredrik, Moesasji, Nick, Summer Emacs, TheBlob42,
- TitusMu, Trey, bepolymathe, bit9tream, bangedorrunt, case-lambda,
- chainedghost, derek-upham, doolio, fleimgruber, gitrj95, iSeeU,
- jixiuf, ltmsyvag, okamsn, pedro-nonfree, pRot0ta1p, shimeike,
- shipmints, soaringbird, tumashu, wakamenod.
+ Kryger, Robert Hepple, Roman Rudakov, Roshan Shariff, Russell Sim,
+ Ryan Phillips, Rytis Paškauskas, Rudolf Adamkovič, Sam Kleinman,
+ Samuel Culpepper, Saša Janiška, Shreyas Ragavan, Simon Pugnet,
+ Stéphane Marks, Steve Downey, Tassilo Horn, Thanos Apollo, Thibaut
+ Verron, Thomas Heartman, Togan Muftuoglu, Tony Zorman, Trey Merkley,
+ Tomasz Hołubowicz, Toon Claes, Uri Sharf, Utkarsh Singh, Vincent
+ Foley, Zoltan Kiraly. As well as users: Ben, CsBigDataHub1, Emacs
+ Contrib, Eugene, Fourchaux, Fredrik, Moesasji, Nick, Summer Emacs,
+ TheBlob42, TitusMu, Trey, bepolymathe, bit9tream, bangedorrunt,
+ case-lambda, chainedghost, derek-upham, doolio, fleimgruber,
+ gitrj95, iSeeU, jixiuf, ltmsyvag, okamsn, pedro-nonfree, pRot0ta1p,
+ shimeike, shipmints, soaringbird, tumashu, wakamenod.
+ Packaging :: Basil L.{{{space()}}} Contovounesios, Eli Zaretskii,
Glenn Morris, Mauro Aranda, Richard Stallman, Stefan Kangas (core
diff --git a/modus-themes.el b/modus-themes.el
index 87e2c2d71b..c4a3dc5d66 100644
--- a/modus-themes.el
+++ b/modus-themes.el
@@ -3859,7 +3859,7 @@ With optional NO-ENABLE, do not try to enable any themes."
(when (memq current (modus-themes-get-all-known-themes nil no-enable))
current)))
-(defun modus-themes--get-theme-palette-subr (theme with-overrides
with-user-palette &optional reverse)
+(defun modus-themes--get-theme-palette-subr (theme with-overrides
with-user-palette)
"Get THEME palette without `modus-themes-known-p'.
WITH-OVERRIDES and WITH-USER-PALETTE are described in
`modus-themes-get-theme-palette'.
@@ -3867,32 +3867,23 @@ WITH-OVERRIDES and WITH-USER-PALETTE are described in
If THEME does not have at least a `:modus-core-palette' among its
`theme-properties', return nil.
-With optional REVERSE, return the combined palette in the form of (CORE
-USER OVERRIDES). Else return (OVERRIDES USER CORE)."
+Else return (append OVERRIDES USER CORE)."
(when-let* ((properties (get theme 'theme-properties))
(core-palette (symbol-value (plist-get properties
:modus-core-palette))))
(let* ((user-palette (when with-user-palette (symbol-value (plist-get
properties :modus-user-palette))))
(overrides-palette (when with-overrides (symbol-value (plist-get
properties :modus-overrides-palette))))
(all-overrides (when with-overrides (append overrides-palette
modus-themes-common-palette-overrides))))
- (if reverse
- (append core-palette user-palette all-overrides)
- (append all-overrides user-palette core-palette)))))
+ (append all-overrides user-palette core-palette))))
-(defun modus-themes-get-theme-palette (&optional theme with-overrides
with-user-palette reverse)
+(defun modus-themes-get-theme-palette (&optional theme with-overrides
with-user-palette)
"Return palette value of active `modus-themes-get-themes' THEME.
If THEME is nil, use the return value of
`modus-themes-get-current-theme'. With WITH-OVERRIDES, include all
overrides in the combined palette. With WITH-USER-PALETTE do the same
-for the user-defined palette extension. With optional REVERSE, return
-the combined palette in the form of (append CORE USER OVERRIDES). Else
-return (append OVERRIDES USER CORE).
+for the user-defined palette extension.
-If THEME is unknown, return nil."
- (modus-themes--get-theme-palette-subr
- (or theme (modus-themes-get-current-theme))
- with-overrides
- with-user-palette
- reverse))
+If THEME is unknown, return nil. Else return (append OVERRIDES USER CORE)."
+ (modus-themes--get-theme-palette-subr (or theme
(modus-themes-get-current-theme)) with-overrides with-user-palette))
(defun modus-themes--disable-themes ()
"Disable themes per `modus-themes-disable-other-themes'."
@@ -7316,6 +7307,16 @@ Consult the manual for details on how to build a theme
on top of the
;;;; Use theme colors
+(defun modus-themes--with-colors-get-palette (theme)
+ "Get THEME palette for `modus-themes-with-colors'.
+Return (list CORE USER OVERRIDES) palettes."
+ (when-let* ((properties (get theme 'theme-properties))
+ (core-palette (symbol-value (plist-get properties
:modus-core-palette))))
+ (let* ((user-palette (symbol-value (plist-get properties
:modus-user-palette)))
+ (overrides-palette (symbol-value (plist-get properties
:modus-overrides-palette)))
+ (all-overrides (append overrides-palette
modus-themes-common-palette-overrides)))
+ (list core-palette user-palette all-overrides))))
+
(defun modus-themes--with-colors-resolve-palette-sort (colors)
"Sort all COLORS in the theme's palette.
Put all named colors before semantic color mappings. A named color is a
@@ -7324,14 +7325,18 @@ whose value is another symbol, which ultimately
resolves to a string or
`unspecified'."
(let ((named nil)
(semantic nil))
- (dolist (color colors)
- (if (stringp (cadr color))
- (push color named)
- (push color semantic)))
- (seq-uniq
- (nconc (nreverse named) (nreverse semantic))
- (lambda (elt1 elt2)
- (eq (car elt1) (car elt2))))))
+ (dolist (group colors)
+ (dolist (color group)
+ (if (stringp (cadr color))
+ (push color named)
+ (push color semantic))))
+ (let* ((unique-fn (lambda (sequence)
+ (seq-uniq sequence
+ (lambda (elt1 elt2)
+ (eq (car elt1) (car elt2))))))
+ (named-unique (funcall unique-fn named))
+ (semantic-unique (funcall unique-fn semantic)))
+ (nreverse (nconc semantic-unique named-unique)))))
(defun modus-themes-with-colors-subr (expressions)
"Do the work of `modus-themes-with-colors' for EXPRESSIONS."
@@ -7341,7 +7346,7 @@ whose value is another symbol, which ultimately resolves
to a string or
`(let* ((c '((class color) (min-colors 256)))
(unspecified 'unspecified)
,@(modus-themes--with-colors-resolve-palette-sort
- (modus-themes--get-theme-palette-subr theme
:with-overrides :with-user-palette :reverse)))
+ (modus-themes--with-colors-get-palette theme)))
,@expressions)
:lexical))
(error (message "Error in `modus-themes-with-colors': %s" data))))