all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Only evaluate code blocks interactively, but export results
@ 2015-04-04 17:03 David Dynerman
  2015-04-04 17:15 ` Thomas S. Dye
  0 siblings, 1 reply; 4+ messages in thread
From: David Dynerman @ 2015-04-04 17:03 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1345 bytes --]

Hi all,

I’m trying to accomplish the following:

1) I have an org-babel python block in my code that produces a figure file
2) I’d like to include the resulting figure HTML export of my org file
3) The code takes a bit to run, so I don’t want to execute the code block during each HTML export

What I have so far:

#+NAME: my_python_function
#+HEADER: :var some python vars
#+BEGIN_SRC python :results value file
  my python code
#+END_SRC

#+CALL: my_python_function(some python vars=values) :results value file :exports results
#+CAPTION: Here is a figure
#+LABEL: fig:an_amazing_figure
#+ATTR_HTML: :height 200em
#+RESULTS:
[[file:output_file]]

This block works when I export to HTML (e.g. the code runs, and the figure is placed in the appropriate figure with the appropriate caption).

Question: How can I modify this so that the code is only executed when I run C-c C-c on the +CALL line, but still have the figure in the exported HTML?

I tried adding :eval no-export to the code and to the +CALL line, but then the resulting HTML doesn’t contain the figure (it outputs “nil”, presumably because the CALL line is trying to call it, but the code is refusing to run because of the no-export line)

I’ve been digging around this for a few hours, any help would be appreciated.

Thanks,
David

[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 842 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Only evaluate code blocks interactively, but export results
  2015-04-04 17:03 Only evaluate code blocks interactively, but export results David Dynerman
@ 2015-04-04 17:15 ` Thomas S. Dye
  2015-04-04 18:55   ` David Dynerman
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas S. Dye @ 2015-04-04 17:15 UTC (permalink / raw)
  To: David Dynerman; +Cc: emacs-orgmode

Aloha David,

David Dynerman <david@block-party.net> writes:

> Hi all,
>
> I’m trying to accomplish the following:
>
> 1) I have an org-babel python block in my code that produces a figure file
> 2) I’d like to include the resulting figure HTML export of my org file
> 3) The code takes a bit to run, so I don’t want to execute the code
> block during each HTML export
>
> What I have so far:
>
> #+NAME: my_python_function
> #+HEADER: :var some python vars
> #+BEGIN_SRC python :results value file
>   my python code
> #+END_SRC
> #+CALL: my_python_function(some python vars=values) :results value file :exports results
> #+CAPTION: Here is a figure
> #+LABEL: fig:an_amazing_figure
> #+ATTR_HTML: :height 200em
> #+RESULTS:
> [[file:output_file]]
>
> This block works when I export to HTML (e.g. the code runs, and the
> figure is placed in the appropriate figure with the appropriate
> caption).
>
> Question: How can I modify this so that the code is only executed when
> I run C-c C-c on the +CALL line, but still have the figure in the
> exported HTML?
>
> I tried adding :eval no-export to the code and to the +CALL line, but
> then the resulting HTML doesn’t contain the figure (it outputs “nil”,
> presumably because the CALL line is trying to call it, but the code is
> refusing to run because of the no-export line)

You can set :cache yes, which can be used to avoid re-evaluating
unchanged code blocks.

hth,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Only evaluate code blocks interactively, but export results
  2015-04-04 17:15 ` Thomas S. Dye
@ 2015-04-04 18:55   ` David Dynerman
  2015-04-05 18:00     ` Charles C. Berry
  0 siblings, 1 reply; 4+ messages in thread
From: David Dynerman @ 2015-04-04 18:55 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2287 bytes --]

Hi Tom,

Does :cache yes work with #+CALL lines? I’m not able to get it to work.

I’m calling my function through #+CALL’s because I’d like to generate several figures from the same org-babel code block/

I tried adding :cache yes to:

1) The actual org-code block
2) The +CALL line, at the end
3) The +CALL line, before the argument list (i.e., my_python_function[:cache yes](…))

None of these worked - the code was still re-evaluated when I exported the file, although the +RESULTS line got a hash value.

Thank you very much,
David


> On Apr 4, 2015, at 12:15, Thomas S. Dye <tsd@tsdye.com> wrote:
> 
> Aloha David,
> 
> David Dynerman <david@block-party.net <mailto:david@block-party.net>> writes:
> 
>> Hi all,
>> 
>> I’m trying to accomplish the following:
>> 
>> 1) I have an org-babel python block in my code that produces a figure file
>> 2) I’d like to include the resulting figure HTML export of my org file
>> 3) The code takes a bit to run, so I don’t want to execute the code
>> block during each HTML export
>> 
>> What I have so far:
>> 
>> #+NAME: my_python_function
>> #+HEADER: :var some python vars
>> #+BEGIN_SRC python :results value file
>>  my python code
>> #+END_SRC
>> #+CALL: my_python_function(some python vars=values) :results value file :exports results
>> #+CAPTION: Here is a figure
>> #+LABEL: fig:an_amazing_figure
>> #+ATTR_HTML: :height 200em
>> #+RESULTS:
>> [[file:output_file]]
>> 
>> This block works when I export to HTML (e.g. the code runs, and the
>> figure is placed in the appropriate figure with the appropriate
>> caption).
>> 
>> Question: How can I modify this so that the code is only executed when
>> I run C-c C-c on the +CALL line, but still have the figure in the
>> exported HTML?
>> 
>> I tried adding :eval no-export to the code and to the +CALL line, but
>> then the resulting HTML doesn’t contain the figure (it outputs “nil”,
>> presumably because the CALL line is trying to call it, but the code is
>> refusing to run because of the no-export line)
> 
> You can set :cache yes, which can be used to avoid re-evaluating
> unchanged code blocks.
> 
> hth,
> Tom
> 
> --
> Thomas S. Dye
> http://www.tsdye.com <http://www.tsdye.com/>

[-- Attachment #1.2: Type: text/html, Size: 12134 bytes --]

[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 842 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Only evaluate code blocks interactively, but export results
  2015-04-04 18:55   ` David Dynerman
@ 2015-04-05 18:00     ` Charles C. Berry
  0 siblings, 0 replies; 4+ messages in thread
From: Charles C. Berry @ 2015-04-05 18:00 UTC (permalink / raw)
  To: David Dynerman; +Cc: emacs-orgmode, Thomas S. Dye

[-- Attachment #1: Type: TEXT/PLAIN, Size: 891 bytes --]

On Sat, 4 Apr 2015, David Dynerman wrote:

> Hi Tom,
>
> Does :cache yes work with #+CALL lines? I’m not able to get it to work.
>
> I’m calling my function through #+CALL’s because I’d like to generate 
> several figures from the same org-babel code block/
>
> I tried adding :cache yes to:
>
> 1) The actual org-code block
> 2) The +CALL line, at the end
> 3) The +CALL line, before the argument list (i.e., my_python_function[:cache yes](…))
>
> None of these worked - the code was still re-evaluated when I exported 
> the file, although the +RESULTS line got a hash value.
>
> Thank you very much,
> David
>

David,

Does this help?

#+NAME: timenow
#+BEGIN_SRC sh
   date
#+END_SRC

#+CALL: timenow[:eval never-export]() :eval never-export


This will run interactively, but not on export. Instead the exported value 
of any previously saved `date' is exported.


HTH,

Chuck

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-04-05 18:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-04 17:03 Only evaluate code blocks interactively, but export results David Dynerman
2015-04-04 17:15 ` Thomas S. Dye
2015-04-04 18:55   ` David Dynerman
2015-04-05 18:00     ` Charles C. Berry

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.