Org-babel-js
hello, world demo
console.log("Hello, World!");
Configuration
(require 'ob-js) (add-to-list 'org-babel-load-languages '(js . t)) (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages) (add-to-list 'org-babel-tangle-lang-exts '("js" . "js"))
Use JavaScript libraries
is supported by default.
var util = require("util"); console.log("this is a Node.js test program!");
Support session for many Emacs packages
The header argument :session value of packages REPL buffer names are default.
And they all support for auto initiate session with ob-core.el
built-in function org-babel-initiate-session
, which is used by
commands like org-babel-switch-to-session
/ ([C-c C-v C-z]).
Indium
console.log("stardiviner")
skewer-mode
console.log("stardiviner")
js-comint
console.log("stardiviner")
helper command to insert session header argument
I write an helper command to insert session header argument easily:
(defun ob-js-insert-session-header-arg (session) "Insert ob-js `SESSION' header argument. - `js-comint' - `skewer-mode' - `Indium' " (interactive (list (completing-read "ob-js session: " '("js-comint" "skewer-mode" "indium")))) (org-babel-insert-header-arg "session" (pcase session ("js-comint" "\"*Javascript REPL*\"") ("skewer-mode" "\"*skewer-repl*\"") ("indium" "\"*JS REPL*\"")))) (define-key org-babel-map (kbd "J") 'ob-js-insert-session-header-arg)