Re: [O] How to ensure code blocks are run during export?

2013-05-06 Thread Gareth Smith

Alan Schmitt alan.schm...@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



Re: [O] How to ensure code blocks are run during export?

2013-05-06 Thread Eric Schulte
Alan Schmitt alan.schm...@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



Re: [O] How to ensure code blocks are run during export?

2013-05-03 Thread Sebastien Vauban
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




Re: [O] How to ensure code blocks are run during export?

2013-05-03 Thread Alan Schmitt
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



Re: [O] How to ensure code blocks are run during export?

2013-05-03 Thread Sebastien Vauban
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




Re: [O] How to ensure code blocks are run during export?

2013-05-03 Thread Alan Schmitt
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



Re: [O] How to ensure code blocks are run during export?

2013-05-03 Thread Sebastien Vauban
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




Re: [O] How to ensure code blocks are run during export?

2013-05-03 Thread Alan Schmitt
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



[O] How to ensure code blocks are run during export?

2013-05-02 Thread Alan Schmitt
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