5
votes

SLIME

I'm pretty new to both Clojure & emacs and I've been trying to set up SLIME for Clojure. The official documentation implicitly assumes you know what your doing with emacs. There isn't just a bunch of code you can stick into your configuration files. Since I am interested in Clojure for Data Analysis, I don't really want to deal with Leiningen if at all possible, but I want the dynamic environment that slime provides.

I have installed Clojure from git in /opt/clojure/ and clojure-contrib in /opt/clojure-contrib and I can get a repl. I installed swank-clojure, clojure-mode, and slime from github in `~/.bin following this tutorial. I changed a few things around when this wasn't working by adding some stuff from the comments section of the official documentation.

When I start slime with M-x slime I get a continuous Polling "/tmp/slime.14113".. (Abort with 'M-x slime-abort-connection'.).

Here is my init-clj.el:

;; clojure-mode
(add-to-list 'load-path "~/.bin/clojure-mode")


;; swank-clojure
(add-to-list 'load-path "~/.bin/swank-clojure")

(setq swank-clojure-jar-path "/opt/clojure/clojure.jar"
  swank-clojure-extra-classpaths (list
                  "~/.bin/swank-clojure/src/swank"
                  "/opt/clojure/clojure-contrib/target/clojure-contrib-1.2.0-SNAPSHOT.jar"))

(require 'swank-clojure)

;; slime
(eval-after-load "slime" 
  '(progn (slime-setup '(slime-repl))))

(add-to-list 'load-path "~/.bin/slime")
(require 'slime)
(eval-after-load 'slime '(setq slime-protocol-version 'ignore))
  (slime-setup '(slime-repl))
(require 'clojure-mode)
(require 'clojure-test-mode)

Here is the error I get when I call it when ants.clj is open:

(progn (load "/home/kca/.bin/slime/swank-loader.lisp" :verbose t) (funcall (read- from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.14113" :coding-system "iso-latin-1-unix"))

Clojure 1.2.0-master-SNAPSHOT
user=> java.lang.Exception: Unable to resolve symbol: progn in this context (NO_SOURCE_FILE:1)

Inferior Lisp

I made a script in .bin/ called clj-repl that holds the java command to start a repl. I then M-x set-variable inferior-lisp-program /home/wdkrnls/.bin/clj-repl. Emacs complains its the wrong type.

2
About the inferior lisp setup: if you're doing M-x set-variable inferior-lisp-program followed by the path to your script, make sure to enclose the path in double quotes; otherwise it won't be read in as a string and Emacs will complain about the resulting type (probably symbol). If this doesn't help, could you provide some more details about your script and what you do in Emacs (or ~/.emacs / ~/.emacs.d/init.el) to set it up as your inferior lisp program?Michał Marczyk
Thanks Michal. Now its working. I had 2 problems, the first was what you said. The second was that when I did put quotes around the path to the script, I didn't kill the old inferior-lisp process, so it looked like something else was happening.wdkrnls

2 Answers

5
votes

The best way to use Clojure is to start by installing Leiningen.

Then install Swank Clojure as a Leiningen plugin.

Next, I'd recommend stripping your current custom Clojure setup from .emacs, and installing ELPA, and then setting up the following initialization code in your .emacs file:

;; Find this line, added by ELPA:
(require 'package)
;; and add the following expression:
(add-to-list 'package-archives
             '("marmalade" . 
               "http://marmalade-repo.org/packages/") t)
;; ... and the rest of the ELPA init code
(package-initialize)

Then, run package-list-packages and install clojure-mode and slime (and paredit for good measure), and anything else you might want.

This should have you all set up and ready to use SLIME in (Leiningen) Clojure projects. And despite the seemingly complex procedure here, you can create a single "uberjar" from your projects to deploy on other servers with absolutely no dependency hassle.

1
votes

Try the method detailed here. It takes a couple of minutes to set everything up from scratch on a clean unix or mac box:

http://www.learningclojure.com/2010/08/clojure-emacs-swank-slime-maven-maven.html