emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alain.Cochard@unistra.fr
To: "Fraga, Eric" <e.fraga@ucl.ac.uk>
Cc: "Alain.Cochard@unistra.fr" <Alain.Cochard@unistra.fr>,
	Org Mode List <emacs-orgmode@gnu.org>,
	Greg Minshall <minshall@umich.edu>
Subject: Re: Confused about source code blocks evaluation when exporting
Date: Wed, 13 Jul 2022 23:06:44 +0200	[thread overview]
Message-ID: <25295.13284.191751.78706@gargle.gargle.HOWL> (raw)
In-Reply-To: <87v8s12sbh.fsf@ucl.ac.uk>


Fraga, Eric writes on Wed 13 Jul 2022 10:57:

 > No, you used the word correctly.  My point was that this was your
 > main issue!  Understanding what is the "result" of a src block
 > evaluation is key.

Thank you for the clarification.  I can see that I am still very
confused.

 > > 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
 > 
 > If you want output, maybe use "print" instead of "message".  However,
 > you will get quotes around the strings.  The best alternative would be
 > to have a single elisp statement that returns what you want output:
 > 
 > #+begin_src emacs-lisp :results value
 >   (concat "Foo"
 >           "\n"
 >           "Bar")
 > #+end_src

I can now also see that the issue is coupled to my unfamiliarity with
the lisp language, so below I switch to something hopefully simpler
for me.

 > > 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".
 > 
 > I do not quite understand the difference.  Evaluation happens (subject
 > to confirmation).  What may happen with that evaluation, however, might
 > not be what you want by default.  What is it you want on export?  If you
 > want the code and the results, add ":exports both" to the begin_src
 > line.  Straightforward?

Nah, sorry.  Maybe I don't understand what "evaluation" is.

I have the file with only the following block in it:

#+begin_src shell
rm -f foo
#+end_src

I load it with 'emacs -Q -l ~/.emacs.git' 

where '~/.emacs.git' only contains

(add-to-list 'load-path "~/Org/Coch-git/org-mode/lisp")
(org-babel-do-load-languages
 'org-babel-load-languages 
 '((shell . t)))

I do 'C-c C-c' within the block; I am asked "Evaluate this shell code
block on your system?", I say 'yes', and I can see that that the file
'foo', which I had just created, is no longer there.  This makes sense
to me.  "evaluation" here seems to me to be a synonym for "execution".

Now I start again, but I do 'C-c C-e l o' instead.  I am _not_ asked
whether I want to evaluate, and the 'foo' file is still there.  But
the pdf file does display

rm -f foo

Does this still qualify as "evaluation"?  I thought not, hence my
conclusion that evaluation was not performed by default upon export,
but you made me doubt it...

Regards.  Hope you appreciated your beer.


Org mode version 9.5.4 (release_9.5.4-623-gc66bdb @
/home/cochard/Org/Coch-git/org-mode/lisp/) 

-- 
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 ]



  reply	other threads:[~2022-07-13 21: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 [this message]
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=25295.13284.191751.78706@gargle.gargle.HOWL \
    --to=alain.cochard@unistra.fr \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=minshall@umich.edu \
    /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).