Discussion:
[O] [PATCH] Add support for Babel with Eshell, and some questions
stardiviner
2018-04-22 02:00:12 UTC
Permalink
I added ob-eshell.el and documentation.

I got some questions:

When I run `make test`, found some babel languages are missing dependency.
What does that mean? and my ob-eshell is missing dependency too.

,----
| Code block evaluation complete.
| passed 136/796 ob-vala/static-output (0.803677 sec)
| failed 137/796 org-missing-dependency/test-ob-R (0.000377 sec)
| failed 138/796 org-missing-dependency/test-ob-eshell (0.000403 sec)
| failed 139/796 org-missing-dependency/test-ob-lua (0.000460 sec)
| failed 140/796 org-missing-dependency/test-ob-maxima (0.000320 sec)
| failed 141/796 org-missing-dependency/test-ob-plantuml (0.000304 sec)
| failed 142/796 org-missing-dependency/test-ob-ruby (0.000354 sec)
| failed 143/796 org-missing-dependency/test-ob-scheme (0.000307 sec)
| failed 144/796 org-missing-dependency/test-ob-sqlite (0.000320 sec)
| failed 145/796 org-missing-dependency/test-org-protocol (0.000304 sec)
| passed 146/796 test-ob-exp/org-babel-exp-src-blocks/w-no-file (0.034372 sec)
| passed 147/796 test-ob-exp/org-babel-exp-src-blocks/w-no-headers (0.031144 sec)
| passed 148/796 test-ob-exp/org-babel-exp-src-blocks/w-no-headers2 (0.665415 sec)
`----

I have not found place for write doc for a specific Babel langauge for
ob-eshell under "* Languages" or other places. So I write document for
ob-eshell in Worg. Will push after this PATCH merged.

Question does all Babel languages document goes to Worg?

- --
[ stardiviner ] don't need to convince with trends.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
stardiviner
2018-04-22 02:01:11 UTC
Permalink
Ahh, forgot include my patches.
stardiviner
2018-04-22 02:31:20 UTC
Permalink
In this latest PATCH, contains fix of ob-shell :session initialize and execution.
Nicolas Goaziou
2018-04-23 09:34:59 UTC
Permalink
Hello,
From 596da7b0384d64f3c1c22a49bc9bced8d0d8abf8 Mon Sep 17 00:00:00 2001
Date: Sun, 22 Apr 2018 09:37:40 +0800
Subject: [PATCH] ob-eshell.el: Add Eshell support for Babel.
Thank you. This could go into master branch once Org 9.2 is out.
| D | d | ditaa | ditaa |
| Graphviz | dot | Emacs Calc | calc |
| Emacs Lisp | emacs-lisp | Fortran | fortran |
+| Shell | sh | Eshell | eshell |
| Gnuplot | gnuplot | Haskell | haskell |
| Java | java | Javascript | js |
| LaTeX | latex | Ledger | ledger |
Shell sh pair is already defined later in the table (ordered
alphabetically). Those are spurious.
+;; Org-Babel support for evaluating Eshell source code.
Org Babel support....
+(defvar org-babel-default-header-args:eshell '())
+
+(defun org-babel-execute:eshell (body params)
+ "Execute a block of Eshell code.
+This function is called by `org-babel-execute-src-block'."
Could you expound a bit and explain what are the arguments, i.e., BODY
and PARAMS?
+(defun org-babel-prep-session:eshell (session params)
+ "Prepare SESSION according to the header arguments specified in PARAMS."
+ (let* ((session (org-babel-eshell-initiate-session session))
+ ;; Eshell session buffer is read from variable `eshell-buffer-name'.
+ (eshell-buffer-name session)
+ (var-lines (org-babel-variable-assignments:eshell params)))
+ (call-interactively 'eshell)
#'eshell
+ (dolist (var-line var-lines)
+ (eshell-command var-line))
(mapc #'eshell-command var-lines)
+ session))
+
+(defun ob-eshell-session-live-p (session)
+ "Detect Eshell SESSION exist."
"Non-nil if Eshell SESSION exists."
+ (and (get-buffer session) t))
Simply:

(get-buffer session)
+;;; test-ob-eshell.el
+
+;; Copyright (c) 2010-2014 Eric Schulte
I don't think so ;)

Barring the minor comments above, it looks good.

Could you send an updated patch?

Regards,
--
Nicolas Goaziou
stardiviner
2018-04-23 13:22:40 UTC
Permalink
Post by Nicolas Goaziou
Hello,
From 596da7b0384d64f3c1c22a49bc9bced8d0d8abf8 Mon Sep 17 00:00:00 2001
Date: Sun, 22 Apr 2018 09:37:40 +0800
Subject: [PATCH] ob-eshell.el: Add Eshell support for Babel.
Thank you. This could go into master branch once Org 9.2 is out.
It's fine to be merged later.

Hi, Nicolas, thank you always review my Org-mode patches. Yesterday, I
ask Bastein about Worg ox-org question. He mentioned I should at least
say "Hi" in message. I'm not good at English culture of something else.
But I just want to say, I'm glad you reviewed my patches. Really. Thanks
and that means a lot to me.
Post by Nicolas Goaziou
| D | d | ditaa | ditaa |
| Graphviz | dot | Emacs Calc | calc |
| Emacs Lisp | emacs-lisp | Fortran | fortran |
+| Shell | sh | Eshell | eshell |
| Gnuplot | gnuplot | Haskell | haskell |
| Java | java | Javascript | js |
| LaTeX | latex | Ledger | ledger |
Shell sh pair is already defined later in the table (ordered
alphabetically). Those are spurious.
Aha, I found it, is there a way to auto sort this table automatically?
(Maybe format it into two columns instead of four columns even though it
looks short and better.) Adding one language into this table, then move
following languages in table one by one is awful.
Post by Nicolas Goaziou
+;; Org-Babel support for evaluating Eshell source code.
Org Babel support....
+(defvar org-babel-default-header-args:eshell '())
+
+(defun org-babel-execute:eshell (body params)
+ "Execute a block of Eshell code.
+This function is called by `org-babel-execute-src-block'."
Could you expound a bit and explain what are the arguments, i.e., BODY
and PARAMS?
+(defun org-babel-prep-session:eshell (session params)
+ "Prepare SESSION according to the header arguments specified in PARAMS."
+ (let* ((session (org-babel-eshell-initiate-session session))
+ ;; Eshell session buffer is read from variable `eshell-buffer-name'.
+ (eshell-buffer-name session)
+ (var-lines (org-babel-variable-assignments:eshell params)))
+ (call-interactively 'eshell)
#'eshell
+ (dolist (var-line var-lines)
+ (eshell-command var-line))
(mapc #'eshell-command var-lines)
I previously patches, you mentioned to use `dolist`, so I used it this
time, what's the difference between mapc and dolist? I thought might be
performance or something else. Maybe looks cleaner?
Post by Nicolas Goaziou
+ session))
+
+(defun ob-eshell-session-live-p (session)
+ "Detect Eshell SESSION exist."
"Non-nil if Eshell SESSION exists."
+ (and (get-buffer session) t))
(get-buffer session)
+;;; test-ob-eshell.el
+
+;; Copyright (c) 2010-2014 Eric Schulte
I don't think so ;)
I copy form other test-ob-*.el file template. forgot to change copyright
name. should I use my own name "stardiviner"?
Post by Nicolas Goaziou
Barring the minor comments above, it looks good.
Could you send an updated patch?
Regards,
I will update patch, and resend later after those question answer fixed.

And thanks again. :) :) :)

- --
[ stardiviner ] don't need to convince with trends.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Nicolas Goaziou
2018-04-23 21:35:22 UTC
Permalink
Post by stardiviner
Hi, Nicolas, thank you always review my Org-mode patches. Yesterday, I
ask Bastein about Worg ox-org question. He mentioned I should at least
say "Hi" in message. I'm not good at English culture of something else.
But I just want to say, I'm glad you reviewed my patches. Really. Thanks
and that means a lot to me.
You're welcome.
Post by stardiviner
Aha, I found it, is there a way to auto sort this table automatically?
(Maybe format it into two columns instead of four columns even though it
looks short and better.) Adding one language into this table, then move
following languages in table one by one is awful.
True. I usually define a quick Emacs macro when I need to shift
a substantial part of this table. I'm not sure it is faster in the end,
but it sure is more interesting.
Post by stardiviner
Post by Nicolas Goaziou
(mapc #'eshell-command var-lines)
I previously patches, you mentioned to use `dolist`, so I used it this
time, what's the difference between mapc and dolist? I thought might be
performance or something else. Maybe looks cleaner?
What I said it `mapc' + `lambda' => `dolist'. This is because calling
lambda is somewhat inefficient in Emacs Lisp. So, instead of (mapc
(lambda (e) (do stuff on e))), it is better to write (dolist (e ...) (do
stuff on e)) since there is one level of indirection less.

In the example above, there is no `lambda'. So (mapc #'function ...) is
shorter and better.
Post by stardiviner
I copy form other test-ob-*.el file template. forgot to change copyright
name. should I use my own name "stardiviner"?
Sure.

Regards,
stardiviner
2018-04-24 02:39:09 UTC
Permalink
Post by Nicolas Goaziou
Post by stardiviner
Hi, Nicolas, thank you always review my Org-mode patches. Yesterday, I
ask Bastein about Worg ox-org question. He mentioned I should at least
say "Hi" in message. I'm not good at English culture of something else.
But I just want to say, I'm glad you reviewed my patches. Really. Thanks
and that means a lot to me.
You're welcome.
Post by stardiviner
Aha, I found it, is there a way to auto sort this table automatically?
(Maybe format it into two columns instead of four columns even though it
looks short and better.) Adding one language into this table, then move
following languages in table one by one is awful.
True. I usually define a quick Emacs macro when I need to shift
a substantial part of this table. I'm not sure it is faster in the end,
but it sure is more interesting.
After some thinking, I think the following table sort might better,
because Org Table support insert a field below is easy when has new
entry need to add. No need to move a lot of fields.

WDYT?

,----
| | Language | Identifier | Language | Identifier |
| |------------+------------+----------------+------------|
| -| Asymptote | asymptote | Awk | awk |
| -| C | C | C++ | C++ |
| -| Clojure | clojure | CSS | css |
| -| D | d | ditaa | ditaa |
| -| Graphviz | dot | Emacs Calc | calc |
| -| Emacs Lisp | emacs-lisp | Fortran | fortran |
| -| Shell | sh | Eshell | eshell |
| -| Gnuplot | gnuplot | Haskell | haskell |
| -| Java | java | Javascript | js |
| -| LaTeX | latex | Ledger | ledger |
| -| Lisp | lisp | Lilypond | lilypond |
| -| Lua | lua | MATLAB | matlab |
| -| Mscgen | mscgen | Objective Caml | ocaml |
| -| Octave | octave | Org mode | org |
| -| Oz | oz | Perl | perl |
| -| Plantuml | plantuml | Processing.js | processing |
| -| Python | python | R | R |
| -| Ruby | ruby | Sass | sass |
| -| Scheme | scheme | GNU Screen | screen |
| -| Sed | sed | shell | sh |
| -| SQL | sql | SQLite | sqlite |
| -| Vala | vala | | |
| +| Asymptote | asymptote | Lisp | lisp |
| +| Awk | awk | Lua | lua |
| +| C | C | MATLAB | matlab |
| +| C++ | C++ | Mscgen | mscgen |
| +| Clojure | clojure | Objective Caml | ocaml |
| +| CSS | css | Octave | octave |
| +| D | d | Org mode | org |
| +| ditaa | ditaa | Oz | oz |
| +| Emacs Calc | calc | Perl | perl |
| +| Emacs Lisp | emacs-lisp | Plantuml | plantuml |
| +| Eshell | eshell | Processing.js | processing |
| +| Fortran | fortran | Python | python |
| +| Gnuplot | gnuplot | R | R |
| +| GNU Screen | screen | Ruby | ruby |
| +| Graphviz | dot | Sass | sass |
| +| Haskell | haskell | Scheme | scheme |
| +| Java | java | Sed | sed |
| +| Javascript | js | shell | sh |
| +| LaTeX | latex | SQL | sql |
| +| Ledger | ledger | SQLite | sqlite |
| +| Lilypond | lilypond | Vala | vala |
| +
`----


- --
[ stardiviner ] don't need to convince with trends.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
Nicolas Goaziou
2018-04-25 08:31:54 UTC
Permalink
Hello,
Post by stardiviner
After some thinking, I think the following table sort might better,
because Org Table support insert a field below is easy when has new
entry need to add. No need to move a lot of fields.
WDYT?
I'm not convinced this is less work to edit, but I changed it anyway. It
makes it easier to follow alphabetical order. I also wrapped
identifiers within verbatim markup.

Thank you.

Regards,
--
Nicolas Goaziou 0x80A93738
stardiviner
2018-04-26 10:53:43 UTC
Permalink
Post by Nicolas Goaziou
I'm not convinced this is less work to edit, but I changed it anyway. It
makes it easier to follow alphabetical order. I also wrapped
identifiers within verbatim markup.
You're right, still not improved a lot. Anyway, thanks. And I updated
patch inclued in attachment.
stardiviner
2018-05-02 14:53:47 UTC
Permalink
Hi, Nicolas.

Now Org 9.1.12 is released. Maybe it's time to merge this ob-eshell PATCH?

If still has some places need modified, please tell me. Thanks.

- --
[ stardiviner ] don't need to convince with trends.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

Loading...