What is wrong with my emacs/slime setup (compile-and-load/eval not working)?
Asked Answered
D

2

6

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:

Detribalize answered 29/12, 2010 at 3:35 Comment(1)
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)Detribalize
S
6

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

Schrick answered 29/12, 2010 at 15:35 Comment(8)
So this setup worked for Clojure with slime, but did not for the clisp slime integration. Somehow when I say M-x slime-common-lisp, it's still using slime from elpa. How do I fix that?Detribalize
Try restarting Emacs before using M-x slime-common-lisp. An Emacs wizard would probably be able to say how to unload the ELPA SLIME before loading the CVS one but I don't know how to do it.Schrick
Yeah I did restart emacs before I tried M-x slime-common-lisp. However the ESK is loading the elpa/slime* before my slime-cvs one and hence the problem. I'll try asking on esk issues too. Thanks.Detribalize
Report back! I struggled with this and might not have taken as close notes as I should have. It seems to work for me but maybe there's something else I did.Schrick
Ok I took a look at my setup tonight after work and updated my answer. What I did differently was to download the ELPA version of SLIME and then put that somewhere separate, unmanaged by the ELPA that comes with emacs-starter-kit. This is a pretty fragile set up, since if swank-clojure requires a newer version of SLIME and ELPA is updated, you'd have to fix this, so it will require a little baby sitting. On the other hand, I've read that ELPA is being neglected until then next major release of Emacs, so it might be safe for a while. Good luck, and let me know if it works for you!Schrick
Awesome! This works great! I'm willing to live with the pain of upgrades to have a working environment. BTW - I'm going to put all these steps in a blog soon - so I can repeat them easily. Will add an attribution to you! Thanks!Detribalize
You're welcome! I had written a blog post about it last month, but the set up was slightly different (ie wrong). I updated it last night. Of course, feel free to do your own write-up, more Lisp blogging the better!Schrick
Cool! I mostly blogged so I can mindlessly copy-paste it next time: arnab-deka.com/posts/notes/emacs-setupDetribalize
R
1

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.

Remediosremedy answered 7/3, 2016 at 10:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.