0

To construct a quasi-alist, case 1 is using hardcode string; case 2 is using a variable filename to replace the hadcode string. but case 2 doesn't work as expected (should the same as case 1).

#+BEGIN_SRC elisp :results output
;; case 1
(setq alist '((:file . "test.txt")))
(print alist)

;;case 2
(setq filename "test.txt")
(setq alist '((:file . filename)))
(print alist)
#+END_SRC

#+RESULTS:
: 
: ((:file . "test.txt"))
: 
: ((:file . filename))

What's the right way to use a variable to construct a quasi-alist?

Drew
  • 77,472
  • 10
  • 114
  • 243
lucky1928
  • 1,666
  • 10
  • 28
  • 1
    Backquote/quasiquote the list, and use a comma to unquote the cdr. – Dan Apr 12 '17 at 03:45
  • In case 2 you have quoted the form, which means no part of the form is evaluated. Hence filename remains a symbol. See C-h i g (elisp) Backquote – phils Apr 12 '17 at 03:56

0 Answers0