Question

I have the following from the slime repl (no clojure.contib functions found):

M-X slime
user=> (:require 'clojure.contrib.string)
nil
user=> (doc clojure.contrib.string/blank?)
java.lang.Exception: Unable to resolve var: clojure.contrib.string/blank? in this context (NO_SOURCE_FILE:10)

And the following when starting clojure from console (but here everything is being found OK):

adr@~/clojure/cloj-1.2$ java -cp /home/adr/clojure/cloj-1.2/clojure.jar:/home/adr/clojure/cloj-1.2/clojure-contrib.jar -server clojure.main
user=> (:require 'clojure.contrib.string)
nil
user=> (doc clojure.contrib.string/blank?)
-------------------------
clojure.contrib.string/blank?
([s])
  True if s is nil, empty, or contains only whitespace.
nil

In my .emacs I have the following:

(setq inferior-lisp-program "java -cp /home/adr/clojure/cloj-1.2/clojure.jar:/home/adr/clojure/cloj-1.2/clojure-contrib.jar -server clojure.main")

My clojure jars (1.2) are at '/home/adr/clojure/cloj-1.2'.

I;m a newbie with emacs, been following some tutorials. For some time I've been trying to use the clojure.contrib library from Emacs, but "M-X slime" finds no clojure.contrib. Please, help

Edit: if that would help, now i saw that when using M-X slime there is a message:

(progn (load "/home/adr/.emacs.d/elpa/slime-20100404/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.4493" :coding-system "iso-latin-1-unix"))

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

Edit2: But there is no such error message if I use M-X slime-connect after having started a "lein swank" in a directory (though even starting with "M-X slime-connect" there are no clojure-contrib libraries found in the REPL (though they are downloaded by leiningen as dependency)).

Was it helpful?

Solution 2

It seems to me that I was using the wrong way to "require" libraries in the REPL (due to my inexperience with clojure); when using a syntax such as:

user=> (require 'clojure.contrib.string)
nil
user=> (clojure.contrib.string/blank? "asd")
false

all the libraries are being found OK (no matter if using "M-X slime" for a non-swank REPL or "M-X slime-connect" for a swank server). So it was entirely my mistake (I have found hints about my mistake at this stackoverflow answer: Why do I get an error when I run (use 'clojure.contrib.repl-utils)?)

OTHER TIPS

This line:

(progn (load "/home/adr/.emacs.d/elpa/slime-20100404/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.4493" :coding-system "iso-latin-1-unix"))

is Common Lisp, not Clojure, but since you set inferior-lisp-program to Clojure, slime can't start a swank server.

See the following sections in swank-clojure project:

  • Connecting with SLIME
  • Embedding
  • swank-clojure.el

The functionality you want is probably in swank-clojure.el, but it is not recommended anymore.

As you're already using ELPA:

add-to-list 'package-archives
         '("technomancy" . "http://repo.technomancy.us/emacs/") t)

M-x package-install ;(slime-repl)
M-x slime-connect
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top