>From 9c3a57107e4ed598ca24582fa330fe698829b61e Mon Sep 17 00:00:00 2001 From: stardiviner Date: Thu, 8 Mar 2018 17:15:58 +0800 Subject: [PATCH] * ob-js.el: support use skewer-mode as session support. --- lisp/ob-js.el | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lisp/ob-js.el b/lisp/ob-js.el index 38c8c39ac..e2a2a9cec 100644 --- a/lisp/ob-js.el +++ b/lisp/ob-js.el @@ -27,6 +27,11 @@ ;; ;; This certainly isn't optimally robust, but it seems to be working ;; for the basic use cases. +;; +;; `skewer-mode' session support: +;; #+begin_src js :session *skewer-repl* +;; console.log("chris"); +;; #+end_src ;;; Requirements: @@ -52,7 +57,10 @@ "Name of command used to evaluate js blocks." :group 'org-babel :version "24.1" - :type 'string) + :type '(choice (const "node") + (const "mozrepl") + (const "skewer-mode")) + :safe #'stringp) (defvar org-babel-js-function-wrapper "require('sys').print(require('sys').inspect(function(){\n%s\n}()));" @@ -142,6 +150,18 @@ specifying a variable of the same value." then create. Return the initialized session." (unless (string= session "none") (cond + ((string= "*skewer-repl*" session) + (require 'skewer-repl) + (let ((session-buffer (get-buffer "*skewer-repl*"))) + (if (and (org-babel-comint-buffer-livep (get-buffer session-buffer)) + (comint-check-proc session-buffer)) + session-buffer + ;; start skewer REPL. + (sit-for .5) + (httpd-start) + (run-skewer) + (sit-for .5) + session-buffer))) ((string= "mozrepl" org-babel-js-cmd) (require 'moz) (let ((session-buffer (save-window-excursion -- 2.16.2