0

I want to fine-tune my syntax highlighting, and have created a separate colors.el file that gets loaded around the beginning of init.el. I often use the same color for multiple entries, and it gets difficult to keep track of them all, so I want to define a bunch of common colors as variables at the top of the file, something like this:

(setq myblue "DodgerBlue1")

(custom-set-faces
 '(link ((:t (:foreground myblue)))))

This keeps giving me a "Wrong type argument: stringp, blue" error on load.

I only have a surface-level understanding of how Lisp works. What would be the proper way to expand blue into a literal string before custom-set-faces is evaluated? Do I need a macro for this? Please help me understand how to make this work.

Drew
  • 75,699
  • 9
  • 109
  • 225
  • https://emacs.stackexchange.com/tags/elisp/info – Drew Jan 23 '22 at 02:47
  • 1
    Try something like (custom-set-faces `(link ((:t (:foreground ',myblue))))) – Drew Jan 23 '22 at 02:49
  • Also, be aware that there is already a standard library named `colors.el`. You might want to choose a different name for yours. – Drew Jan 23 '22 at 02:50
  • @Drew I think you made a typo, after trying some variations the one that worked was `(custom-set-faces (link ((t (:foreground ,myblue)))))` – Andrii Kozytskyi Jan 23 '22 at 03:49
  • 1
    Yes, you don't need to quote the inserted value, which is a string. (Habit - it's more common to need to quote the value of the eval'd sexp, as a further evaluation of the result is common. – Drew Jan 23 '22 at 04:03

0 Answers0