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"))
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"))
(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
(defun fun2 (str) (list (cons 'hello str)))
. It doesn't hurt to look behind the "magic" of backquoting. – Drew Jan 10 '18 at 05:10