Skip to content

Emacs & inferior lisp mode

levonlloyd edited this page Mar 29, 2012 · 3 revisions

Create a shell script that starts the browser REPL and put it on your path. The shell script should look something like this:

#!/bin/sh

if [ "$CLOJURESCRIPT_HOME" = "" ]; then
  CLOJURESCRIPT_HOME="`dirname $0`/.."
fi

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.browser :as browser])
(def env (browser/repl-env))
(repl/repl env)"

Edit your .emacs and add a line like the following:

(setq inferior-lisp-program "browser-repl")

When editing .cljs files you can start the browser REPL with C-c C-z. Try this with the browser REPL sample that comes with ClojureScript. Make sure that you eval the namespace form to put the REPL into the namespace where you are working.

It's recommended that you use a tool like cljs-watch - this will recompile your project automatically when any of the project .cljs source files change.

Clone this wiki locally