[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 2 'echo' bash instructions produce a table
From: |
Ihor Radchenko |
Subject: |
Re: 2 'echo' bash instructions produce a table |
Date: |
Mon, 14 Nov 2022 03:59:55 +0000 |
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>