Revise modus-themes-with-colors to work with dynamic variables

This is how it used to be. I am addressing a regression that was
introduced in Modus themes version 5.0.0.

Thanks to Alexandr Semenov and realazy for testing my patch in issue
170: <https://github.com/protesilaos/modus-themes/issues/170>.
This commit is contained in:
Protesilaos Stavrou 2025-12-19 15:04:34 +02:00
parent 4ac7fdd6c7
commit 7a86cf49a8
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA

View file

@ -7471,23 +7471,23 @@ whose value is another symbol, which ultimately resolves to a string or
(semantic-unique (funcall unique-fn semantic))) (semantic-unique (funcall unique-fn semantic)))
(nreverse (nconc semantic-unique named-unique))))) (nreverse (nconc semantic-unique named-unique)))))
(defun modus-themes-with-colors-subr (expressions) (defun modus-themes-with-colors-subr (body)
"Do the work of `modus-themes-with-colors' for EXPRESSIONS." "Do the work of `modus-themes-with-colors' for BODY."
(condition-case data (condition-case data
(when-let* ((theme (modus-themes-get-current-theme))) (when-let* ((modus-themes-with-colors--current (modus-themes-get-current-theme))
(palette (modus-themes--with-colors-get-palette modus-themes-with-colors--current))
(sorted (modus-themes--with-colors-resolve-palette-sort palette)))
(eval (eval
`(let* ((c '((class color) (min-colors 256))) `(let* ((c '((class color) (min-colors 256)))
(unspecified 'unspecified) (unspecified 'unspecified)
,@(modus-themes--with-colors-resolve-palette-sort ,@sorted)
(modus-themes--with-colors-get-palette theme))) (funcall ',body))))
,@expressions)
:lexical))
(error (message "Error in `modus-themes-with-colors': %s" data)))) (error (message "Error in `modus-themes-with-colors': %s" data))))
(defmacro modus-themes-with-colors (&rest body) (defmacro modus-themes-with-colors (&rest body)
"Evaluate BODY with colors from current palette bound." "Evaluate BODY with colors from current palette bound."
(declare (indent 0)) (declare (indent 0))
`(modus-themes-with-colors-subr ',body)) `(modus-themes-with-colors-subr (lambda () ,@body)))
;;;; Declare all the Modus themes ;;;; Declare all the Modus themes