From a743e2252aa7030007d1f0f57f26640ffbbf14a1 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Sun, 18 Mar 2018 01:33:12 +0800 Subject: [PATCH 3/4] * ob-js.el: support :session for js-comint REPL. --- etc/ORG-NEWS | 4 ++++ lisp/ob-js.el | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 0e0b6fa33..71895e6a0 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 js-comint +#+begin_src js :session "*Javascript REPL*" +console.log("stardiviner") +#+end_src *** Add ~:session~ support of ob-js for Indium #+begin_src js :session "*JS REPL*" console.log("stardiviner") diff --git a/lisp/ob-js.el b/lisp/ob-js.el index 06df20bf7..c829c4c74 100644 --- a/lisp/ob-js.el +++ b/lisp/ob-js.el @@ -59,7 +59,8 @@ :type '(choice (const "node") (const "mozrepl") (const "skewer-mode") - (const "indium")) + (const "indium") + (const "js-comint")) :safe #'stringp) (defvar org-babel-js-function-wrapper @@ -171,6 +172,15 @@ then create. Return the initialized session." (httpd-start) (run-skewer) session-buffer))) + ((string= "*Javascript REPL*" session) + (require 'js-comint) + (let ((session-buffer "*Javascript REPL*")) + (if (and (org-babel-comint-buffer-livep (get-buffer session-buffer)) + (comint-check-proc session-buffer)) + session-buffer + (call-interactively 'run-js) + (sit-for .5) + session-buffer))) ((string= "mozrepl" org-babel-js-cmd) (require 'moz) (let ((session-buffer (save-window-excursion -- 2.16.2