My SLIME installation diary

135 views
Skip to first unread message

Stuart Sierra

unread,
Dec 23, 2008, 1:15:56 PM12/23/08
to Clojure
Hi folks,

Up 'till now I've been perfectly happy with Emacs' inferior-lisp mode,
but I decided to try SLIME. Since there seem to be a lot of questions
about SLIME, I thought I would make a record of everything I did to
get it set up. This is on OSX with Aquamacs. I'm setting up Clojure,
clojure-contrib, SLIME, swank-clojure, clojure-mode, and paredit.

Step 1: prepare a space

cd /Users/stuart/Projects
mkdir clj
cd clj

Step 2: get the latest sources of everything

svn checkout http://clojure.googlecode.com/svn/trunk/ clojure
svn checkout http://clojure-contrib.googlecode.com/svn/trunk/
contrib
cvs -d :pserver:anonymous:anon...@common-lisp.net:/project/slime/
cvsroot co slime
git clone git://github.com/jochu/clojure-mode.git clojure-mode
git clone git://github.com/jochu/swank-clojure.git swank-clojure

Step 3: compile everything

cd clojure
ant
cd ..
cd contrib
ant -Dclojure.jar=../clojure/clojure.jar
cd ..

Step 3: edit Emacs configuration. Since this is Aquamacs, I edited
~/Library/Preferences/Aquamacs Emacs/Preferences.el
to add the following lines:

(push "/Users/stuart/Projects/clj/clojure-mode" load-path)
(load-library "clojure-auto")
(load-library "clojure-paredit")

(push "/Users/stuart/Projects/clj/swank-clojure" load-path)
(require 'swank-clojure-autoload)
(swank-clojure-config
(setq swank-clojure-jar-path
"/Users/stuart/Projects/clj/clojure/clojure.jar")
(setq swank-clojure-extra-classpaths
(list "/Users/stuart/Projects/clj/contrib/src"
"/Users/stuart/Projects/clj/contrib/classes")))

(push "/Users/stuart/Projects/clj/slime" load-path)
(require 'slime)
(slime-setup)

Step 4: restart Emacs

Step 5: In Emacs, enter: M-x slime

Step 6: SLIMEy, Clojurey goodness!

The only snag I ran into was figuring out that swank-clojure has to be
loaded BEFORE slime in the Emacs configuration.

-Stuart Sierra

bOR_

unread,
Feb 4, 2009, 6:36:49 AM2/4/09
to Clojure
As we never can have enough examples, and this one was about the
simplest that just worked on Ubuntu, I'll paste my variant of it here.
It is slightly different because I'm behind a proxy, and thus my git
calls are somewhat different, and I got my slime from a git repository
rather than a cvs one.

;; compiled together from http://riddell.us/clojure/ and
;; http://groups.google.com/group/clojure/browse_thread/thread/bb2445519f74dcef/e725f3cab7e6a76

;; run from ~/opt
svn checkout http://clojure.googlecode.com/svn/trunk/ clojure
svn checkout http://clojure-contrib.googlecode.com/svn/trunk/ contrib

;;cvs -d :pserver:anonymous:anon...@common-lisp.net:/project/slime/
cvsroot co slime
;; Doesn't work for me, might be something with my proxy. As an
alternative:
git clone http://git.boinkor.net/git/slime.git


git clone http://github.com/jochu/clojure-mode.git clojure-mode
git clone http://github.com/jochu/swank-clojure.git swank-clojure

cd clojure
ant
cd ..
cd contrib
ant -Dclojure.jar=../clojure/clojure.jar
cd ..


;; put the below in ~/.emacs, and uncomment the
;; comments that start with only 1 ;
;(add-to-list 'load-path "~/opt/clojure-mode")
;(require 'clojure-mode)

;; Swank bit
;; Instructions from
;; http://github.com/jochu/swank-clojure/tree/master
;;
;(add-to-list 'load-path "~/opt/swank-clojure")
;(require 'swank-clojure-autoload)
;(swank-clojure-config
; (setq swank-clojure-jar-path "~/opt/clojure/clojure.jar")
; (setq swank-clojure-extra-classpaths (list
; "~/opt/contrib/src"
; "~/opt/contrib/classes"
; "~/.clojure")))
;
;
;(add-to-list 'load-path "~/opt/slime")
;(require 'slime)
;(slime-setup)



;; Uncomment to turn off the "beep" which sounded
;; everytime the top or bottom of a file was reached
;(setq ring-bell-function 'ignore)


On Dec 23 2008, 7:15 pm, Stuart Sierra <the.stuart.sie...@gmail.com>
wrote:
> Hi folks,
>
> Up 'till now I've been perfectly happy with Emacs' inferior-lisp mode,
> but I decided to try SLIME.  Since there seem to be a lot of questions
> about SLIME, I thought I would make a record of everything I did to
> get it set up.  This is on OSX with Aquamacs.  I'm setting up Clojure,
> clojure-contrib, SLIME, swank-clojure, clojure-mode, and paredit.
>
> Step 1: prepare a space
>
>     cd /Users/stuart/Projects
>     mkdir clj
>     cd clj
>
> Step 2: get the latest sources of everything
>
>     svn checkouthttp://clojure.googlecode.com/svn/trunk/clojure
>     svn checkouthttp://clojure-contrib.googlecode.com/svn/trunk/
> contrib
>     cvs -d :pserver:anonymous:anonym...@common-lisp.net:/project/slime/

Craig McDaniel

unread,
Feb 4, 2009, 7:12:55 AM2/4/09
to Clojure
Thanks Stuart. Since the clojure-contrib.jar you built in step 3 does
include both clj and class files, I think you can reduce

(setq swank-clojure-extra-classpaths
(list "/Users/stuart/Projects/clj/contrib/src"
"/Users/stuart/Projects/clj/contrib/classes"))

to

(setq swank-clojure-extra-classpaths
(list "/Users/stuart/Projects/clj/contrib/clojure-
contrib.jar"))

-Craig

Phil Hagelberg

unread,
Feb 4, 2009, 2:14:19 PM2/4/09
to clo...@googlegroups.com

Seeing all these complicated steps that need to be reproduced made me
wonder if it couldn't be automated. I've added an M-x clojure-install
command to my fork of clojure-mode, so if you are wanting to get started
with SLIME and Clojure, please give it a look.

Installation and configuration should be as simple as putting this
file into your Emacs config, pressing M-x clojure-install, and following
a few simple instructions:

http://github.com/technomancy/clojure-mode/blob/4506f07fd69262057fd07ece127466e27fb6b74d/clojure-mode.el

I blogged about the details here: http://technomancy.us/122

I've tested this on GNU/Linux systems (Emacs 23 and 22), and it's been
reported to work well on Mac OS X also. Please let me know how it works
for you or if you have any comments. This has definitely been a pain
point in the past, and it would be great if it could be streamlined.

-Phil

chris

unread,
Feb 4, 2009, 4:36:11 PM2/4/09
to Clojure
(defun get-classpath-list ()
(if
(or
(eq 'windows-nt system-type)
(eq 'ms-dos system-type))
(split-string (getenv "CLASSPATH") ";")
(split-string (getenv "CLASSPATH") ":")))

(setq swank-clojure-jar-path
(dev-dir "clojure/clojure.jar"))
(setq swank-clojure-extra-classpaths
(get-classpath-list))

Get the classpath from the system and set it as your swank classpath.

My slime setup currently fails completely on windows, however. The
slime repl never starts; is there a way to get slime to dump all of
its communication (both ways, not just sending) to a file?

Chris

On Feb 4, 12:14 pm, Phil Hagelberg <p...@hagelb.org> wrote:
> Seeing all these complicated steps that need to be reproduced made me
> wonder if it couldn't be automated. I've added an M-x clojure-install
> command to my fork of clojure-mode, so if you are wanting to get started
> with SLIME and Clojure, please give it a look.
>
> Installation and configuration should be as simple as putting this
> file into your Emacs config, pressing M-x clojure-install, and following
> a few simple instructions:
>
> http://github.com/technomancy/clojure-mode/blob/4506f07fd69262057fd07...

chris

unread,
Feb 4, 2009, 4:37:48 PM2/4/09
to Clojure
Also, I would love to get some more debugging support into slime.

I was wondering how difficult it would be to use the java debugging
API, embedded in the swank module, and send debug commands across?

Chris

Phil Hagelberg

unread,
Feb 4, 2009, 5:04:40 PM2/4/09
to clo...@googlegroups.com
chris <cnue...@gmail.com> writes:

> (defun get-classpath-list ()
> (if
> (or
> (eq 'windows-nt system-type)
> (eq 'ms-dos system-type))
> (split-string (getenv "CLASSPATH") ";")
> (split-string (getenv "CLASSPATH") ":")))
>
> (setq swank-clojure-jar-path
> (dev-dir "clojure/clojure.jar"))
> (setq swank-clojure-extra-classpaths
> (get-classpath-list))
>
> Get the classpath from the system and set it as your swank classpath.

Thanks; this looks useful. But I've heard people say that using
environment variables for your classpath should be avoided. I'm not sure
what the reasoning behind this is though. Maybe it's just a case of "you
should be explicit instead of implicit"; I could see how it would be
annoying to track down problems that result from the value of an
invisible variable that lives outside your code base.

If the general consensus is that using environment variables is a good
idea, then I can merge this into clojure-mode.

For projects that depend on Java jars, my approach so far has been to
construct the classpath list from a directory listing and then include
the elisp code to do so in the source directory:

(setq concourse-dir (file-name-directory
(or (buffer-file-name) load-file-name))
swank-clojure-jar-path (concat concourse-dir "/jars/clojure.jar")
swank-clojure-extra-classpaths (directory-files (concat concourse-dir "/jars/")
t ".jar$"))

-Phil

Tom Emerson

unread,
Feb 5, 2009, 1:21:20 PM2/5/09
to clo...@googlegroups.com
On Wed, Feb 4, 2009 at 4:36 PM, chris <cnue...@gmail.com> wrote:
[snip]

> My slime setup currently fails completely on windows, however. The
> slime repl never starts; is there a way to get slime to dump all of
> its communication (both ways, not just sending) to a file?

Ditto, I'm still busted on Windows with the latest snaps of
everything, just as I was a couple of weeks ago. Haven't tried
installing on my Ubuntu box yet to see if this is indeed windows
specific.

-tree

--
Tom Emerson
trem...@gmail.com
http://treerex.blogspot.com/

chris

unread,
Feb 5, 2009, 2:07:32 PM2/5/09
to Clojure
I haven't seen a clear argument about the classpath variable one way
or another. I also haven't figured out an elegant way to deal with
it.

I have no problem running a shell script from a terminal I want to
develop with to setup classpath to be exactly what I expect it to be
on a unix system. On windows, this is a little strange.

One thing I am certain about is that as my java setup gets more
advanced and I start using more interesting jars and jnilibs, my
classpath and my java.library.path are both going to get more
complex. I am certainly *not* going to repeat my non-trivial
classpath into my .emacs file thus forcing myself to change something
difficult to get correct in the first place in at least two places.

On windows it appears that java correctly using the path env. variable
to load jni libs. On Mac, it doesn't. One huge improvement would be
that any binary libs, be they jni libs *or* dlls that java finds next
to jars in the classpath are eligible for loading on both systems.
Thus I don't have to setup my java loading system using two completely
unrelated environment variables. Using JOGL and clojure on windows
and mac has brought at lot of the pain of java right to the forefront
in my case.

Chris

On Feb 5, 11:21 am, Tom Emerson <tremer...@gmail.com> wrote:
> On Wed, Feb 4, 2009 at 4:36 PM, chris <cnuern...@gmail.com> wrote:
>
> [snip]
>
> > My slime setup currently fails completely on windows, however.  The
> > slime repl never starts; is there a way to get slime to dump all of
> > its communication (both ways, not just sending) to a file?
>
> Ditto, I'm still busted on Windows with the latest snaps of
> everything, just as I was a couple of weeks ago. Haven't tried
> installing on my Ubuntu box yet to see if this is indeed windows
> specific.
>
>     -tree
>
> --
> Tom Emerson
> tremer...@gmail.comhttp://treerex.blogspot.com/

chris

unread,
Feb 5, 2009, 4:00:48 PM2/5/09
to Clojure

bOR_

unread,
Feb 9, 2009, 4:36:39 AM2/9/09
to Clojure

HI Phil. Tried the clojure-install on a fairly clean ubuntu / emacs23

Here is what went and what went wrong:
Had to use a different .emacs. Just autoload and add-to-list didn't
seem to load clojure-mode.el. Took a moment to figure out that I had
to set clojure-src-root as well, as that isn't mentioned at the top of
the clojure-mode.el file. I've no clue why autoload won't work.
-----------
(push "/home/boris/.emacs.d" load-path)
(load-library "clojure-mode")

(autoload 'clojure-mode "clojure-mode" "A major mode for Clojure" t)
(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
(setq clojure-src-root "/home/boris/opt")
-------------


The kevinoneill clojure-contrib failed for me (might be my
connection), so I replaced both kevinoneills with the svn checkouts
from googlecode. In retrospect it might have been because I didn't
replace git:// with http:// that is neccesary for me to git past a
proxy. The slime git worked fine, but took ages.. I replaced it with
git clone http://git.boinkor.net/git/slime.git

------------
"git clone git://github.com/kevinoneill/clojure.git"
"git clone git://github.com/kevinoneill/clojure-contrib.git"
to
------------

Furthermore, it might be nice to have an 'overwrite? ignore? keep?
option when clojure-install encounters relevant directories in the
clojure-src-root already. With all the failed gits, I've been
downloading clojure and clojure-contrib 5 times before all was
downloaded.

The whole thing compiled without any trouble, and after a M-x slime
told me it "Cannot open load file: slime-repl". I am guessing it is
because I use a different slime git.


bOR_

unread,
Feb 9, 2009, 5:35:43 AM2/9/09
to Clojure
Slowly wrestling myself through getting to know emacs.

Ok. autoload works fine. Didn't realize I have to open emacs with
a .clj file for the clojure-mode to load. Now looking where this
'Cannot open load file:slime-repl' is coming from.

On Feb 9, 10:36 am, bOR_ <boris.sch...@gmail.com> wrote:
> HI Phil. Tried the clojure-install on a fairly clean ubuntu / emacs23
>
> Here is what went and what went wrong:
> Had to use a different .emacs. Just autoload and add-to-list didn't
> seem to load clojure-mode.el. Took a moment  to figure out that I had
> to set clojure-src-root as well, as that isn't mentioned at the top of
> the clojure-mode.el file. I've no clue why autoload won't work.
> -----------
> (push "/home/boris/.emacs.d" load-path)
> (load-library "clojure-mode")
>
> (autoload 'clojure-mode "clojure-mode" "A major mode for Clojure" t)
> (add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
> (setq clojure-src-root "/home/boris/opt")
> -------------
>
> The kevinoneill clojure-contrib failed for me (might be my
> connection), so I replaced both kevinoneills with the svn checkouts
> from googlecode. In retrospect it might have been because I didn't
> replace git:// with http:// that is neccesary for me to git past a
> proxy. The slime git worked fine, but took ages.. I replaced it with
> git clonehttp://git.boinkor.net/git/slime.git
>
> ------------
> "git clone git://github.com/kevinoneill/clojure.git"
> "git clone git://github.com/kevinoneill/clojure-contrib.git"
> to
> "svn checkouthttp://clojure.googlecode.com/svn/trunk/clojure"
> "svn checkouthttp://clojure-contrib.googlecode.com/svn/trunk/

Phil Hagelberg

unread,
Feb 9, 2009, 2:05:30 PM2/9/09
to clo...@googlegroups.com
bOR_ <boris....@gmail.com> writes:

> Had to use a different .emacs. Just autoload and add-to-list didn't
> seem to load clojure-mode.el.

That's correct; this will not load the code. It just sets it up so that
the file gets loaded on-demand when you open a clojure file. I will add
a note mentioning that the first time you want to run the installer you
should manually load clojure-mode.el yourself since the autoload won't
help you. This is unclear in the current instructions; sorry.

> Took a moment to figure out that I had to set clojure-src-root as
> well, as that isn't mentioned at the top of the clojure-mode.el
> file. I've no clue why autoload won't work.

That's not actually right; you don't need to set clojure-src-root to use
clojure-mode. You only need it to use SLIME if you install somewhere
other than ~/src. It will give you instructions about this when the
installation completes, but it looks like you had network connectivity
issues keeping this from working.

> (push "/home/boris/.emacs.d" load-path)

This is actually already on the load-path by default; no need to add it.

> (load-library "clojure-mode")

You only need to do this when you're running the installer, so it's
probably not worth running every single time you launch Emacs.

> The kevinoneill clojure-contrib failed for me (might be my
> connection), so I replaced both kevinoneills with the svn checkouts
> from googlecode. In retrospect it might have been because I didn't
> replace git:// with http:// that is neccesary for me to git past a
> proxy. The slime git worked fine, but took ages.. I replaced it with
> git clone http://git.boinkor.net/git/slime.git

Ugh... I didn't think about nasty firewalls blocking the git port. I
don't want to switch it to http by default, but maybe it could provide a
fallback mechanism?

> Furthermore, it might be nice to have an 'overwrite? ignore? keep?
> option when clojure-install encounters relevant directories in the
> clojure-src-root already. With all the failed gits, I've been
> downloading clojure and clojure-contrib 5 times before all was
> downloaded.

Maybe. I was trying to keep it simple, but if this turns out to be a
common problem I could add it.

> The whole thing compiled without any trouble, and after a M-x slime
> told me it "Cannot open load file: slime-repl". I am guessing it is
> because I use a different slime git.

Your slime checkout should have a contrib directory containing
slime-repl.el. If this doesn't exist, then it's a problem with the
checkout. If it does, it's a problem with the way the load-path is set
up.

-Phil

bOR_

unread,
Feb 9, 2009, 2:42:28 PM2/9/09
to Clojure
Thanks for all the explanations. I'll try again this wednesday!

bOR_

unread,
Feb 11, 2009, 5:50:25 AM2/11/09
to Clojure
>> (push "/home/boris/.emacs.d" load-path)
>This is actually already on the load-path by default; no need to add it.

Standard load-path on ubuntu didn't include ~/.emacs.d for me. Not
sure why not.

load-path is a variable defined in `C source code'.
Its value is
("/etc/emacs-snapshot" "/etc/emacs" "/usr/local/share/emacs/23.0.60/
site-lisp" "/usr/local/share/emacs/site-lisp" "/usr/share/emacs/
23.0.60/site-lisp" "/usr/share/emacs/site-lisp" "/usr/share/emacs/
23.0.60/lisp" "/usr/share/emacs/23.0.60/lisp/url" "/usr/share/emacs/
23.0.60/lisp/textmodes" "/usr/share/emacs/23.0.60/lisp/progmodes" "/
usr/share/emacs/23.0.60/lisp/play" "/usr/share/emacs/23.0.60/lisp/org"
"/usr/share/emacs/23.0.60/lisp/obsolete" "/usr/share/emacs/23.0.60/
lisp/nxml" "/usr/share/emacs/23.0.60/lisp/net" "/usr/share/emacs/
23.0.60/lisp/mh-e" "/usr/share/emacs/23.0.60/lisp/mail" "/usr/share/
emacs/23.0.60/lisp/language" "/usr/share/emacs/23.0.60/lisp/
international" "/usr/share/emacs/23.0.60/lisp/gnus" "/usr/share/emacs/
23.0.60/lisp/eshell" "/usr/share/emacs/23.0.60/lisp/erc" "/usr/share/
emacs/23.0.60/lisp/emulation" "/usr/share/emacs/23.0.60/lisp/emacs-
lisp" "/usr/share/emacs/23.0.60/lisp/calendar" "/usr/share/emacs/
23.0.60/lisp/calc" "/usr/share/emacs/23.0.60/leim")


Anyway,

1. Creating a .emacs with the load-path .emacs.d
2. Downloading clojure-mode.el
3. replacing git:// with http:// to get past my proxy
4. The slime git kept failing (stalled somewhere near the end of
downloading), so I removed that line from clojure-mode.el and
installed a snapshot of slime myself.
5. The clojure git failed as well, I replaced it with the "svn
checkout http://clojure.googlecode.com/svn/trunk/ clojure" in clojure-
mode.el
6. idem contrib: replaced with "svn checkout
http://clojure-contrib.googlecode.com/svn/trunk/contrib" in clojure-
mode.el
7. M-x load-library clojure-mode
8. M-x clojure-install <ret><ret>
9. added (clojure-slime-config) to .emacs
10. M-x slime

Success! Thank you.

I think perhaps the best thing to do with the failing gits (for
whatever reason) is to just let the script skip the downloading of new
checkouts if an old checkout is present, and to let it give a message
like this: "Failed to checkout slime, please do so manually, install
in ~/src and rerun M-x clojure-install".

bOR_

unread,
Feb 11, 2009, 7:57:48 AM2/11/09
to Clojure
>
> Success! Thank you.

Success lasted till I tried to restart emacs. Here is where I am stuck
again:
1. It can't find M-x slime
clojure-slime-config doesn't seem to be an option either to manually
run with M-x clojure<tab>

The solution seems to be to take the functions in clojure-slime-config
and put them into my .emacs
together with a setq. The setq seems to be mandatory.

(setq clojure-src-root "~/src")
(add-to-list 'load-path (concat clojure-src-root "/slime"))
(add-to-list 'load-path (concat clojure-src-root "/slime/contrib"))
(add-to-list 'load-path (concat clojure-src-root "/swank-clojure"))

(require 'slime-autoloads)
(require 'swank-clojure-autoload)

(slime-setup '(slime-fancy slime-repl))

(setq swank-clojure-jar-path (concat clojure-src-root "/clojure/
clojure.jar")
swank-clojure-extra-classpaths
(list (concat clojure-src-root "/clojure-contrib/clojure-
contrib/src/")))



A more general question. Why use "\\.clj$", where most other processes
seem to have "\\.clj\\'" as regexp to auto-mode-alist?

bOR_

unread,
Feb 11, 2009, 8:41:09 AM2/11/09
to Clojure
Spotted an error in clojure-mode.el. Swank-clojure-extra-classpaths
needs to be changed from this to the following, in order for people to
be able to use contrib.

(setq swank-clojure-jar-path (concat clojure-src-root "/clojure/
clojure.jar")
swank-clojure-extra-classpaths
(list (concat clojure-src-root "/clojure-contrib/src/"))))

(setq swank-clojure-jar-path (concat clojure-src-root "/clojure/
clojure.jar")
swank-clojure-extra-classpaths
(list (concat clojure-src-root "/contrib/src/"))))

Now it works!

user> (System/getProperty "java.class.path")
"/home/boris/src/clojure/clojure.jar:/home/boris/src/contrib/src/"
user> (require 'clojure.contrib.math)
nil
user>

Phil Hagelberg

unread,
Feb 12, 2009, 12:35:15 PM2/12/09
to clo...@googlegroups.com
bOR_ <boris....@gmail.com> writes:

>>> (push "/home/boris/.emacs.d" load-path)
>>This is actually already on the load-path by default; no need to add it.
>
> Standard load-path on ubuntu didn't include ~/.emacs.d for me. Not
> sure why not.

You're right; my bad.

> 1. Creating a .emacs with the load-path .emacs.d
> 2. Downloading clojure-mode.el
> 3. replacing git:// with http:// to get past my proxy
> 4. The slime git kept failing (stalled somewhere near the end of
> downloading), so I removed that line from clojure-mode.el and
> installed a snapshot of slime myself.
> 5. The clojure git failed as well, I replaced it with the "svn
> checkout http://clojure.googlecode.com/svn/trunk/ clojure" in clojure-
> mode.el

I can't reproduce these download problems... Has anyone else had trouble
with these URLs?

> I think perhaps the best thing to do with the failing gits (for
> whatever reason) is to just let the script skip the downloading of new
> checkouts if an old checkout is present, and to let it give a message
> like this: "Failed to checkout slime, please do so manually, install
> in ~/src and rerun M-x clojure-install".

Yeah, not a bad idea.

> 1. It can't find M-x slime clojure-slime-config doesn't seem to be an
> option either to manually run with M-x clojure<tab>

clojure-slime-config is a function, but it's not a command, so you can't
invoke it via M-x. It should only be invoked from your .emacs file. I
suspect you're missing the autoload that it mentions in the
clojure-mode.el header:

;; (autoload 'clojure-mode "clojure-mode" "A major mode for Clojure" t)


;; (add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))

That should go in your .emacs file.

I should have mentioned that if you don't already have an Emacs config,
you could try the Emacs Starter Kit, where clojure-mode is already
installed for you. (You would still have to install Clojure though.) But
the autoloads are all set up for you.

http://github.com/technomancy/emacs-starter-kit

> (setq swank-clojure-jar-path (concat clojure-src-root "/clojure/clojure.jar")


> swank-clojure-extra-classpaths
> (list (concat clojure-src-root "/contrib/src/"))))

This isn't right according to the default installation, but if you
checked things out manually it could be different.

-Phil

bOR_

unread,
Feb 13, 2009, 3:58:40 AM2/13/09
to Clojure
That starter-kit sounds perhaps easier. I'll try the starter-kit. I
want the install to be fairly easy, if I want to convince others at
work to play with it :).

On Feb 12, 6:35 pm, Phil Hagelberg <p...@hagelb.org> wrote:
> bOR_ <boris.sch...@gmail.com> writes:
> >>> (push "/home/boris/.emacs.d" load-path)
> >>This is actually already on the load-path by default; no need to add it.
>
> > Standard load-path on ubuntu didn't include ~/.emacs.d for me. Not
> > sure why not.
>
> You're right; my bad.
>
> > 1. Creating a .emacs with the load-path .emacs.d
> > 2. Downloading clojure-mode.el
> > 3. replacing git:// with http:// to get past my proxy
> > 4. The slime git kept failing (stalled somewhere near the end of
> > downloading), so I removed that line from clojure-mode.el and
> > installed a snapshot of slime myself.
> > 5. The clojure git failed as well, I replaced it with the "svn
> > checkouthttp://clojure.googlecode.com/svn/trunk/clojure" in clojure-

David

unread,
Feb 13, 2009, 4:31:28 PM2/13/09
to Clojure
I have a small problem with clojure-mode in your setup.

Since clojure-mode is autoloaded, it, and SLIME, aren't available
until I load a '.clj' file.
Starting SLIME, though, doesn't add the SLIME menu to the previously
loaded '.clj' buffer
(Newly loaded files get the menu, as they should).

Thanks,
-dms

On Feb 12, 12:35 pm, Phil Hagelberg <p...@hagelb.org> wrote:
> bOR_ <boris.sch...@gmail.com> writes:
> >>> (push "/home/boris/.emacs.d" load-path)
> >>This is actually already on the load-path by default; no need to add it.
>
> > Standard load-path on ubuntu didn't include ~/.emacs.d for me. Not
> > sure why not.
>
> You're right; my bad.
>
> > 1. Creating a .emacs with the load-path .emacs.d
> > 2. Downloading clojure-mode.el
> > 3. replacing git:// with http:// to get past my proxy
> > 4. The slime git kept failing (stalled somewhere near the end of
> > downloading), so I removed that line from clojure-mode.el and
> > installed a snapshot of slime myself.
> > 5. The clojure git failed as well, I replaced it with the "svn
> > checkouthttp://clojure.googlecode.com/svn/trunk/clojure" in clojure-

Phil Hagelberg

unread,
Feb 13, 2009, 4:39:49 PM2/13/09
to clo...@googlegroups.com
David <dsie...@yahoo.com> writes:

> I have a small problem with clojure-mode in your setup.
>
> Since clojure-mode is autoloaded, it, and SLIME, aren't available
> until I load a '.clj' file.
> Starting SLIME, though, doesn't add the SLIME menu to the previously
> loaded '.clj' buffer
> (Newly loaded files get the menu, as they should).

Yeah, I've thought about a hook that runs after SLIME loads to activate
slime-mode for all pre-existing clojure-mode buffers; just haven't
gotten around to it.

If you're handy with elisp, I'd love a patch, otherwise I'll get around
to it eventually. =)

-Phil

David

unread,
Feb 18, 2009, 4:59:21 PM2/18/09
to Clojure
I can't really claim to be handy with elisp, but I got by.
(Is there a guide to elisp functions anywhere? The Lisp
reference didn't include the Common Lisp emulation library,
and I never did find an equivalent to the clojure filter()).

Anyway, here's what I added to my .emacs:

(defun find-ext-for-mode (m)
(let (modes)
(dolist (ext auto-mode-alist modes)
(if (eq (cdr ext) m)
(add-to-list 'modes (car ext))))))
; (find-ext-for-mode 'clojure-mode)

(defun is-clojure-buffer (b)
(let ((regexes (find-ext-for-mode 'clojure-mode)))
(find-if
(lambda (regex) (string-match regex (buffer-name b)))
regexes)))

(defun add-slime-mode-to-existing-buffers ()
(interactive)
(let ((clojure-buffers (remove-if-not 'is-clojure-buffer (buffer-
list))))
(dolist (b clojure-buffers)
(set-buffer b)
(slime-mode))))
(eval-after-load 'slime '(add-slime-mode-to-existing-buffers))

Let me know if you add it to your repository.

There could conceivably be some issues with multiple slime
connections, or with running slime-mode repeatedly on the same
buffer. I couldn't find any easy way to determine if a buffer already
had slime-mode -- love to hear from someone who is actually handy
with elisp!

On Feb 13, 4:39 pm, Phil Hagelberg <p...@hagelb.org> wrote:

Phil Hagelberg

unread,
Feb 18, 2009, 6:34:29 PM2/18/09
to clo...@googlegroups.com
David <dsie...@yahoo.com> writes:

> I can't really claim to be handy with elisp, but I got by.
> (Is there a guide to elisp functions anywhere? The Lisp
> reference didn't include the Common Lisp emulation library,
> and I never did find an equivalent to the clojure filter()).

The Elisp CL emulation package is documented in its own top-level Info
node for some reason rather than in the Elisp manual.

> Anyway, here's what I added to my .emacs:
>

> (defun add-slime-mode-to-existing-buffers ()
> (interactive)
> (let ((clojure-buffers (remove-if-not 'is-clojure-buffer (buffer-
> list))))
> (dolist (b clojure-buffers)
> (set-buffer b)
> (slime-mode))))
> (eval-after-load 'slime '(add-slime-mode-to-existing-buffers))

Cool! It's a little simpler to check for the value of the major-mode
local variable rather than to use the filename, so here's what I ended
up with:

(defun clojure-enable-slime-on-existing-buffers ()
(interactive)
(dolist (buffer (buffer-list))
(if (equal '(major-mode . clojure-mode)
(assoc 'major-mode (buffer-local-variables buffer)))
(with-current-buffer buffer
(slime-mode t)))))

> Let me know if you add it to your repository.

I've committed this to my copy, but I don't know when it will go
upstream to the mainline clojure-mode branch, as the maintainer has been
out of communication for some time.

http://github.com/technomancy/clojure-mode/

> There could conceivably be some issues with multiple slime
> connections, or with running slime-mode repeatedly on the same
> buffer. I couldn't find any easy way to determine if a buffer already
> had slime-mode -- love to hear from someone who is actually handy
> with elisp!

Calling slime-mode with an argument of t forces it to enable rather than
toggling it. I don't know about multiple slime connections though; it
seems kind of edge-casey, though I can look into it if it causes
problems.

Thanks for getting the ball rolling on this.

-Phil

David

unread,
Feb 19, 2009, 4:11:12 AM2/19/09
to Clojure
On Feb 18, 6:34 pm, Phil Hagelberg <p...@hagelb.org> wrote:
> David <dsieg...@yahoo.com> writes:
> The Elisp CL emulation package is documented in its own top-level Info
> node for some reason rather than in the Elisp manual.

Almost certainly historical -- it must be a later, separate
development.

It really should be listed in the 'More Manuals' submenu of the Help
Menu, though -- that's where I looked for documentation. It never
occurred to me that there would be some other elisp manual
someplace else (and my Internet connection was dead -- very
frustrating).

> Cool! It's a little simpler to check for the value of the major-mode
> local variable rather than to use the filename, so here's what I ended
> up with:
>
> (defun clojure-enable-slime-on-existing-buffers ()
>   (interactive)
>   (dolist (buffer (buffer-list))
>     (if (equal '(major-mode . clojure-mode)
>                (assoc 'major-mode (buffer-local-variables buffer)))
>         (with-current-buffer buffer
>           (slime-mode t)))))

Well, that's simpler!

> Thanks for getting the ball rolling on this.

Glad to help,
-dms

Boris Schmid

unread,
Feb 20, 2009, 6:45:11 AM2/20/09
to Clojure
Nice. It starts to work flawless. Did another installation test on a
fresh ubuntu.

1. mark emacs-snapshot and ant for installation in synaptic. You'll
automatically download the other files you need then.
2. get clojure-mode from http://github.com/technomancy/clojure-mode/ ,
and store the .el files in ~/.emacs.d
3. create a ~/.emacs file with (push "~/.emacs.d" load-path) in it.
4. start emacs
5. M-x load-library clojure-mode
6. M-x clojure-install
7. Add these three lines t your .emacs

(autoload 'clojure-mode "clojure-mode" "A major mode for Clojure" t)
(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
(eval-after-load 'clojure-mode '(clojure-slime-config))

Fine! :).
Reply all
Reply to author
Forward
0 new messages