Reputation: 1753
I try to set the font as below:
(let ((my:font "WenQuanYi Micro Hei Mono"))
(when (member my:font (font-family-list))
(set-face-attribute 'default nil :font my:font :width 'condensed)
(add-to-list 'default-frame-alist
'(font . my:font))))
The set-face-attribute
works fine. I can see the font is set to WenQuanYi
. But when I check the value of default-frame-alist
, it shows as (font . my:font)
and when try to create a new frame (emacsclient), I got this error:
*ERROR*: Invalid font: my:font
It looks like it try to use the value name as a font name. So I am not sure what's the right way to do it.
Upvotes: 0
Views: 59
Reputation: 9377
The quoted list '(font . my:font)
produces a cons of those two symbols, rather than the value that you want. Instead of quote you can use either backquoting or a call to cons:
`(font ,my:font)
or
(cons 'font my:font)
You might be interested in the info pages (info "(elisp)Quoting")
and (info "(elisp)Backquoting")
, which explain those constructs in more detail.
On an unrelated note, the emacs lisp lexical conventions for local variables uses hyphens like-this
, not colons like:this
.
Upvotes: 1