reddit / emacs

Cannot pass a string variable to set a face color

TiMueller · 2022-10-13 12:39
Why is it that I cannot pass a string variable to set a face color? I can use `(propertize "Colorful" 'face '(:foreground "CornflowerBlue"))`, but I cannot use: (setq mycolor "CornflowerBlue") (propertize "Colorful" 'face '(:foreground mycolor)) Also it doesn't work with `,mycolor` or `(mycolor)`. What am I doing wrong? Any help is appreciated!
ireallywantfreedom · 2022-10-13 13:12
https://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html You'll need the comma and the preceding backtick e. g. (setq mycolor "CornflowerBlue") (propertize "Colorful" 'face `(:foreground ,mycolor))
TiMueller · 2022-10-13 13:53
Thank you so much! I have never used the backtick before. Now it works! So much to learn until one gets to a better understanding of Elisp. I am very grateful there is this reddit forum where I can ask. Thanks again!