Johan:
Maybe this one would work for you:
#+NAME: first
#+BEGIN_SRC js
function one() {
return 1;
}
#+END_SRC
#+NAME: second
#+BEGIN_SRC js
function two() {
return 2;
}
#+END_SRC
#+NAME: third
#+BEGIN_SRC js
function three() {
return 3;
}
#+END_SRC
#+NAME: all
#+BEGIN_SRC sh
Following up: A function like this one should help.
(defun expand-named-babel-block (block)
(save-excursion
(org-babel-goto-named-src-block block)
(org-babel-expand-src-block)))
However ... there's something strange here with
org-babel-goto-named-src-block (org 9.0.9). It just jumps
Thanks Martin,
These are good suggestions, but it's not quite what I am after. In your
second example, I would like ":var code=example" to make "code" carry the
full (and expanded) text of the "example" block, i.e. to have
echo ls -alh
as the result -- the code itself, unevaluated.
Johan
Johan:
To use expanded noweb references you can use text source blocks
#+NAME: lscode
#+BEGIN_SRC *text*
ls -alh
#+END_SRC
#+NAME: example
#+BEGIN_SRC sh :noweb yes
echo <>
#+END_SRC
#+RESULTS: example
: ls -alh
#+BEGIN_SRC emacs-lisp :var code=example
(message code)
#+END_SRC
#+RESULTS:
:
Johan:
You can try the following:
#+NAME: lscode
#+BEGIN_ASCII
ls -alh
#+END_ASCII
#+BEGIN_SRC emacs-lisp :var code=lscode
(message code)
#+END_SRC
#+RESULTS:
: ls -alh
I haven't tried the noweb references, but it does return the code block in
the variable.
Martín
On Wed, Oct 25, 2017 at