Emacs, luminus and nREPL
-
Create a new project with luminus (optional)
lein new luminus foobar
-
Setup nREPL in Luminus
In order to run the remote nREPL, just define the
NREPL_PORT
environment variable and run the project. I compiled the project (lein uberjar
) and directly run as a jar. It should also work from Tomcatexport NREPL_PORT=7000 java -jar target/uberjar/foobar.jar
-
Connect remotely
To connect to the remote nREPL
lein repl :connect 7000
-
Inject code
From the repl you just launched (the one with
:connect 7000
), you can inject new code into the jar. Let’s say you modified the filefoobar.clj
and you want to test it. Just type(load-file "foobar.clj")
and the new code should be loaded into the running application -
Connect from Emacs
To connect from Emacs to the remote REPL, just
M-x cider-connect
and then specify the host and port (localhost and 7000 in our case). If you followed all the steps, Emacs should complain that If you want to connect from Emacs using Cider, you have to modify a couple of things. If you just trFirst you need to add the relative plugin
[cider/cider-nrepl "0.15.0-snapshot"]
(actually check that the version matches the emacs one). -
Emacs shortcuts
The most useful shortcut is
C-c C-l
which will send the code to the remote REPL and inject it into the running application (just listload-file
does)
References
- http://www.luminusweb.net/docs/deployment.md#enabling_nrepl
- https://www.cheatography.com/bilus/cheat-sheets/emacs-cider/