From 26763df7de8f742e76f10f2e7603ed290b97df65 Mon Sep 17 00:00:00 2001 Message-Id: <26763df7de8f742e76f10f2e7603ed290b97df65.1678529850.git.yantar92@posteo.net> From: Ihor Radchenko Date: Sat, 11 Mar 2023 11:16:23 +0100 Subject: [PATCH] org-manual.org: Explain that noweb expansion does not carry over :var * doc/org-manual.org (Noweb Reference Syntax): Provide an example explaining that :var header arguments are not in effect when expanding noweb reference. Reported-by: Zelphir Kaltstahl Link: https://orgmode.org/list/46e6f579-9eca-e1da-06ea-f2478a603c5a@posteo.de --- doc/org-manual.org | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/org-manual.org b/doc/org-manual.org index 1c97d6aa8..2c3ec46a4 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -19117,6 +19117,32 @@ ** Noweb Reference Syntax ,#+END_SRC #+end_example +Note that noweb expansion does not automatically carry over =var= +header arguments. In the following example, attempting to evaluate +the second code block will give an error, because the variables +defined in the first code block will not be defined in the second +block. + +#+begin_example +,#+NAME: get-prompt +,#+BEGIN_SRC emacs-lisp :var prompt="root> " :var command="ls" + (concat prompt command) +,#+END_SRC + +,#+RESULTS: get-prompt +: root> ls + +,#+BEGIN_SRC emacs-lisp :noweb yes + <> +,#+END_SRC + +The previous block is expanded to + +,#+BEGIN_SRC emacs-lisp + (concat prompt command) +,#+END_SRC +#+end_example + You may also include the contents of multiple blocks sharing a common =noweb-ref= header argument, which can be set at the file, subtree, or code block level. In the example Org file shown next, the body of -- 2.39.1