Running figwheel with Emacs Inferior Clojure Interaction Mode

Colin Yates edited this page Apr 19, 2017 · 23 revisions

Inf-clojure

inf-clojure allows you to interact with a terminal Clojure/ClojureScript REPL directly within Emacs. This enables you to ship code from your buffer to the ClojureScript REPL for evaluation and much more. The main advantage of using inf-clojure is that you have extremely simple direct access to a Clojure(Script) REPL from Emacs and can skip the complexity and configuration involved in getting nREPL to work for ClojureScript.

Assuming you have already installed clojure-mode, run M-x package-list-packages and install inf-clojure.

Edit your .emacs or init.el and add a function like the following:

(defun figwheel-repl ()
  (interactive)
  (inf-clojure "lein figwheel"))

(add-hook 'clojure-mode-hook #'inf-clojure-minor-mode)

Restart Emacs (or evaluate the forms above with C-x C-e)!

Open your ClojureScript file and run M-x figwheel-repl. You'll get a new buffer with the REPL. Switch back to your file.

  • C-c C-l will load the file.
  • C-c Meta-n will switch your namespace.
  • If you place your cursor at the end of a s-expression, C-x C-e will evaluate that expression.
  • C-c C-v will show the docs. C-c C-s will show the source. C-c <return> will macroexpand.

Refer to inf-clojure for more documentation.

You are done!

Launching from a Clojure Process

Create a script/repl.clj with the following contents:

(use 'figwheel-sidecar.repl-api)
(start-figwheel!)
(cljs-repl)

note: leiningen profile merging won't occur with start-figwheel!

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

(defun figwheel-repl ()
  (interactive)
  (inf-clojure "lein trampoline run -m clojure.main script/repl.clj"))

(add-hook 'clojure-mode-hook #'inf-clojure-minor-mode)

Open your ClojureScript file and run M-x figwheel-repl. You'll get a new buffer with the REPL.

Resources

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.