I used code like this:
(defvar my-defvar "test")
(completing-read "input: " '("1" "2" my-defvar))
Then M-x eval-region.
I got “1”, “2”, my-defvar in minibuffer.
My question is how to convert my-defvar to string in a list.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In Lisp, the
´-symbol will quote the rest of the expression. This means that the value will be the expression exactly as it is written, function calls are not evaluated, variables are not replaced with it’s value etc.The most straight-forward way is to use the function
listthat creates a list of elements, after evaluating it’s arguments, for example:Of course, you could also use the backquote syntax, as suggested in another answer. This allows you to quote a complex expression but unquote (i.e. evaluate) parts of it. However, in this simple case I don’t think it’s the right tool for the job.