emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get =#+RESULTS= without re-evaluating source code block?


From: John Kitchin
Subject: Re: Get =#+RESULTS= without re-evaluating source code block?
Date: Wed, 27 Jan 2021 18:31:03 -0500


I tried this but it did not work for me. 


On Wed, Jan 27, 2021 at 5:38 PM <tomas@tuxteam.de> wrote:
On Wed, Jan 27, 2021 at 05:14:43PM -0500, doltes wrote:
> Get =#+RESULTS= without re-evaluating source code block?
>
> Let's suppose I have a code block which requires a long time to finish
>
> #+NAME: big-computation
> #+begin_src bash
> sleep 5 # Some computation which requires a long time to complete.
> echo a
> #+end_src
>
> #+RESULTS: big-computation
> #+begin_example
> a
> #+end_example
>
> I want to use the results of that code block in other code blocks so I
> use a =noweb= reference (see below.)
>
> #+begin_src bash :noweb yes
> printf "%s\n" <<big-computation()>>
> #+end_src
>
> #+RESULTS:
> #+begin_example
> a
>
> #+end_example
>
> However, doing this (i.e. using a =noweb= reference) would make the
> command to be evaluated whenever getting its results. I don't want
> this, I want the =:noweb= reference to actually use the already
> computed results.
>
> So, my question is: Is it possible to use the actual =#+RESULTS= code
> block instead of always evaluating it when referencing the results
> through a =:noweb= reference?

Perhaps "Cache results of evaluation" (15.5 Evaluating Code Blocks,
in the Interwebs here [1] is for you.

In short, add a header argument :cache yes to your code block.

Cheers

[1] https://orgmode.org/org.html#Evaluating-Code-Blocks

 - t
--
John

-----------------------------------
Professor John Kitchin 
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


reply via email to

[Prev in Thread] Current Thread [Next in Thread]