Skip to content
Jethro Kuan Sheng Yuan edited this page Jan 23, 2016 · 3 revisions

#Introduction Using inf-clojure with boot should be a simple task, because there are no external dependencies whatsoever. The simplicity of setup and use may appeal to some, but those who seek a REPL with more advanced functionality should take a look at CIDER instead.

Company-mode code-completions

For code-completions to work with company-mode, the repl needs to be started with the '--no-colors' flag so ANSI color codes won't be injected into your *inf-clojure* process output.

Setup

There are two predominant ways of connecting to your boot repl:

  1. Start the server and connect a client both from within Emacs
  2. Start the server in your boot deftask or from command line, and connect a client from Emacs

Server + Client in Emacs

Setting inf-clojure-program to boot -C repl should just work.

(setq inf-clojure-program "boot -C repl")	 

Running M-x inf-clojure will start a repl server and connect to it.

Client-only Emacs setup

Boot setup

In your build.boot, compose (repl :server true) into your task. Alternatively, you could run boot -C repl -s in your command line.

Emacs setup

Set inf-clojure-program to start just the client:

(setq inf-clojure-program "boot -C repl -c")

The client will detect the existence of .nrepl-port in your project root directory, and connect to the correct repl.

Bonus: Connecting to a specific port

To connect to a specific port, add the following to your Emacs configuration:

(defun run-boot-repl (x)
  (interactive "sEnter Port Number:")
  (run-clojure (format  "boot -C repl -cp %s" x)))

Once the nrepl server is started, take note of the port number, and connect to it in emacs by running M-x run-boot-repl.

#Usage You can start inf-clojure and switching to the repl by running C-c C-z from your Clojure source files.

Some additional helper functions:

(defun reload-current-clj-ns (next-p)
	    (interactive "P")
	    (let ((ns (clojure-find-ns)))
	      (message (format "Loading %s ..." ns))
	      (inf-clojure-eval-string (format "(require '%s :reload)" ns))
	      (when (not next-p) (inf-clojure-eval-string (format "(in-ns '%s)" ns)))))

This (re)loads the current namespace of the buffer. I bind this to C-c C-k.

Clone this wiki locally