Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ef-themes-with-colors throws error #11

Closed
stevemolitor opened this issue Aug 29, 2022 · 4 comments
Closed

ef-themes-with-colors throws error #11

stevemolitor opened this issue Aug 29, 2022 · 4 comments

Comments

@stevemolitor
Copy link

stevemolitor commented Aug 29, 2022

Executing the example code in section "9. Use colors from the active Ef theme":

(ef-themes-with-colors
 (list bg-main fg-main bg-mode-line cursor))

Gives this error:

Symbol’s value as variable is void: ef-light-palette

The error happens here. It seems to have been introduced in this commit: e5e8ada. The ef-light-pallette constant has not been defined yet apparently.

If I select the ef-light-theme first then it works fine (which makes sense).

@protesilaos
Copy link
Owner

Thank @stevemolitor! Your assessment is correct. I need to think about an elegant way to do this. Will think about it some more and report back to you.

@protesilaos
Copy link
Owner

Maybe you can try this diff?

 ef-themes.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ef-themes.el b/ef-themes.el
index 9a60504..377935c 100644
--- a/ef-themes.el
+++ b/ef-themes.el
@@ -1518,7 +1518,7 @@ (defmacro ef-themes-with-colors (&rest body)
          ;; instantiate the actual theme's palette.  We have to do this
          ;; otherwise the macro does not work properly when called from
          ;; inside a function.
-         (colors (mapcar #'car (symbol-value 'ef-light-palette))))
+         (colors (mapcar #'car (ef-themes--current-theme-palette))))
     `(let* ((c '((class color) (min-colors 256)))
             (,sym (ef-themes--current-theme-palette))
             ,@(mapcar (lambda (color)

I tested it with these:

(defun testing-ef-themes-with-colors ()
  (ef-themes-with-colors
    (list bg-main)))

;; Evaluate these, change theme and eval again to see if you get a
;; different value:
(ef-themes-with-colors (list bg-main))

(testing-ef-themes-with-colors)

@stevemolitor
Copy link
Author

@protesilaos I can confirm that your diff above fixes the issue.

Thanks again!

protesilaos added a commit that referenced this issue Aug 30, 2022
Thanks to Steve Molitor for telling me that the previous design would
not work if 'ef-light' was not loaded.   This was done in issue 11 at
the GitHub mirror: <#11>.
@protesilaos
Copy link
Owner

Thank you! Just pushed the change. Closing this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants