Emacs Lisp: evaluate variable in alist

Viewed 4443

This is probably silly but I don't have enough Elisp knowledge to understand what is going on with respect to quoting and evaluation.

Suppose I have this Elisp code:

(add-to-list 'default-frame-alist '(width . 100))
(add-to-list 'default-frame-alist '(height . 50))

It will result in the expected default-frame-alist value:

((height 50)
 (width 100))

But now if I have this:

(setq my-frame-width 100)
(setq my-frame-height 50)
(add-to-list 'default-frame-alist '(width . my-frame-width))
(add-to-list 'default-frame-alist '(height . my-frame-height))

It will result in -

((height my-frame-height)
 (width my-frame-width))

and, judging from the frame geometry, never evaluates those variables. How do I make the actual values of my-frame-width and height appear in this alist? Do I have too many quotes? But I cannot remove any from the add-to-list evaluations...

2 Answers
Related