9
votes

I am tring to setup an environment for editing clojure in emacs. I'm relatively new to emacs (only 1 yr) and totally new to clojure (2 weeks). I've found lots of tutorial online about how to setup most of which talk about lein, swank-clojure, slime and nrepl. It seems that swank-clojure and slime need to work together but swank-clojure is deprecated, so what left is nrepl and some built in lisp repl mode.

I tried inferior lisp mode first because it is the default for clojure-mode and it looks fine to me. But I can't seem tp find a way to switch namespace easily within it.

I then tried emacs-live which is like a kit for emacs newbie that comes with nrepl. I can then do "nrepl-jack-in" to get a repl even though it is very slow.. It can switch namespace easily with "C-C M-n". Howevre, sometime after switching, a buffer called nrepl error would pop up and won't let me close. I have to force close emacs instead. Also, nrepl does not have much of syntax highlight.

To sum up: after swank-clojure been deprecated, which repl should I use? slime-repl? nrepl? or others?

I don't know much about clojure now so I'm not sure bwhat feature is important to a repl but it would be nice to at least have syntax highlight and can easily switch between namespace like "C-C M-n" in nrepl, and maybe a debugger.

3

3 Answers

15
votes

I heartily recommend nREPL.el for various reasons:

  1. swank-clojure is dead officially, but has been dead for a long while. While it was getting some job done, nothing much has changed or improved in it after its initial inception. The development of swank-clojure required significant expertise in Common Lisp, which Clojure developers generally lack and are unwilling to attain.

  2. clojure-mode 2.0.0 doesn't support swank-clojure + SLIME at all. This move was hugely beneficial to both clojure-mode (which dropped a lot of legacy code) and nrepl.el (which's development pace was increased after the announcement).

  3. nrepl.el is picking up features really FAST. I'm one of its contributors so I should know :-) Recently a lot of cool things like macroexpansion, compilation error highlighting and multiple connections support were added, just to name a few. Many more features and refinements are in the pipeline. nrepl.el's architecture is much simpler than SLIME's and it's much easier for regular Clojure hackers to extend nrepl.el.

  4. SLIME syntax highlighting? The REPL has the same font-locking in both SLIME and nrepl.el and the source buffers are using clojure-mode's font locking. It other words - syntax highlighting's the same in both.

  5. Emacs Live relies on vendorized git submodules and generally the versions of the extensions it ships are lagging behind the upstream a bit. You might want to try as an alternative Emacs Prelude, which also ships with Clojure support, but always uses the latest packages available in MELPA.

There is no slime-repl (outside SLIME that is). At this point it's just swank-clojure + SLIME or nrepl.el. Given that nrepl.el even now implements most of what SLIME has - you'd better get used to using nrepl.el.

Update

nREPL.el was renamed to CIDER after version 0.2.0.

3
votes

nREPL is probably your best bet. It's the officially suggested replacement for swank-clojure, and it's really easy to set up. (As for SLIME, swank-clojure is SLIME support for Clojure. SWANK is the backend communications channel for SLIME. If you want to use SLIME, you'll want swank-clojure — but of course that's been abandoned in favor of nREPL.)

1
votes

My experience at the moment is that nrepl.el is somewhat less usuable than SWANK was; it is however picking up fast, both in terms of features and in terms of stability.

Installing Swank is now a bit harder because Clojure-mode has dropped it, so you'd need an older version. So, my advice would be, if you already have a working swank setup, then don't change anything for a couple of months; on the other hand, if you don't have a working setup, go for nrepl because it's going to happen so or later, and Swank is going to involve old versions.

If you end up with nrepl, as I say, it's not perfect yet, but keep the knowledge that, to coin a phrase, things can only get better.