diff options
author | stardiviner <numbchild@gmail.com> | 2018-03-18 01:19:29 +0800 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-03-25 22:41:05 +0200 |
commit | b4e2fed77e1b656141bf4283b4b674e7e7fe895a (patch) | |
tree | 57297e8e6f4e6e8331016dc945bd29d5f4f5d63d | |
parent | 1a1e2286baf41a898c1cf5235d3b6f3a8a81655b (diff) | |
download | org-mode-b4e2fed77e1b656141bf4283b4b674e7e7fe895a.tar.gz |
ob-js: support :session for Indium Node REPL.
* lisp/ob-js.el (org-babel-js-cmd): Add "indium".
(org-babel-execute:js): Handle Indium REPL.
-rw-r--r-- | etc/ORG-NEWS | 4 | ||||
-rw-r--r-- | lisp/ob-js.el | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 1a652e0..1e5e4e4 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -113,6 +113,10 @@ now sort according to the locale’s collation rules instead of by code-point. ** New features +*** Add ~:session~ support of ob-js for Indium +#+begin_src js :session "*JS REPL*" +console.log("stardiviner") +#+end_src *** Add ~:session~ support of ob-js for skewer-mode #+begin_src js :session "*skewer-repl*" console.log("stardiviner") diff --git a/lisp/ob-js.el b/lisp/ob-js.el index 9e9ffc1..2794c71 100644 --- a/lisp/ob-js.el +++ b/lisp/ob-js.el @@ -43,6 +43,8 @@ (declare-function run-mozilla "ext:moz" (arg)) (declare-function httpd-start "simple-httpd" ()) (declare-function run-skewer "skewer-mode" ()) +(declare-function indium-run-node "indium-nodejs" (command)) +(declare-function indium-eval "indium-interaction" (string &optional callback)) (defvar org-babel-default-header-args:js '() "Default header arguments for js code blocks.") @@ -56,7 +58,8 @@ :version "24.1" :type '(choice (const "node") (const "mozrepl") - (const "skewer-mode")) + (const "skewer-mode") + (const "indium")) :safe #'stringp) (defvar org-babel-js-function-wrapper @@ -84,6 +87,13 @@ This function is called by `org-babel-execute-src-block'" (org-babel-eval (format "%s %s" org-babel-js-cmd (org-babel-process-file-name script-file)) ""))) + ;; Indium Node REPL + ;; separate case because Indium REPL is not inherited from comint-mode + ((string= session "*JS REPL*") + (require 'indium-repl) + (unless (get-buffer session) + (indium-run-node)) + (indium-eval full-body)) ;; session evaluation (t (let ((session (org-babel-prep-session:js |