10

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.

My configuration

For clojure:

  • I set up clojure-mode, slime, slime-repl via ELPA
  • I run $ lein swank in project directory
  • Then M-x slime-connect to hack 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?


Update

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

koddo
  • 3,328
  • 2
  • 26
  • 25

3 Answers3

8

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)))))
Kaisyu
  • 96
  • 4
4

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.

Bozhidar Batsov
  • 55,802
  • 13
  • 100
  • 117
  • 1
    Thanks for your answer, but the CVS version from 04-04-2010 as installed by ELPA does not work at all. I also found slime-autodoc loaded with slime-fancy causes hangs. See update. – koddo Dec 12 '10 at 21:37
  • I also deleted those unnecessary lines from my init.el. Thanks. – koddo Dec 12 '10 at 21:39
1

I use sbcl, clozure, and clojure: Getting Emacs, Slime, Common Lisp (SBCL, Clozure), and Clojure to Work Together

Denilson Sá Maia
  • 47,466
  • 33
  • 109
  • 111
m7d
  • 736
  • 6
  • 18
  • Please, read my question and update. I wrote there I use CVS version already, and it doesn't help. And why did you post the whole .emacs here? Do you think it's helpful? – koddo Dec 13 '10 at 19:28
  • Check this, for more help: http://bit.ly/h0b6mV. Yes, it solves your problem. I had the same one. – m7d Dec 13 '10 at 21:31
  • I cleaned out the .emacs config here and wrote a blog post to help you and others. I hope it helps you. Works great for me. – m7d Dec 13 '10 at 21:57
  • I've just tryed one more time. I updated SLIME, started lein swank, and did M-x slime-connect. But with slime-fancy it hangs as usually. Doesn't work for me. – koddo Dec 13 '10 at 22:41
  • npoektop: if you give more details, your .emacs config, and how you are getting clojure, etc., I'd be glad to try and help. – m7d Dec 14 '10 at 01:47
  • @m7d What happens when you evaluate an expression with an error? For instance `(+ "" "")` Using the most recent SLIME from CVS, it won't properly handle the error, instead I get a SLIME (or swank) error: `"error in process filter: Wrong number of arguments: nil, 0"` According to this, https://github.com/technomancy/swank-clojure/issues/issue/31 the most recent SLIME won't work with swank-clojure. Can you try that and report back? If you got it to work I would love to know. – okonomichiyaki Dec 14 '10 at 05:40