Skip to content

Emacs & Inferior Clojure Interaction Mode

David Nolen edited this page Mar 26, 2015 · 10 revisions

Assuming you already have clojure-mode, run M-x package-list-packages and install inf-clojure. If you are using Emacs on OS X be sure to install exec-path-from-shell so that the Node.js REPL will work correctly. If you need exec-path-from-shell make sure to follow the Usage instructions.

Create a REPL file that starts whatever REPL you like (refer to the Quick Start) and put it in your current directory. For example a repl.clj file for the Node.js REPL would look like the following:

(require 'cljs.repl)
(require 'cljs.repl.node)
(cljs.repl/repl (cljs.repl.node/repl-env))

Edit your .emacs or init.el and add a function like the following if you are using the JAR in your current directory:

(defun cljs-node-repl ()
  (interactive)
  (run-clojure "java -cp cljs.jar clojure.main repl.clj"))

If you are using Leiningen:

(defun cljs-node-repl ()
  (interactive)
  (run-clojure "lein trampoline run -m clojure.main repl.clj"))

Open the your ClojureScript file and run M-x cljs-node-repl. You get a new buffer with the REPL. Switch back to your file and run M-x inf-clojure-minor-mode. You're good to go!

Clone this wiki locally