emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Rudolf Adamkovič" <salutis@me.com>
To: alain.cochard@unistra.fr, Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: Confused about source code blocks evaluation when exporting
Date: Thu, 14 Jul 2022 08:06:58 +0200	[thread overview]
Message-ID: <m25yk0cjnh.fsf@me.com> (raw)
In-Reply-To: <25293.28342.763993.795868@gargle.gargle.HOWL>

Alain.Cochard@unistra.fr writes:

> Org evaluates source code blocks in an Org file during export.

I have just tried to export the following document:

#+begin_src emacs-lisp :exports both
(+ 1 1)
#+end_src

The exported HTML file contains the expression '(+ 1 1)' along with '2',
its value.  It follows that Emacs does evaluate source blocks on export.

(Note that Org did not add RESULTS to the Org file during export, for no
export should ever modify the source file in any way.)

> why does '#+RESULTS:' show 'bar' and not 'foo'?

By default, the Org mode captures the value of the last expression.  In
your case, the last expression has the value of 'bar'.

If you want to capture something else for the result, such as standard
output, you must tell Org Babel about it with the ':results' argument.
It makes sense, if you think about it.  The computer cannot possibly
know what you want to capture.

Rudy
-- 
"The introduction of suitable abstractions is our only mental aid to
organize and master complexity."
-- Edsger Wybe Dijkstra, 1930-2002

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


  parent reply	other threads:[~2022-07-14  6:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12 12:53 Confused about source code blocks evaluation when exporting Alain.Cochard
2022-07-12 14:08 ` 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č [this message]
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=m25yk0cjnh.fsf@me.com \
    --to=salutis@me.com \
    --cc=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).