0

I'm trying to set the default font for my Emacs based on a variable (so I can use a different font on a different machine):

(setq fontspec (concat ck-font-name "-" (number-to-string ck-font-size)))
(set-default-font fontspec)
(set-fontset-font "fontset-default" nil
                  (font-spec :size ck-font-size :name ck-font-name))
(add-to-list 'default-frame-alist '(font . fontspec))

This basically works but the last line throws a warning:

frame-notice-user-settings: Invalid font: fontspec

I know what the problem is (fontspec seems to not be defined when the list gets evaluated), but I don't know how to fix this; my elisp-fu is not good enough.

Can somebody explain me or give me a pointer where I can read how to fix this?

2

Ok, I just found out about backquoting:

(add-to-list 'default-frame-alist `(font . ,fontspec))

This quotes the (font . part and evaluates the fontspec. Nice!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.