[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Selective export of Babel code blocks
From: |
William LÉCHELLE |
Subject: |
Re: [O] Selective export of Babel code blocks |
Date: |
Mon, 18 Jun 2012 13:37:47 -0400 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.8 Emacs/23.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
> On Mon, Jun 18, 2012 at 6:50 PM, John Hendy <address@hidden> wrote:
> > #+name: preamble
> > #+begin_src R :exports none
> > tikzDevice("file-name")
> > #+end_src
>
> Are you trying to use "file-name" as a variable? if so I think the
> source block header should include this: ":var file-name" and the source
> block can refer to the variable as $file-name.
It seems to me one of both
,----[ insert preamble ]
| <<preamble>>
| with the preamble having the header
| :var file-name="file_1.tex"
`----
or
,----[ eval preamble ]
| <<preamble(file-name="file_1.tex")>>
| without any :var header
`----
would be correct syntax, but using :var <variable> without assigning it should
fail
(though I didn't test it).
Both wouldn't give the same result…
> > And by the org-mode Babel documentation it looks like I can do
> > something like:
> >
> > <<preamble(file-name=file_1.tex)>>
>
> I'm not sure about this. The syntax seems correct but I don't quite
> understand the following statement from the manual:
>
> It is possible to include the _results_ of a code block rather than
> the body. This is done by appending parenthesis to the code block name
> which may optionally contain arguments to the code block as shown
> below.
>
> <<code-block-name(optional arguments)>>
… as I read this as
"the noweb reference will expand in either
1. The litteral of the code-block if there are no parenthesis
2. The results of the block (as obtained with C-c C-c or
org-babel-execute-src-block) (which may depend of a :results header, maybe),
if parenthesis are present.
"
So if the OP wants to call the preamble block with an argument in the noweb
reference, then the preamble block might have to be more like
#+name: preamble
#+begin_src R :results output
print(tikzDevice(file-name))
#+end_src
called with
<<preamble(file-name="file_1.tex")>>
(but I don't know any R either, I just went myself through variable
substitution over the weekend)
Last alternative, which I use, is putting the file name in some named table,
and then passing it as an argument to
,----[ insert preamble ]
| <<preamble>>
| with the preamble having the header
| :var file-name=some-table[0,1]
`----
(Like
#+tblname: some-table
| file | "file_1.tex" |
)
HTH,
William
- [O] Selective export of Babel code blocks, John Hendy, 2012/06/18
- Re: [O] Selective export of Babel code blocks, suvayu ali, 2012/06/18
- Re: [O] Selective export of Babel code blocks, Thomas S. Dye, 2012/06/18
- Re: [O] Selective export of Babel code blocks, suvayu ali, 2012/06/18
- Re: [O] Selective export of Babel code blocks, John Hendy, 2012/06/18
- Re: [O] Selective export of Babel code blocks, Andreas Leha, 2012/06/18
- Re: [O] Selective export of Babel code blocks, Thomas S. Dye, 2012/06/18
- Re: [O] Selective export of Babel code blocks, suvayu ali, 2012/06/19
- Re: [O] Selective export of Babel code blocks, John Hendy, 2012/06/19