From: Alain.Cochard@unistra.fr
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: Confused about source code blocks evaluation when exporting
Date: Tue, 12 Jul 2022 14:53:10 +0200 [thread overview]
Message-ID: <25293.28342.763993.795868@gargle.gargle.HOWL> (raw)
Hello. The manual says:
Org evaluates code in the following circumstances:
_Source code blocks_
Org evaluates source code blocks in an Org file during export.
Org also evaluates a source code block with the ‘C-c C-c’ key
chord.
NB: each test below is performed with a new 'emacs -Q' session. I
have: Org mode version 9.5.2 (release_9.5.2-25-gaf6f12 @
/home/cochard/usr/local/emacs-28.1/lisp/org/)
(test 1) I have an org file which only contains
#+BEGIN_SRC emacs-lisp
(message "foo")
(setq my-var 'bar)
#+END_SRC
If I do 'C-c C-c', I am asked the following
Evaluate this emacs-lisp code block on your system? (yes or no)
If I answer 'yes', the following block
#+RESULTS:
: bar
is inserted below the source block; also I see, in the *Messages*
buffer:
executing Emacs-Lisp code block...
foo
Code block evaluation complete.
and if if 'C-h v' for 'my-var', it says
my-var’s value is ‘bar’
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.)
(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:
Contents
(message "foo")
(setq my-var ’bar)
The *Messages* buffer shows
org-babel-exp process emacs-lisp at position 1...
Saving file /home/cochard/tmp/scr.tex...
Wrote /home/cochard/tmp/scr.tex
Processing LaTeX file scr.tex...
PDF file produced.
Running /usr/bin/xdg-open /home/cochard/tmp/scr.pdf...done
and 'my-var' is not understood as a variable.
So I don't understand. I can only conclude that the code is not
evaluated, which seems to me contradictory with "Org evaluates source
code blocks in an Org file during export".
(test 3) Same code, except that I change the 1st line to
#+BEGIN_SRC emacs-lisp :exports results
If I do 'C-c C-e l o', I am asked the same question as in test 1:
Evaluate this emacs-lisp code block on your system? (yes or no)
but even if I answer 'yes', no '#+RESULTS:' block is inserted. The
*Messages* buffer shows
org-babel-exp process emacs-lisp at position 1...
executing Emacs-Lisp code block...
foo
Code block evaluation complete.
Saving file /home/cochard/tmp/scr.tex...
Wrote /home/cochard/tmp/scr.tex
Processing LaTeX file scr.tex...
PDF file produced.
and the pdf file shows:
Contents
bar
and my-var is defined. So the code is evaluated this time, but I
don't really understand the whole process either...
For example, what should I do if I want the code to be evaluated, the
'#+RESUTS:' block to be inserted in the org file, but nothing to be
shown in the exported pdf? (i.e., neither the code nor its results)
Same question for code evaluation but nothing related to this code
inserted or exported.
I've tried using the ':eval' header argument but it never worked as I
expected.
Thank you for you help.
--
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 ]
next reply other threads:[~2022-07-12 13:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 12:53 Alain.Cochard [this message]
2022-07-12 14:08 ` Confused about source code blocks evaluation when exporting Fraga, Eric
2022-07-14 5:47 ` Rudolf Adamkovič
2022-07-12 14:22 ` Greg Minshall
2022-07-12 21:13 ` Alain.Cochard
2022-07-13 10:57 ` Fraga, Eric
2022-07-13 21:06 ` Alain.Cochard
2022-07-14 7:06 ` Fraga, Eric
2022-07-14 8:09 ` Alain.Cochard
2022-07-14 8:35 ` Fraga, Eric
2022-07-20 12:12 ` Alain.Cochard
2022-07-20 12:43 ` Fraga, Eric
2022-07-22 4:27 ` Alain.Cochard
2022-07-22 17:09 ` Fraga, Eric
2022-07-22 22:21 ` Alain.Cochard
2022-07-14 6:06 ` Rudolf Adamkovič
2022-07-14 6:48 ` Alain.Cochard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25293.28342.763993.795868@gargle.gargle.HOWL \
--to=alain.cochard@unistra.fr \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).