Since there is parameter I need to use, so I will not use single quote as the question's answer

First, I try

emacsclient -q --eval (progn (find-file "ORG/${UN}.org") (org-latex-export-to-pdf))

zsh: bad pattern: (progn (find-file ORG/Austin.org) (org-latex-export-to-pdf))


emacsclient -q --eval "(progn (find-file "ORG/${UN}.org") (org-latex-export-to-pdf))"

I get the error again

ERROR: Symbol’s value as variable is void: ORG/Austin\.org

The question is how to give the parameters.


I still get error after backslash the period

emacsclient -q --eval "(progn (find-file "ORG/${UN}\.org") (org-latex-export-to-pdf))" 

ERROR: Symbol’s value as variable is void: ORG/Austin\.org

  • 1
    This is a zsh question and nothing to do with org-mode, org-export etc. . Have you tried to backslash the inner apostrophs ?
    – politza
    Oct 29, 2016 at 21:57
  • @politza Still get error after backslash the period emacsclient -q --eval "(progn (find-file "ORG/${UN}\.org") (org-latex-export-to-pdf))" *ERROR*: Symbol’s value as variable is void: ORG/Austin\.org
    – yuxuan
    Oct 29, 2016 at 22:24
  • ...(find-file \"ORG/${UN}\.org\")...
    – politza
    Oct 30, 2016 at 1:37

3 Answers 3


Use either

emacsclient -q --eval "(progn (find-file \"ORG/${UN}.org\") (org-latex-export-to-pdf))"


emacsclient -q --eval '(progn (find-file "ORG/'"${UN}"'.org") (org-latex-export-to-pdf))'

The problem that needs to be solved is to give the string "ORG/Austin.org" rather than the symbol ORG/Austin.org to emacs.

  • What should I do to only open the file instead of piping it into pdf?
    – alper
    May 10, 2020 at 11:49
  • @alper Can you expand your question - I don't understand what you are asking? The emacs lisp code is a progn which says "do a sequence of things". Inside that the sequence is find-file to open the file and org-latex-export-to=pdf. If all you want is to open the file then remove the (org-latex-export-to-pdf) but this seems overkill! Perhaps you should start a new question?
    – icarus
    May 10, 2020 at 14:40
emacs --batch foo.org -f org-latex-export-to-pdf
  • --batch: Run Emacs in batch mode
  • foo.org: Open foo.org and set it as current buffer (org.el is loaded by the way)
  • -f org-latex-export-to-pdf: Then call org-latex-export-to-pdf to export the current buffer to pdf

As your tries

emacsclient -q --eval (progn (find-file "ORG/${UN}.org") (org-latex-export-to-pdf))

you need quote your expression for shell since it contains white spaces.

emacsclient -q --eval "(progn (find-file "ORG/${UN}.org") (org-latex-export-to-pdf))"

you need escape the inner " because you are using " outside. You can refer to @icarus's answer, I think it's correct. However, instead of writing Lisp in your shell, you can just make a function in Emacs and call it using emacsclient from command line, for example,

(defun my-org-latex-export-to-pdf ()

$ emacsclient --eval '(my-org-latex-export-to-pdf)'

In Emacs Lisp, you can use getenv to access value of environment variable if you need to.


Use eval solve this question.

 eval "emacsclient -q --eval '(progn (find-file \"ORG/$UN.org\") (org-latex-export-to-pdf))'"
  • eval is a very useful and powerful feature of the shell, but is almost certainly the wrong tool for this. You just need to get the quotes correct,
    – icarus
    Oct 30, 2016 at 1:59

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.