I'm relatively new to Elisp and I'm trying to figure out a bug in my code, but I have no idea what to search or read in order to get an idea about it.

The bug is in this code:

(defvar some-variable "some-value")
(setq some-plist
      '(:name "name" :query some-variable :key 97))

(stringp (plist-get some-plist :query))  ;; nil (HERE)
(stringp some-variable) ;; t

Even though (plist-get some-plist :query) returns some-variable, why does stringp on it returns nil?


1 Answer 1


You need to "unquote" some-variable when building the plist. So the code should look like this:

(defvar some-variable "some-value")
(setq some-plist
      `(:name "name" :query ,some-variable :key 97))

(stringp (plist-get some-plist :query))  ;; t (HERE)
(stringp some-variable) ;; t

When you build a list using a quote ', everything is added to the list verbatim. So, going back to the snippet you posted, even though some-variable evaluates to a string, '(some-variable) is equivalent to (list 'some-variable) (a list with a quoted symbol).

To get what you are asking for, you can either use a backtick-quoted list and unquote some-variable


or just use the list form

(list some-variable)
  • 3
    Generally speaking, it is convenient to construct a property list using list instead of backquoting, since keyword symbols are self-evaluating, so you don't need to quote them, and it is fairly common to want to evaluate the values in a plist anyway.
    – Philip K.
    Commented Dec 27, 2022 at 17:44
  • That certainly makes sense. Thanks for the tip.
    – David Leal
    Commented Dec 28, 2022 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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