[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Confused about source code blocks evaluation when exporting
From: |
Alain . Cochard |
Subject: |
Re: Confused about source code blocks evaluation when exporting |
Date: |
Tue, 12 Jul 2022 23:13:49 +0200 |
Fraga, Eric writes on Tue 12 Jul 2022 14:08:
> On Tuesday, 12 Jul 2022 at 14:53, Alain.Cochard@unistra.fr wrote:
> > So far so good. (Well almost: why does '#+RESULTS:' show 'bar' and
> > not 'foo'? After all, I'm just setting 'my-var', I'm not asking to
> > display its value. But that's incidental.)
>
> It's not incidental. By default, the results of a src block evaluation
> is the value of the src block which is typically the value returned by
> the last statement.
I guess I didn't use 'incidental' correctly. I meant it as "not my
main concern". Anyway, thank you; I could check that if I switch the
2 lines I indeed get '#+RESULTS:' to show foo'.
> You can modify this by adding
>
> :results output
>
> for instance to the begin_src line.
>
> > (test 2) Same org file. If I do 'C-c C-e l o', no question is asked,
> > no '#+RESULTS:' block is inserted, and the resulting pdf file shows:
>
> On export, the default is to export the code. If you want the results,
> you need to add
>
> :exports results
>
> or if you want both code and results,
>
> :exports both
Greg Minshall writes on Tue 12 Jul 2022 17:22:
> maybe look in the org manual for ":results" (with "value" or
> "output" as options) and ":exports" (with "code" or "results" or
> "both" as options).
Thank you both, I made progress; but the behavior is still very so
unintuitive to me. For example, I haven't found a way to have this
block:
#+begin_src emacs-lisp <arguments to be determined>
(message "foo")
(message "bar")
#+END_SRC
and have the following inserted during export:
#+RESULTS:
: foo
: bar
(after all, that is was goes into the *Messages* buffer upon
evaluation with 'C-c C-c'...)
Finally I still tend to consider that the sentence "Org evaluates
source code blocks in an Org file during export" is confusing. But
maybe that's just I who interpret this as "code evaluation is the
default behavior upon export".
Regards
--
EOST (École et Observatoire des Sciences de la Terre)
ITE (Institut Terre & Environnement) | alain.cochard@unistra.fr
5 rue René Descartes [bureau 106] | Phone: +33 (0)3 68 85 50 44
F-67084 Strasbourg Cedex, France | [ slot available for rent ]
- Confused about source code blocks evaluation when exporting, Alain . Cochard, 2022/07/12
- Re: Confused about source code blocks evaluation when exporting, Fraga, Eric, 2022/07/12
- Re: Confused about source code blocks evaluation when exporting, Greg Minshall, 2022/07/12
- Re: Confused about source code blocks evaluation when exporting,
Alain . Cochard <=
- Re: Confused about source code blocks evaluation when exporting, Fraga, Eric, 2022/07/13
- Re: Confused about source code blocks evaluation when exporting, Alain . Cochard, 2022/07/13
- Re: Confused about source code blocks evaluation when exporting, Fraga, Eric, 2022/07/14
- Re: Confused about source code blocks evaluation when exporting, Alain . Cochard, 2022/07/14
- Re: Confused about source code blocks evaluation when exporting, Fraga, Eric, 2022/07/14
- Re: Confused about source code blocks evaluation when exporting, Alain . Cochard, 2022/07/20
- Re: Confused about source code blocks evaluation when exporting, Fraga, Eric, 2022/07/20
- Re: Confused about source code blocks evaluation when exporting, Alain . Cochard, 2022/07/22
- Re: Confused about source code blocks evaluation when exporting, Fraga, Eric, 2022/07/22
- Re: Confused about source code blocks evaluation when exporting, Alain . Cochard, 2022/07/22