emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Alain.Cochard@unistra.fr
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: 2 'echo' bash instructions produce a table
Date: Mon, 14 Nov 2022 03:59:55 +0000	[thread overview]
Message-ID: <87pmdqfao4.fsf@localhost> (raw)
In-Reply-To: <25457.22124.839301.412560@gargle.gargle.HOWL>

Alain.Cochard@unistra.fr writes:

> Ihor Radchenko writes on Mon  7 Nov 2022 02:31:
>
>  > If you want to force string output, use :results output.
>  > 
>  > By default, ob-shell tries to guess the output type.  In the case
>  > of two commands returning output, the guess is yielding the
>  > table. In the case of a single command, the guess is yielding a
>  > single string output.
>
> Thanks a lot.
>
> I find it strange, though, that the default is not as what one gets
> from running the code from a terminal.  I imagine there are good
> reasons for that, but I think this should be made clear (or at least
> clearer) in the manual.  I browsed through section 16 of the manual,
> with particular attention to 16.5 (Evaluating Code Blocks) and 16.6
> (Results of Evaluation), but still cannot see where this is said or
> hinted; if it is there, I missed it or do not know enough to
> understand it.

The manual describes generic code execution. If you do not explicitly
specify the :results header arg, it is the specific babel backend that
specifies the defaults.

Will it help if we mention this fact in "16.6 Results of Evaluation"
section?

> For the sake of newcomers, it seems to me that something along the
> line of what you write above would fit somewhere in 16.6, with a first
> short mention/warning (and reference to it) next to that excerpt in
> 16.5:
>
>    Org captures the results of the code block evaluation and inserts
>    them in the Org file, right after the code block.

Talking about ob-shell does not belong to this section of the manual.
Other backends have different behaviour. Have you seen examples in
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-shell.html ?
Are they not clear enough?

> In section 16.3 of the manual (Using Header Arguments):
>
>    System-wide values of header arguments can be specified by
>    customizing the ‘org-babel-default-header-args’ variable, which
>    defaults to the following values:
>
> 	:session    => "none"
> 	:results    => "replace"
> 	:exports    => "code"
> 	:cache      => "no"
> 	:noweb      => "no"
>
>
> but the docstring of 'org-babel-default-header-args' says:
>
>    org-babel-default-header-args is a variable defined in ‘ob-core.el’.
>    Its value is
>    ((:session . "none")
>     (:results . "replace")
>     (:exports . "code")
>     (:cache . "no")
>     (:noweb . "no")
>     (:hlines . "no")
>     (:tangle . "no"))
>
> so I was wondering if there should be
>
>    :hlines      => "no"
>    :tangle      => "no"
>
> added above.

It will be fixed in the next release. The online and built-in Emacs
manual are only reflecting the current stable Org version.

> PS2
>
> In section 16.6 (Results of Evaluation)
>    
>    [The ‘results’ header argument] accepts four classes of options
>    [Collection, Type, Format, Handling]
>
>    Each code block can take only one option per class:
>
> Now, the paragraphs related to Collection, Type, & Format all contain
> the statement
>
>    "Choose one of the options; they are mutually exclusive".
>
> I thought this statement was saying the same thing as the "only one
> option per class" above, but then why not also repeat the statement in
> the Handling paragraph?

Makes sense.
Done on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=4260f5a8d74c965fccf200aa71da0c6d338573c0

> PS3
>
> In section 16.4 (Environment of a Code Block)
>
>     A simple named list.
>
> 	 #+NAME: example-list
> 	 - simple
> 	   - not
> 	   - nested
> 	 - list
>
> 	 #+BEGIN_SRC emacs-lisp :var x=example-list
> 	   (print x)
> 	 #+END_SRC
>
> 	 #+RESULTS:
> 	 | simple | list |
>
> But if I evaluate the code, I get
>
> 	 #+RESULTS:
> 	 | simple | (unordered (not) (nested)) |
> 	 | list   |                            |

Confirmed. Need to look into this.

> PS4
>
> In 16.5 (Evaluating Code Blocks), in this code
>
>    #+NAME: random
>    #+BEGIN_SRC R :cache yes
>      runif(1)
>    #+END_SRC
>
> the (1) seems to be understood as a footnote in Info, at least for me.
> E.g., <RET> on it goes to the footnote
>
>    (1) The option ‘org-babel-no-eval-on-ctrl-c-ctrl-c’ [...]
>
> and <RET> on this (1) goes back to the above code instead of to the
> actual call
>
>    "Org provides many ways to execute code blocks.  ‘C-c C-c’ or ‘C-c
>    C-v e’ with the point on a code block(1)"

Confirmed, but it does not look like Org's fault.
Org correctly produces the following texinfo source:

@example
#+NAME: random
#+BEGIN_SRC R :cache yes
  runif(1)
#+END_SRC

#+RESULTS[a2a72cd647ad44515fab62e144796432793d68e1]: random
0.4659510825295

#+NAME: caller
#+BEGIN_SRC emacs-lisp :var x=random :cache yes
  x
#+END_SRC

#+RESULTS[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
0.254227238707244
@end example

As you can see, no @footnote command is there.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2022-11-14 23:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-06  6:58 2 'echo' bash instructions produce a table Alain.Cochard
2022-11-07  2:31 ` Ihor Radchenko
2022-11-13 20:41   ` Alain.Cochard
2022-11-14  3:59     ` Ihor Radchenko [this message]
2022-11-15  6:00       ` [RFC] :var x=list-name should be resolved into simple lists (item1 item2 ...); not nested ((item1) (item2) ...) (was: 2 'echo' bash instructions produce a table) Ihor Radchenko
2022-11-26  1:54         ` Ihor Radchenko
2022-11-16  1:24       ` 2 'echo' bash instructions produce a table Ihor Radchenko
2022-11-21  9:04         ` Ihor Radchenko
2022-11-21  9:05         ` Ihor Radchenko
2022-11-16 16:35       ` Alain.Cochard
2022-11-19 12:28         ` Rudolf Adamkovič
2022-11-20  5:05           ` Ihor Radchenko
2022-11-22  8:16         ` Ihor Radchenko
2022-11-22 19:13           ` Alain.Cochard
2022-11-24  1:55             ` Ihor Radchenko
2022-11-22  8:31         ` [RFC] Backend vs. back-end (was: 2 'echo' bash instructions produce a table) Ihor Radchenko
2023-02-20 10:07           ` Ihor Radchenko
2023-02-20 14:54             ` Alain.Cochard
2023-04-06  9:57               ` Ihor Radchenko
2023-04-20 12:17                 ` Ihor Radchenko
2023-04-06 23:43           ` Samuel Wales
2022-11-22  8:37         ` [BUG] Make source block auto-completion work for all the loaded babel backends " Ihor Radchenko

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=87pmdqfao4.fsf@localhost \
    --to=yantar92@posteo.net \
    --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).