SLIME setup for both Common Lisp and Clojure development
I've been having trouble with setting up SLIME to work with both Clojure and Common Lisp. Most Clojure devs tend to use the stripped down SLIME available via ELPA that is frozen for Clojure compatibility. I, however, do a lot of Common Lisp hacking as well and I generally use the SLIME CVS version (obtained via QuickLisp).
There are some well known problems with the swank implementation for Clojure - it doesn't work with autodoc (if it's enabled SLIME freezes), it doesn't support some things like fuzzy-completion, etc. This question discusses the same subject the the answer suggested there is a no go for me.
(add-hook 'slime-connected-hook
(lambda ()
(if (string= (slime-lisp-implementation-type) "Clojure")
(setq slime-use-autodoc-mode nil)
(setq slime-use-autodoc-mode t))
))
(add-hook 'slime-mode-hook
(lambda ()
(if (eq major-mode 'clojure-mode)
(slime-autodoc-mode 0)
(slime-autodoc-mode 1))))
(add-hook 'slime-repl-mode-hook
(lambda ()
(if (string= (slime-lisp-implementation-type) "Clojure")
(progn (setq slime-use-autodoc-mode nil)
(slime-autodoc-mod开发者_如何学Ce 0))
(progn (setq slime-use-autodoc-mode t)
(slime-autodoc-mode 1)))))
The solution looks great on paper, but for me slime-lisp-implementation-type is always nil. (same for slime-lisp-implementation-type:connlocal with local connections).
What I basically need is just a way to know I running SLIME with Clojure's swank to be able to modify the problematic settings.
It seems that the solution to this problem was just created. It's called jack-in. Basically you just need to do three things:
- Install clojure-mode via git or Marmalade
- lein plugin install swank-clojure 1.3.1
- Invoke M-x clojure-jack-in from a project
This will bootstrap the supported SLIME automatically. You no longer need to install it via ELPA. I've wrapped my Common Lisp init in an interactive function that I can call when I need it, because loading the Clojure SLIME naturally messes up a few settings. It's not as ideal a solution as upstream Clojure support in SLIME, but it's much better than most alternative...
Update:
SLIME is no longer needed for Clojure development. I recommend you to use CIDER instead.
This is a step by step guide to setting up SLIME for Clojure in Emacs (gathered from http://technomancy.us/126 and other sources). It does not interfere with your existing CommonLisp or Scheme setup:
http://languageagnostic.blogspot.com/2011/05/clojure-in-emacs.html
精彩评论