I set up emacs for both clojure and common lisp, but I want also (slime-setup '(slime-fancy)) for common lisp. If I add that line to init.el, clojure won't work: it gives me repl, but it hangs after I run any code.
For clojure:
For common lisp I place this after ELPA code in init.el:
(add-to-list 'load-path "~/.elisp/slime")
(require 'slime)
(add-to-list 'slime-lisp-implementations '(sbcl ("/opt/local/bin/sbcl") :coding-system utf-8-unix))
;; (slime-setup '(slime-fancy))
So if I uncomment the last line, clojure will be broken. But slime-fancy a very important meta package for hacking common lisp.
Is there a way to set them both up to work without changing configuration and restarting when I need to switch languages?
I found that slime-autodoc loaded with slime-fancy is the cause of hangs.
(slime-setup '(slime-fancy))
(setq slime-use-autodoc-mode nil)
This configuration lets run both common lisp and clojure SLIMEs. Even simultaneously. But without slime-autodoc.
I also found I'm using the CVS version of SLIME since I manually do (add-to-list 'load-path "~/.elisp/slime") after ELPA code. That does not solve the problem. Maybe there is a version from some magic date which works with clojure? Here a guy says CVS version works for him: http://www.youtube.com/watch?v=lf_xI3fZdIg&feature=player_detailpage#t=221s
Here is a solution. (using hooks)
That is ugly but quite convenient.
(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))))
Update
If the problem still exists on the slime-repl
buffer, try the following code:
(add-hook 'slime-repl-mode-hook
(lambda ()
(if (string= (slime-lisp-implementation-type) "Clojure")
(progn (setq slime-use-autodoc-mode nil)
(slime-autodoc-mode 0))
(progn (setq slime-use-autodoc-mode t)
(slime-autodoc-mode 1)))))
I've been contemplating on the same problem recently. The issue is that the SLIME in ELPA is trimmed down and is next to useless for Common Lisp. One way you can circumvent the problem is to check out SLIME from CVS from the same date as the checkout was done for the ELPA package and add manually the missing stuff. Someone on #clojure told me he did that and the solution worked. I personally find such a solution pretty ugly, but until someone manages to get the Clojure support into upstream SLIME there won't be a better one.
Alternatively you can add features to the slime-setup one by one and see what feature exactly is causing the problem with the Clojure evaluation - after all slime-fancy is simply a metafeature that just loads the most popular contrib features.
Btw you don't need the lines
(add-to-list 'load-path "~/.elisp/slime/contrib")
(setq slime-backend "~/.elisp/slime/swank-loader.lisp")
(require 'slime)
The contrib dir will be added automatically to the load path, the back-end is the default and if you're using 'slime-autoloads you should require slime before that, since this defeats the purpose of the autoload.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With