Function: org-babel-js-initiate-session
org-babel-js-initiate-session is a byte-compiled function defined in
ob-js.el.gz.
Signature
(org-babel-js-initiate-session &optional SESSION PARAMS)
Documentation
If there is not a current inferior-process-buffer in SESSION then create.
Return the initialized session.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ob-js.el.gz
(defun org-babel-js-initiate-session (&optional session _params)
"If there is not a current inferior-process-buffer in `SESSION' then create.
Return the initialized session."
(cond
((string= session "none")
(warn "Session evaluation of ob-js is not supported"))
((string= "*skewer-repl*" session)
(org-require-package 'skewer-repl "skewer-mode")
(let ((session-buffer (get-buffer "*skewer-repl*")))
(if (and session-buffer
(org-babel-comint-buffer-livep (get-buffer session-buffer))
(comint-check-proc session-buffer))
session-buffer
;; start skewer REPL.
(httpd-start)
(run-skewer)
(skewer-repl)
session-buffer)))
;; SIC, JavaScript miscapitalized in `js-comint.el'.
((string= "*Javascript REPL*" session)
(org-require-package '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)
;; FIXME: According to https://github.com/bard/mozrepl, this REPL
;; is outdated and does not work for Firefox >54.
(org-require-package 'moz "mozrepl")
(let ((session-buffer (save-window-excursion
(run-mozilla nil)
(rename-buffer session)
(current-buffer))))
(if (org-babel-comint-buffer-livep session-buffer)
(progn (sit-for .25) session-buffer)
(sit-for .5)
(org-babel-js-initiate-session session))))
((string= "node" org-babel-js-cmd )
(error "Session evaluation with node.js is not supported"))
(t
(error "Sessions are only supported with mozrepl add \":cmd mozrepl\""))))