0

This question already has an answer here:

How can I make fun2 return as the same as fun1?

(defun fun1 ()
  '((hello . "test"))) ; <= returns ((hello . "test"))

(defun fun2 (str)
  '((hello . str))) ; <= this is wrong! should return ((hello . "test"))

marked as duplicate by Drew, JeanPierre, Stefan, DoMiNeLa10 Aug 29 at 17:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
(defun fun2 (str)
  `((hello . ,str)))

See the backquote section of the Emacs manual:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html

  • 2
    Or (defun fun2 (str) (list (cons 'hello str))). It doesn't hurt to look behind the "magic" of backquoting. – Drew Jan 10 '18 at 5:10

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