[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] «Macro» expansion in source blocks; code-sharing between blocks
From: |
Andreas Kiermeier |
Subject: |
Re: [O] «Macro» expansion in source blocks; code-sharing between blocks |
Date: |
Fri, 19 Sep 2014 09:14:46 +0930 |
I don't think you need the ":noweb yes" as part of the setup_fu
header, as this block is not pulling in other materials.
Having used this type of setup only over the last couple of days, I've
come up with another question. It appears that the setup_fu is
executed twice ... once as it's own source block (though by itself not
need) and once as part of the second noweb block. This isn't a problem
if the execution time is small, but I'm trying to create a summary
table in Latex format from 2 million records - so the time is
considerable.
My two blocks (with some code removed for simplicity) are as follow:
#+NAME: tbl-refyear
#+BEGIN_SRC R :results silent :exports none
latex(tabular( <code remove> ))
#+END_SRC
#+BEGIN_SRC latex :noweb yes
\begin{table}[h]
\label{tbl:refyear}
\caption{Separation outcomes (death or any type of discharge) by
reference year.}
<<tbl-refyear()>>
\end{table}
#+END_SRC
I've tried :cache yes as part of the tbl-refyear source block, but
that didn't stop if from being run twice. Am I missing a suitable
header argument?
This is the only way I could find to wrap the latex table (which has
some complex formatting and hence why I've used it over just producing
a table) in a float with a caption (though I still can't properly
reference the label when I export to a PDF file).
Any thought would be greatly appreciated. TIA!
Andreas
On 18 September 2014 23:31, Eric S Fraga <address@hidden> wrote:
>
> On Thursday, 18 Sep 2014 at 13:26, Tobias Getzner wrote:
> > On Thu, 18 Sep 2014 13:17:14 +0000, Tobias Getzner wrote:
> >
> >> Are there any convenient inline-expansion methods I might have
> >> overlooked?
> >
> > To illustrate, I was wondering if any of the following is feasible
> > somehow:
>
> Yes, and you almost got it right with your syntactic expansion:
>
> #+begin_src org
>
> ,* Syntactic expansion
>
> ,#+name: setup_fu
> ,#+begin_src sh :noweb yes
> echo 2
> ,#+end_src
>
> ,#+begin_src sh :results raw :noweb yes
> echo 1
> <<setup_fu>>
> echo 3
> ,#+end_src
>
> ,#+results:
> 1
> 2
> 3
>
> #+end_src
>
> Org src blocks can reference other src blocks. Note the ":noweb yes"
> option and the use of <<...>>.
>
>
> --
> : Eric S Fraga (0xFFFCF67D), Emacs 24.4.50.1, Org release_8.3beta-366-gb2fca7
- [O] «Macro» expansion in source blocks; code-sharing between blocks, Tobias Getzner, 2014/09/18
- Re: [O] «Macro» expansion in source blocks; code-sharing between blocks, Tobias Getzner, 2014/09/18
- Re: [O] «Macro» expansion in source blocks; code-sharing between blocks, Eric S Fraga, 2014/09/18
- Re: [O] «Macro» expansion in source blocks; code-sharing between blocks, Rainer M Krug, 2014/09/19
- Re: [O] «Macro» expansion in source blocks; code-sharing between blocks, Andreas Kiermeier, 2014/09/19
- [O] header arguments, inheritance, and noweb expansion Was: «Macro» expansion in source blocks; code-sharing between blocks, Rainer M Krug, 2014/09/19
- Re: [O] header arguments, inheritance, and noweb expansion Was: «Macro» expansion in source blocks; code-sharing between blocks, Andreas Kiermeier, 2014/09/20
- Re: [O] header arguments, inheritance, and noweb expansion Was: «Macro» expansion in source blocks; code-sharing between blocks, Charles Berry, 2014/09/20
- Re: [O] header arguments, inheritance, and noweb expansion Was: «Macro» expansion in source blocks; code-sharing between blocks, Andreas Kiermeier, 2014/09/21