* How to ensure code blocks are run during export?
@ 2013-05-02 17:43 Alan Schmitt
2013-05-03 8:44 ` Sebastien Vauban
2013-05-03 15:59 ` Eric Schulte
0 siblings, 2 replies; 9+ messages in thread
From: Alan Schmitt @ 2013-05-02 17:43 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
Hello,
I'm writing an exam in org mode, and it's going really well. I need to
have some code in code blocks being run during export (as it's defining
some functions for later questions), but I don't want anything to be
displayed in the final document. At the moment I use the following
options in the block:
:results silent :exports results
Is it the correct way to do it?
Thanks,
Alan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to ensure code blocks are run during export?
2013-05-02 17:43 How to ensure code blocks are run during export? Alan Schmitt
@ 2013-05-03 8:44 ` Sebastien Vauban
2013-05-03 9:57 ` Alan Schmitt
2013-05-03 15:59 ` Eric Schulte
1 sibling, 1 reply; 9+ messages in thread
From: Sebastien Vauban @ 2013-05-03 8:44 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Alan,
Alan Schmitt wrote:
> I'm writing an exam in org mode, and it's going really well. I need to
> have some code in code blocks being run during export (as it's defining
> some functions for later questions), but I don't want anything to be
> displayed in the final document. At the moment I use the following
> options in the block:
>
> :results silent :exports results
>
> Is it the correct way to do it?
It works, but a better way'd simply be ":exports none".
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to ensure code blocks are run during export?
2013-05-03 8:44 ` Sebastien Vauban
@ 2013-05-03 9:57 ` Alan Schmitt
2013-05-03 11:16 ` Sebastien Vauban
0 siblings, 1 reply; 9+ messages in thread
From: Alan Schmitt @ 2013-05-03 9:57 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: emacs-orgmode
Sebastien Vauban writes:
> Alan,
>
> Alan Schmitt wrote:
>> I'm writing an exam in org mode, and it's going really well. I need to
>> have some code in code blocks being run during export (as it's defining
>> some functions for later questions), but I don't want anything to be
>> displayed in the final document. At the moment I use the following
>> options in the block:
>>
>> :results silent :exports results
>>
>> Is it the correct way to do it?
>
> It works, but a better way'd simply be ":exports none".
I tried, and this does not run the code block (I see errors for later
code blocks that depend on it, and there is no mention of running that
code block in the log).
Alan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to ensure code blocks are run during export?
2013-05-03 9:57 ` Alan Schmitt
@ 2013-05-03 11:16 ` Sebastien Vauban
2013-05-03 12:16 ` Alan Schmitt
0 siblings, 1 reply; 9+ messages in thread
From: Sebastien Vauban @ 2013-05-03 11:16 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Alan,
Alan Schmitt wrote:
> Sebastien Vauban writes:
>> Alan Schmitt wrote:
>>> I'm writing an exam in org mode, and it's going really well. I need to
>>> have some code in code blocks being run during export (as it's defining
>>> some functions for later questions), but I don't want anything to be
>>> displayed in the final document. At the moment I use the following
>>> options in the block:
>>>
>>> :results silent :exports results
>>>
>>> Is it the correct way to do it?
>>
>> It works, but a better way'd simply be ":exports none".
>
> I tried, and this does not run the code block (I see errors for later
> code blocks that depend on it, and there is no mention of running that
> code block in the log).
The following does work.
--8<---------------cut here---------------start------------->8---
#+name: do-this
#+begin_src org :results drawer replace :var you="44" :exports none
Hello $you
#+end_src
#+begin_src org :results drawer replace :var data=do-this :exports results
Value: $data
#+end_src
--8<---------------cut here---------------end--------------->8---
Maybe giving an ECM would help.
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to ensure code blocks are run during export?
2013-05-03 11:16 ` Sebastien Vauban
@ 2013-05-03 12:16 ` Alan Schmitt
2013-05-03 12:55 ` Sebastien Vauban
0 siblings, 1 reply; 9+ messages in thread
From: Alan Schmitt @ 2013-05-03 12:16 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: emacs-orgmode
Sebastien Vauban writes:
> The following does work.
It does, I agree, but this does not. If you run export on this:
--8<---------------cut here---------------start------------->8---
# -*- org-confirm-babel-evaluate: nil -*-
Setting the stage
#+BEGIN_SRC ocaml :results silent :exports none
let f x = x;;
#+END_SRC
Using the function
#+BEGIN_SRC ocaml :results code verbatim :exports results
f 3;;
#+END_SRC
--8<---------------cut here---------------end--------------->8---
Then the `f 3' results in an error. Looking in the ocaml buffer that is
launched for evaluation, one sees:
,----
| f 3;;
| "org-babel-ocaml-eoe";;
| Characters 0-1:
| f 3;;
| ^
| Error: Unbound value f
| # - : string = "org-babel-ocaml-eoe"
`----
And the declaration of f was not run.
If you replace `none' by `results' for the `:exports' of the first
block, then everything works fine.
I don't think this is specific to ocaml, I guess it may happen with
every session-based evaluation.
Alan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to ensure code blocks are run during export?
2013-05-03 12:16 ` Alan Schmitt
@ 2013-05-03 12:55 ` Sebastien Vauban
2013-05-03 13:08 ` Alan Schmitt
0 siblings, 1 reply; 9+ messages in thread
From: Sebastien Vauban @ 2013-05-03 12:55 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Alan,
Alan Schmitt wrote:
> Sebastien Vauban writes:
>
>> The following does work.
>
> It does, I agree, but this does not. If you run export on this:
>
> # -*- org-confirm-babel-evaluate: nil -*-
>
> Setting the stage
>
> #+BEGIN_SRC ocaml :results silent :exports none
> let f x = x;;
> #+END_SRC
>
> Using the function
>
> #+BEGIN_SRC ocaml :results code verbatim :exports results
> f 3;;
> #+END_SRC
>
> Then the `f 3' results in an error. Looking in the ocaml buffer that is
> launched for evaluation, one sees:
>
> ,----
> | f 3;;
> | "org-babel-ocaml-eoe";;
> | Characters 0-1:
> | f 3;;
> | ^
> | Error: Unbound value f
> | # - : string = "org-babel-ocaml-eoe"
> `----
>
> And the declaration of f was not run.
>
> If you replace `none' by `results' for the `:exports' of the first
> block, then everything works fine.
>
> I don't think this is specific to ocaml, I guess it may happen with
> every session-based evaluation.
I don't know OCaml at all, so I cannot try your example locally on my machine.
Though, you speak of "session": where is your session header argument? Isn't
that the problem?
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to ensure code blocks are run during export?
2013-05-03 12:55 ` Sebastien Vauban
@ 2013-05-03 13:08 ` Alan Schmitt
2013-05-06 15:18 ` Gareth Smith
0 siblings, 1 reply; 9+ messages in thread
From: Alan Schmitt @ 2013-05-03 13:08 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: emacs-orgmode
Hi Sebastien,
Sebastien Vauban writes:
> I don't know OCaml at all, so I cannot try your example locally on my
> machine.
And I don't know about other languages that support sessions,
unfortunately.
> Though, you speak of "session": where is your session header argument? Isn't
> that the problem?
There is a default session for Caml code, so one does not need this
argument.
Alan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to ensure code blocks are run during export?
2013-05-02 17:43 How to ensure code blocks are run during export? Alan Schmitt
2013-05-03 8:44 ` Sebastien Vauban
@ 2013-05-03 15:59 ` Eric Schulte
1 sibling, 0 replies; 9+ messages in thread
From: Eric Schulte @ 2013-05-03 15:59 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode@gnu.org
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> Hello,
>
> I'm writing an exam in org mode, and it's going really well. I need to
> have some code in code blocks being run during export (as it's defining
> some functions for later questions), but I don't want anything to be
> displayed in the final document. At the moment I use the following
> options in the block:
>
> :results silent :exports results
>
> Is it the correct way to do it?
>
> Thanks,
>
> Alan
>
Yes, this is the correct combination of header arguments for this use
case.
Cheers,
--
Eric Schulte
http://cs.unm.edu/~eschulte
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to ensure code blocks are run during export?
2013-05-03 13:08 ` Alan Schmitt
@ 2013-05-06 15:18 ` Gareth Smith
0 siblings, 0 replies; 9+ messages in thread
From: Gareth Smith @ 2013-05-06 15:18 UTC (permalink / raw)
To: Alan Schmitt; +Cc: Sebastien Vauban, emacs-orgmode
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> Hi Sebastien,
>
> Sebastien Vauban writes:
>
>> I don't know OCaml at all, so I cannot try your example locally on my
>> machine.
>
> And I don't know about other languages that support sessions,
> unfortunately.
I can see something similar using haskell, if that helps:
--8<---------------cut here---------------start------------->8---
# -*- org-confirm-babel-evaluate: nil -*-
Setting the stage
#+BEGIN_SRC haskell :results code verbatim :exports results
let f = (+1)
f 1
#+END_SRC
Using the function
#+BEGIN_SRC haskell :results code verbatim :exports results
f 3
#+END_SRC
Setting another stage
#+BEGIN_SRC haskell :results silent :exports none
let g = (+1)
g 1
#+END_SRC
Using the second function
#+BEGIN_SRC haskell :results code verbatim :exports results
g 3
#+END_SRC
--8<---------------cut here---------------end--------------->8---
>> Though, you speak of "session": where is your session header argument? Isn't
>> that the problem?
>
> There is a default session for Caml code, so one does not need this
> argument.
In my example, the function f is declared in one block and successfully
used in the second. The function g is declared in a third (silent)
block, and results in an error when we try to call it in the fourth and
final block. Does this demonstrate the default "session" that Alan
mentioned?
G
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-05-06 16:19 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-02 17:43 How to ensure code blocks are run during export? Alan Schmitt
2013-05-03 8:44 ` Sebastien Vauban
2013-05-03 9:57 ` Alan Schmitt
2013-05-03 11:16 ` Sebastien Vauban
2013-05-03 12:16 ` Alan Schmitt
2013-05-03 12:55 ` Sebastien Vauban
2013-05-03 13:08 ` Alan Schmitt
2013-05-06 15:18 ` Gareth Smith
2013-05-03 15:59 ` Eric Schulte
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).