I'm new to Emacs and think I ran into some macro expansion problems. There's a function solarized-with-color-variables
which is a macro that creates local variables using let*
and then expands the macro body parameter inside the let*
body so that it has access to these variables.
At one point I need to setq
a variable to a value consisting of a list, the first element of which should take on the value of one of these variables, green
. Normally I did this like this:
(setq some-var `(,green box))
However, it seems that after switching to using use-package.el
's use-package
macro, it seems like I'm in multiple layers of macros now, such that the above now expands one more time to:
(setq some-var (green box))
That is, it attempts to call green
as a function, which it's not; it's a string.
I'm not sure how to go about fixing this, or how I should proceed. My guess is that I have to basically wrap it in another layer of quotes so that the extra expansion leaves it as is, but being new to Emacs Lisp I'm not really sure how to do this. I tried a couple variations of quote
and list
to no avail.
;; use-package is a macro
(use-package solarized-theme
:ensure t
:config
(load-theme 'solarized-light t)
;; solarized-with-color-variables is a macro
(solarized-with-color-variables 'light
(custom-theme-set-faces
'solarized-light
`(show-paren-match ((,class (:foreground unspecified
:background ,base02
:weight normal)))))
;; I wanted to use with-eval-after-load but that's also a macro
(eval-after-load 'evil
(progn
(setq some-var `(,green box))))))
Edit: I've come to realize that it is the eval-after-load
function I'm using.
If I have this:
(solarized-with-color-variables 'light
(setq evil-emacs-state-cursor `(,red box)))
Everything works. But if I put that inside of eval-after-load
or vice versa, it breaks:
(eval-after-load 'evil
(solarized-with-color-variables 'light
(setq evil-emacs-state-cursor `(,red box))))
It says that the value of red
, "#blah", is not a valid function. I imagine that it's expanding macros twice, once for solarized-with-color-variables
so that it yields:
(setq evil-emacs-state-cursor '("#blah" box))
And then again (?):
(setq evil-emacs-state-cursor ("#blah" box))
Then when attempting to evaluate it it tries to use "#blah"
as a function, which it's not. Using the code from my own answer actually is giving me problems too, I guess it's not exactly the same as the value I set manually which is '("#blah" box)
:
(setq some-var `(list ,green 'box))