Last Updated: February 25, 2016
·
2.183K
· pierrel

Clojurescript repl in emacs

Picture

Create a file "cljs-repl" that looks like the following:

#!/bin/sh
CLOJURESCRIPT_HOME="/your/path/to/clojurescript"

CLJSC_CP=''
for next in lib/: lib/*: src/clj: src/cljs: test/cljs; do
  CLJSC_CP=$CLJSC_CP$CLOJURESCRIPT_HOME'/'$next
done

java -server -cp $CLJSC_CP clojure.main -e \
"(require '[cljs.repl :as repl])
(require '[cljs.repl.rhino :as rhino])
(def env (rhino/repl-env))
(repl/repl env)"

Put that thing in your PATH. Then, in emacs you can do

M-x
set-variable
inferior-lisp-program
cljs-repl

Then you can do C-c C-z from a clojurescript buffer. If you're going to do this often then you can write a function that does this automatically (in your .emacs):

(defun cljs-repl ()
    (interactive)
    (setq inferior-lisp-program "cljs-repl")
    (run-lisp))

(hobbled together from https://groups.google.com/forum/?fromgroups=#!topic/clojure/_JWvqc3fENQ)

3 Responses
Add your response

If you're using leiningen and lein-cljsbuild, you could probably also just set your inferior-lisp-program to "lein cljsbuild repl-rhino".

over 1 year ago ·

Thank you so much for this. My current project doesn't involve Clojure so I never thought to use lein. I'm going to have to try lein cljsbuild repl-launch to get browser support working when I get home.

over 1 year ago ·

Worked a bit more to find out how to get clojruescript repl to connect to a browser: https://coderwall.com/p/ourduw

over 1 year ago ·