6
votes

I can run emacs and start slime (with M-x slime). At this point I get the REPL in the inferior-lisp buffer and can run lisp there. But when I open up lisp code in another buffer none of the slime-goodness works (C-x C-e, C-c C-k etc.) and I keep seeing this in the Messages buffer (with an increasing count-number):

slime-connection: Not connected.

Polling "/var/folders/B9/B9B5J15dH+aNt5J5gkROEk+++TI/-Tmp-/slime.3202".. (Abort with `M-x slime-abort-connection'.) [69 times]

Makes me think slime is not connecting to the correct lisp interpreter, but since I am very new to emacs and lisp I am stuck here. My setup is:

2
BTW - I tried removing my customizations and that did not work still. All I had left was: (setq inferior-lisp-program "/usr/local/bin/clisp") (add-to-list 'load-path "~/code/playground/lisp/slime/") (require 'slime) (slime-setup)arnab

2 Answers

6
votes

The following is what I did to get Common Lisp and Clojure to work in the same Emacs installation, along with the excellent emacs-starter-kit. This won't let you use both at the same time (you have to restart Emacs to switch from CL to Clojure or vice versa)

I believe that the version of SLIME in ELPA is old, but works for Clojure. Newer version of SLIME won't work for Clojure. Additionally, this version of SLIME seems to be stripped down (no swank-loader.el?) and won't work with Common Lisp.

These are the steps I did to get this to work, it's just what worked for me. All of the bits are under active development, so I think breakage in this area is pretty likely.

With a fresh Emacs (no configuration at all, so move anything .emacs somewhere else for the moment) install ELPA:

http://tromey.com/elpa/install.html

From within Emacs, install the packages "slime" and "slime-repl". (M-x package-list-packages then C-s slime then i to select and x to install)

Move the files in ~/.emacs.d/elpa/slime-20100404 and ~/.emacs.d/elpa/slime-repl-20100404 to a new directory like ~/hacking/lisp/elpa-slime.

Throw out the ELPA install: $ rm -rf .emacs.d.

Now clone the emacs-starter-kit and move it to .emacs.d. I only did this with a fresh copy from technomancy's Github, so try that first if you have problems.

Get the latest SLIME with CVS:

cvs -d :pserver:anonymous:[email protected]:/project/slime/cvsroot co cvs-slime

I don't think OS X comes with CVS installed, so you'll need to install it from Macports, Homebrew or something.

I put cvs-slime in ~/hacking/lisp.

Hopefully it's obvious what the Emacs Lisp below does:

(defun slime-common-lisp ()
  (interactive)
  (setq inferior-lisp-program "/usr/local/bin/sbcl") ; your Common Lisp impl
  (add-to-list 'load-path "~/hacking/lisp/cvs-slime/")  ; your SLIME from CVS directory
  (require 'slime)
  (slime-setup '(slime-repl))
  (slime))

(defun slime-clojure ()
  (interactive)
  (add-to-list 'load-path "~/hacking/lisp/elpa-slime")
  (require 'slime)
  (slime-setup '(slime-repl))
  (slime-connect "localhost" 4005))

For Clojure you'd have to start the Clojure runtime and swank-clojure on port 4005, I think using Leiningen is the approved method:

Create a new project:

$ lein new project
$ cd project

In project.clj:

(defproject newclj "1.0.0-SNAPSHOT"
    :description "FIXME: write"
    :dependencies [[org.clojure/clojure "1.2.0"]
                   [org.clojure/clojure-contrib "1.2.0"]]
    :dev-dependencies [[swank-clojure "1.2.1"]])

Then:

$ lein deps
$ lein swank

Edited to add:

If you find that Paredit in the SLIME REPL is broken while using this setup, check this out: http://www.emacswiki.org/emacs/ParEdit#toc3

At least one other potential issue with this is that, AFAICT, if you open a Common Lisp source file and then start SLIME, you won't be able to send forms from the first buffer to the SLIME buffer. So open a SLIME buffer before opening any Common Lisp source files, and it should work. This doesn't seem to apply to Clojure.

References:

emacs setup for both clojure and common lisp with slime-fancy (slime-autodoc)

https://github.com/technomancy/swank-clojure/issues/closed#issue/31/comment/544166

1
votes

If u have correctly install slime in your system then better use sbcl and add the following line in your ~/.emacs (setq inferior-lisp-program "/usr/bin/sbcl")

/usr/bin/sbcl can be different according to your sbcl installation path.