On Fri, Mar 07 2025, alain.coch...@unistra.fr wrote: > #+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both > wc -w $filename > #+END_SRC
(buffer-file-name) is evaluating the Emacs Lisp function `buffer-file-name', which returns a string with the buffer's filename. > > > I have a subtree containing just this code block: > > #+BEGIN_SRC shell :var filename=("/tmp/test.r") :exports both > wc -w $filename > #+END_SRC > > Upon 'C-c C-c', it gives > > #+RESULTS: > : 1 /tmp/test.r > > which is what I expect. > > However, upon latex export of the subtree (C-c e l p), I get: > > org-babel-read: Invalid function: "/tmp/test.r" Org is trying to evaluate an Emacs Lisp function, "/tmp/test.r", but that name is invalid since it is a string and not a symbol. You want to remove the parentheses in this case, because you are passing a literal string, not wanting to evaluate an elisp function. > > Now, if I remove the parentheses, i.e., if I just use > filename="/tmp/test.r" above, then it works as I expect in both cases, that > is, there is no error during export and I do see > > wc -w $filename > > 1 /tmp/test.r > > in the exported pdf file. > > Are the parentheses in the manual correct? If so, what is the rationale? > Thanks. Yes, they manual is correct, just not relevant to your second example. Leo