emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Literate programming in org
@ 2015-08-26  8:35 Max Linke
  2015-08-26 10:36 ` Sebastien Vauban
  2015-08-26 12:21 ` Ken Mankoff
  0 siblings, 2 replies; 5+ messages in thread
From: Max Linke @ 2015-08-26  8:35 UTC (permalink / raw)
  To: Org Mode

Hi

I'm currently trying to use org-modes literate programming capabilities 
to write up a paper. So far it has been a joy to have the plotting code
and text in the same document. Thanks for all the work people here have
already put in to make this so easy.

I have run into a two small problems so far

* How can I use computed variables (string/int/float) in floating text?

   I have for example calculated a autocorrelation time and now want to
   use that calculated number in the text. The best solution I have
   found so far is

   #+name: print_acf_time
   #+begin_src ipython :session :exports none
     print(acf_time)
   #+end_src

   The autocorrelation time for the process is call_print_acf_time().
   That is OK-ish but I have to write a special code cell for every
   variable that I want to reference in my document. Is there another
   method to export variables to be easily accessible in org-mode?

* reruning specific cells only one time after emacs was started

   I have some cells that are long running and produce some variables
   I later use for plotting or calculating related values. To avoid
   recalculating I have added `cache: yes` to these cells. But they
   are only run once across restarts of emacs or my interpreter session
   in the background. When I start working again I would like to have a
   way to rerun all code-cells independent of the fact if they are cached
   or not. This would lead to a huge speed up in converting to latex for
   me.

I appreciate any help with this.

best Max

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

* Re: Literate programming in org
  2015-08-26  8:35 Literate programming in org Max Linke
@ 2015-08-26 10:36 ` Sebastien Vauban
  2015-08-26 19:40   ` Max Linke
  2015-08-26 12:21 ` Ken Mankoff
  1 sibling, 1 reply; 5+ messages in thread
From: Sebastien Vauban @ 2015-08-26 10:36 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi,

Max Linke <max_linke-Mmb7MZpHnFY@public.gmane.org> writes:
> I'm currently trying to use org-modes literate programming capabilities 
> to write up a paper. So far it has been a joy to have the plotting code
> and text in the same document. Thanks for all the work people here have
> already put in to make this so easy.

Can't add anything! ;-)

> I have run into a two small problems so far
>
> * How can I use computed variables (string/int/float) in floating text?
>
>    I have for example calculated a autocorrelation time and now want to
>    use that calculated number in the text. The best solution I have
>    found so far is
>
>    #+name: print_acf_time
>    #+begin_src ipython :session :exports none
>
>      print(acf_time)
>    #+end_src
>
>    The autocorrelation time for the process is call_print_acf_time().
>    That is OK-ish but I have to write a special code cell for every
>    variable that I want to reference in my document. Is there another
>    method to export variables to be easily accessible in org-mode?

See:

- inline Babel calls: ... call_<NAME>(<ARGUMENTS>) ... and/or
- inline code blocks: src_<LANGUAGE>{<BODY>}.

> * reruning specific cells only one time after emacs was started
>
>    I have some cells that are long running and produce some variables
>    I later use for plotting or calculating related values. To avoid
>    recalculating I have added `cache: yes` to these cells. But they
>    are only run once across restarts of emacs or my interpreter session
>    in the background. When I start working again I would like to have a
>    way to rerun all code-cells independent of the fact if they are cached
>    or not. This would lead to a huge speed up in converting to latex for
>    me.

I don't understand why re-running code blocks which are cached is
a problem.  Could you elaborate?

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: Literate programming in org
  2015-08-26  8:35 Literate programming in org Max Linke
  2015-08-26 10:36 ` Sebastien Vauban
@ 2015-08-26 12:21 ` Ken Mankoff
  1 sibling, 0 replies; 5+ messages in thread
From: Ken Mankoff @ 2015-08-26 12:21 UTC (permalink / raw)
  To: Max Linke; +Cc: Org Mode

Hi Max,

This is one bit of literate programming I haven't mastered myself yet. I generally have code blocks and print results, and then manually re-enter them in the paragraph below. I would like what you are looking for. The best solution I have, which I don't use often, is to use sessions and inline code.

On 2015-08-26 at 04:35, Max Linke <max_linke@gmx.de> wrote:
> * How can I use computed variables (string/int/float) in floating text?
>
>    I have for example calculated a autocorrelation time and now want to
>    use that calculated number in the text. The best solution I have
>    found so far is
>
>    #+name: print_acf_time
>    #+begin_src ipython :session :exports none
>      print(acf_time)
>    #+end_src
>
>    The autocorrelation time for the process is call_print_acf_time().
>    That is OK-ish but I have to write a special code cell for every
>    variable that I want to reference in my document. Is there another
>    method to export variables to be easily accessible in org-mode?

For example, to insert the number three I could do the following, if a = 1 and b = 2, defined previously in session "foo": src_octave[:session foo]{a+b} {{{results(=3=)}}}

I've been thinking about other ways to achieve this... perhaps my code blocks update a table. That table might be included in the text for the reader. Then one code session reads it all in, so I have access to all results in one session and can use them in the text...

  -k.

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

* Re: Literate programming in org
  2015-08-26 10:36 ` Sebastien Vauban
@ 2015-08-26 19:40   ` Max Linke
  2015-08-26 20:07     ` Sebastien Vauban
  0 siblings, 1 reply; 5+ messages in thread
From: Max Linke @ 2015-08-26 19:40 UTC (permalink / raw)
  To: emacs-orgmode



On 08/26/2015 12:36 PM, Sebastien Vauban wrote:
> See:
>
> - inline Babel calls: ... call_<NAME>(<ARGUMENTS>) ... and/or
> - inline code blocks: src_<LANGUAGE>{<BODY>}.

Yes I'm currently using inline babel calls.

>
>> * reruning specific cells only one time after emacs was started
>>
>>     I have some cells that are long running and produce some variables
>>     I later use for plotting or calculating related values. To avoid
>>     recalculating I have added `cache: yes` to these cells. But they
>>     are only run once across restarts of emacs or my interpreter session
>>     in the background. When I start working again I would like to have a
>>     way to rerun all code-cells independent of the fact if they are cached
>>     or not. This would lead to a huge speed up in converting to latex for
>>     me.
>
> I don't understand why re-running code blocks which are cached is
> a problem.  Could you elaborate?

I wanted a shortcut to rerun every code cell independent of cached 
status. Looking again into the docs I found the short-cut

	'C-u C-c C-v b'

This calls 'org-babel-execute-buffer'.

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

* Re: Literate programming in org
  2015-08-26 19:40   ` Max Linke
@ 2015-08-26 20:07     ` Sebastien Vauban
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastien Vauban @ 2015-08-26 20:07 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Max Linke <max_linke-Mmb7MZpHnFY@public.gmane.org> writes:
> On 08/26/2015 12:36 PM, Sebastien Vauban wrote:
>> See:
>>
>> - inline Babel calls: ... call_<NAME>(<ARGUMENTS>) ... and/or
>> - inline code blocks: src_<LANGUAGE>{<BODY>}.
>
> Yes I'm currently using inline babel calls.
>
>>> * reruning specific cells only one time after emacs was started
>>>
>>>     I have some cells that are long running and produce some variables
>>>     I later use for plotting or calculating related values. To avoid
>>>     recalculating I have added `cache: yes` to these cells. But they
>>>     are only run once across restarts of emacs or my interpreter session
>>>     in the background. When I start working again I would like to have a
>>>     way to rerun all code-cells independent of the fact if they are cached
>>>     or not. This would lead to a huge speed up in converting to latex for
>>>     me.
>>
>> I don't understand why re-running code blocks which are cached is
>> a problem.  Could you elaborate?
>
> I wanted a shortcut to rerun every code cell independent of cached
> status. Looking again into the docs I found the short-cut
>
> 	'C-u C-c C-v b'
>
> This calls 'org-babel-execute-buffer'.

... to forcibly re-evaluate the blocks (even when marked ":cache"), yes.
OK, got it now!

Best regards,
  Seb

-- 
Sebastien Vauban

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

end of thread, other threads:[~2015-08-26 20:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-26  8:35 Literate programming in org Max Linke
2015-08-26 10:36 ` Sebastien Vauban
2015-08-26 19:40   ` Max Linke
2015-08-26 20:07     ` Sebastien Vauban
2015-08-26 12:21 ` Ken Mankoff

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).