[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] input data for babel blocks
From: |
Rick Frankel |
Subject: |
Re: [O] input data for babel blocks |
Date: |
Tue, 01 Oct 2013 10:29:49 -0400 |
User-agent: |
Roundcube Webmail/0.9.0 |
On 2013-10-01 09:01, Alan Schmitt wrote:
I'm sorry, I don't see the answer to this above. The only example I
could find in the manual is this one
http://orgmode.org/manual/noweb_002dref.html#noweb_002dref which does
not address using noweb with different languages.
I did some experiments and I'm even more confused. Here is a test where
I want to feed the results of "ls" in a shell block as an ocaml
list. This is what I tried:
#+BEGIN_SRC sh :noweb-ref testing
echo "["
for i in `ls`; do
echo \"$i;\"
done
echo "]"
#+END_SRC
#+BEGIN_SRC ocaml :noweb yes
let x =
<<testing>>
in x
#+END_SRC
This is clearly wrong because this is what ends up in the toplevel:
let x =
echo "["
for i in `ls`; do
echo \"$i;\"
done
echo "]"
in x;;
You're close. The noweb ref should be a named src block which is
executed, not expanded, so, (note the named shell source block and the
parens in the noweb reference):
#+name: testing
#+BEGIN_SRC sh :results raw
echo "["
ls *.org | sed 's/$/;/'
echo "]"
#+END_SRC
#+BEGIN_SRC ocaml :noweb yes
let x =
<<testing()>>
in x
#+END_SRC
rick