My non-ELPA Emacs swank-clojure setup

100 views
Skip to first unread message

Ævar Arnfjörð Bjarmason

unread,
Apr 7, 2010, 5:12:11 PM4/7/10
to clo...@googlegroups.com
I stubbornly refuse to use ELPA. I keep my ~/.emacs and associated
libraries in Git[1][2] and don't like deviating from that with ELPA by
running the clojure code from an unversioned directory that isn't
automatically there when I set up my Emacs configuration from Git.

I couldn't find any documentation for setting up Emacs + Clojure +
Swank without ELPA. What follows are the steps I had to do to get my
setup working so that I can use both SBCL and Clojure with SLIME.

First checkout the needed clojure code into my ~/g/elisp library:

git submodule add git://github.com/technomancy/slime.git slime
git submodule add git://github.com/technomancy/clojure-mode.git clojure-mode
git submodule add git://github.com/jochu/swank-clojure.git swank-clojure
git submodule add git://github.com/richhickey/clojure.git clojure
git submodule add git://github.com/richhickey/clojure-contrib.git clojure

Build clojure:

cd clojure && ant
cd clojure-contrib && mvn package

Add this in my ~/.emacs to load the libraries:

(add-to-list 'load-path "~/g/elisp/clojure-mode")
(add-to-list 'load-path "~/g/elisp/swank-clojure")
(add-to-list 'load-path "~/g/elisp/slime")
(add-to-list 'load-path "~/g/elisp/slime/contrib")

Add autoloads + massive hack to get all of this to work:

(autoload 'clojure-mode "clojure-mode" nil t)
(autoload 'clojure-test-mode "clojure-test-mode" nil t)
(defvar package-activated-list nil "Hack: used in
`slime-changelog-date' but not defined anywhere")
(progn
(autoload 'swank-clojure-init "swank-clojure")
(autoload 'swank-clojure-slime-mode-hook "swank-clojure")
(autoload 'swank-clojure-cmd "swank-clojure")
(autoload 'swank-clojure-project "swank-clojure"))

(setq clojure-src-root (expand-file-name "~/g/elisp"))

;; Java starves programs by default
(setq swank-clojure-extra-vm-args (list "-Xmx1024m"))

This part is very suboptimal, it would be nice if swank-clojure had
better support for running out-of-Git so I wouldn't have to do
this. Maybe it does and I haven't found the relevant bits:

(defun clojure-slime-config (&optional src-root)
"Hacky copy of slime-clojure's `clojure-slime-config' to do what I want."

(if src-root (setq clojure-src-root src-root))

(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)

(slime-setup '(slime-fancy))

(setq swank-clojure-classpath
(list
(concat clojure-src-root "/clojure/clojure.jar")
;; Hack: Expand the name of the .jar with some Emacs glob function
(concat clojure-src-root
"/clojure-contrib/target/clojure-contrib-1.2.0-SNAPSHOT.jar")
(concat clojure-src-root "/swank-clojure/src")
(concat clojure-src-root "/clojure/test/clojure/test_clojure")))
(eval-after-load 'slime
'(progn (require 'swank-clojure)
(setq slime-lisp-implementations
(cons `(clojure ,(swank-clojure-cmd) :init
swank-clojure-init)
(remove-if #'(lambda (x) (eq (car x) 'clojure))
slime-lisp-implementations))))))

;;; Setup clojure
(clojure-slime-config)


Finally set it up to play nice so that I can do M-x run-sbcl or M-x
run-clojure to run Common Lisp or Clojure:

;; http://groups.google.com/group/clojure/browse_thread/thread/e70ac373b47d7088
(eval-after-load 'slime
'(progn
(add-to-list 'slime-lisp-implementations
'(sbcl ("/usr/bin/sbcl")))))

(defun pre-slime ()
"Stuff to do before SLIME runs"
(clojure-slime-config)
(slime-setup))

(defun run-clojure ()
"Starts clojure in Slime"
(interactive)
(pre-slime)
(slime 'clojure))

(defun run-sbcl ()
"Starts SBCL in Slime"
(interactive)
(pre-slime)
(slime 'sbcl))

Of course all of this was such a pain that I pretty much stopped there
and haven't actually /done/ anything with clojure aside from a Hello
World :)


1. http://github.com/avar/dotemacs
2. http://github.com/avar/elisp

Brent Millare

unread,
Apr 7, 2010, 10:57:21 PM4/7/10
to Clojure
http://tentclube.blogspot.com/

I made a blog post on this a while ago, but I've simplified the
process now. I'm still working on making it easier to deploy on
different systems though.

-Brent

>     ;;http://groups.google.com/group/clojure/browse_thread/thread/e70ac373b...

Phil Hagelberg

unread,
Apr 8, 2010, 1:08:43 AM4/8/10
to clo...@googlegroups.com
On Wed, Apr 7, 2010 at 7:57 PM, Brent Millare <brent....@gmail.com> wrote:
> http://tentclube.blogspot.com/
>
> I made a blog post on this a while ago, but I've simplified the
> process now. I'm still working on making it easier to deploy on
> different systems though.

Both those options sound like an awful lot of work. I'm curious as to
what advantages there are to this method over the original
installation instructions.

Do you realize that package.el is going to be included in Emacs 24?

-Phil

Tassilo Horn

unread,
Apr 8, 2010, 5:42:40 AM4/8/10
to clo...@googlegroups.com
On Thursday 08 April 2010 07:08:43 Phil Hagelberg wrote:

Hi Phil,

> Both those options sound like an awful lot of work. I'm curious as to
> what advantages there are to this method over the original
> installation instructions.

To me, all this stuff seems to magical, for example that swank-clojure
downloads the required clojure/contrib jars (at least the comment in the
el-file says so). How do I know what version it will fetch? How does
it know when to update those jars?

I already installed leiningen, so all clojure files are already
contained in leiningen-1.1.0-standalone.jar somewhere in
~/.m2/repository/. Can I use those somehow?

> Do you realize that package.el is going to be included in Emacs 24?

Well, in general I think that's a good thing. But it has to be enhanced
with better version checking. For example, I used to have a SLIME CVS
checkout and used that for my lisp editing needs. But swank-clojure
from ELPA requires some older SLIME version only accible via ELPA again.

This "use one ELPA package and catch (already accessible duplicate)
dependencies" is a bad thing, IMO. But I guess it will become better as
soon as ELPA matures and is accepted as emacs package standard.

BTW: Now I installed slime, slime-repl, clojure-mode and swank-clojure
from ELPA. I symlinked the leiningen-1.1.0-standalone.jar in the maven
repo from ~/.clojure/ so that the jar should be picked up. When I do

M-x slime RET

I only get this error:

,----
| Clojure 1.1.0
| user=> java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)
| user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:0)
| user=> user=> nil
| java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:0)
`----

What's wrong?

Bye,
Tassilo

Pelayo Ramón

unread,
Apr 8, 2010, 6:08:37 AM4/8/10
to clo...@googlegroups.com
>  M-x slime RET
>
> I only get this error:
>
> ,----
> | Clojure 1.1.0
> | user=> java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath:  (NO_SOURCE_FILE:0)
> | user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:0)
> | user=> user=> nil
> | java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:0)
> `----
>
> What's wrong?
>
> Bye,
> Tassilo

That's the same error I've commented in another discussion.
I had to download the swank-clojure.jar and point classpath to its
directory with

(setq swank-clojure-extra-
classpaths
(list
"/home/user/.clojure"))
in the .emacs .

Still have to report the log messages, I'm working in windows atm and
I didn't have time to log into linux. I will this afternoon.

Tassilo Horn

unread,
Apr 8, 2010, 6:18:38 AM4/8/10
to clo...@googlegroups.com
On Thursday 08 April 2010 12:08:37 Pelayo Ramón wrote:

Hi!

> > M-x slime RET
> >
> > I only get this error:
> >
> > ,----
> > | Clojure 1.1.0
> > | user=> java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)
> > | user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:0)
> > | user=> user=> nil
> > | java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:0)
> > `----
> >
> > What's wrong?
>

> That's the same error I've commented in another discussion. I had to
> download the swank-clojure.jar and point classpath to its directory

Hm, but the docs say that swank-clojure.jar would be downloaded as soon
as I do M-x slime.

,----[ ~/.emacs.d/elpa/swank-clojure-1.1.0/swank-clojure.el ]
| ;; 1. Standalone: If you just hit M-x slime, swank-clojure will
| ;; download the jars for Clojure, contrib, and swank-clojure,
| ;; launch an instance, and connect to it. If you just want to try
| ;; out Clojure, this is all you need. Just get Swank Clojure
| ;; through ELPA (http://tromey.com/elpa) and stop reading here.
`----

In *Messages* nothing indicates that it tries to download anything...

Bye,
Tassilo

Alex Osborne

unread,
Apr 8, 2010, 6:28:07 AM4/8/10
to clo...@googlegroups.com
Tassilo Horn <tas...@member.fsf.org> writes:

> To me, all this stuff seems to magical, for example that swank-clojure
> downloads the required clojure/contrib jars (at least the comment in the
> el-file says so). How do I know what version it will fetch? How does
> it know when to update those jars?

It will only download anything if ~/.swank-clojure and ~/.clojure don't
exist. If you create either of those directories manually and populate
it with clojure.jar, clojure-contrib.jar and swank-clojure.jar (and
any other jars you like) then you can use whatever versions you like.

Also note that they're only used when you use M-x slime. If you use M-x
swank-clojure-project instead then it'll add these subdirectories to the
classpath:

src/
classes/
lib/*.jar

So for example if you have a leiningen project and run lein deps so the
lib directory is populated with clojure, contrib, swank-clojure and
anything else your project needs, then when you run M-x
swank-clojure-project and point it at your project's directory, it'll
completely disregard ~/.swank-clojure and use those jars.

Tassilo Horn

unread,
Apr 8, 2010, 6:48:27 AM4/8/10
to clo...@googlegroups.com
On Thursday 08 April 2010 12:28:07 Alex Osborne wrote:

Hi Alex,

> > To me, all this stuff seems to magical, for example that
> > swank-clojure downloads the required clojure/contrib jars (at least
> > the comment in the el-file says so). How do I know what version it
> > will fetch? How does it know when to update those jars?
>
> It will only download anything if ~/.swank-clojure and ~/.clojure
> don't exist.

Ah, then that's my problem. I already have a ~/.clojure/ directory with
a user.clj, the leiningen jar, and some additional jars, but not
swank-clojure.jar. ~/.swank-clojure doesn't exist, though.

> If you create either of those directories manually and populate it
> with clojure.jar, clojure-contrib.jar and swank-clojure.jar (and any
> other jars you like) then you can use whatever versions you like.

To get swank-clojure.jar I need to check out the project from github and
use "lein jar" to generate the jar, right? Or is it possible to
download a ready-made jar?

> Also note that they're only used when you use M-x slime. If you use
> M-x swank-clojure-project instead then it'll add these subdirectories
> to the classpath:
>
> src/
> classes/
> lib/*.jar
>
> So for example if you have a leiningen project and run lein deps so
> the lib directory is populated with clojure, contrib, swank-clojure
> and anything else your project needs, then when you run M-x
> swank-clojure-project and point it at your project's directory, it'll
> completely disregard ~/.swank-clojure and use those jars.

Isn't it a bad idea to include all deps into a project, so that one ends
up with so much duplication?

Bye,
Tassilo

Pelayo Ramón

unread,
Apr 8, 2010, 7:04:15 AM4/8/10
to clo...@googlegroups.com
>> It will only download anything if ~/.swank-clojure and ~/.clojure
>> don't exist.
>
> Ah, then that's my problem.  I already have a ~/.clojure/ directory with
> a user.clj, the leiningen jar, and some additional jars, but not
> swank-clojure.jar.  ~/.swank-clojure doesn't exist, though.
>

That was my problem also. I think I will delete the de directory so
swank-clojure downloads all the correct files.

Alex Osborne

unread,
Apr 8, 2010, 7:33:43 AM4/8/10
to clo...@googlegroups.com
Tassilo Horn <tas...@member.fsf.org> writes:

> To get swank-clojure.jar I need to check out the project from github and
> use "lein jar" to generate the jar, right? Or is it possible to
> download a ready-made jar?

You can just download it by hand from Clojars if you like:

http://clojars.org/repo/swank-clojure/swank-clojure/

I've never had a problem with the stable 1.1.0 version fine, or you can
try the 'break' snapshot which has better debugging support.

>> So for example if you have a leiningen project and run lein deps so
>> the lib directory is populated with clojure, contrib, swank-clojure
>> and anything else your project needs, then when you run M-x
>> swank-clojure-project and point it at your project's directory, it'll
>> completely disregard ~/.swank-clojure and use those jars.
>
> Isn't it a bad idea to include all deps into a project, so that one ends
> up with so much duplication?

What is a "bad idea" is subjective and depends on your use case and your
workflow. You may need to use a particular version of Clojure for a
particular project, for example because AOT-compiled 1.1.0 and git
master are incompatible. Similarly I find having a project checkout
fully self-contained so that it can just be copied to a server and run
without any prior setup except having a JVM installed extremely handy.
But it seems a lot of people don't agree and would prefer to save a small
amount of disk space by sharing jars between projects.

It's up to you really, you can use symlinks if you prefer (and there's
apparently a patch you can apply to Lein that makes it use symlinks).
There's also a branch of Lein which allows you to use checked out
projects as dependencies which lets you hack on multiple inter-dependent
projects at once nicely:

http://groups.google.com/group/leiningen/browse_thread/thread/f67cb42c06515e53

Tassilo Horn

unread,
Apr 8, 2010, 7:51:45 AM4/8/10
to clo...@googlegroups.com
On Thursday 08 April 2010 13:33:43 Alex Osborne wrote:

Hi Alex,

> > To get swank-clojure.jar I need to check out the project from github


> > and use "lein jar" to generate the jar, right? Or is it possible to
> > download a ready-made jar?
>
> You can just download it by hand from Clojars if you like:
>
> http://clojars.org/repo/swank-clojure/swank-clojure/

That did the trick, and thanks a lot for the further explanations.

Bye,
Tassilo

Ævar Arnfjörð Bjarmason

unread,
Apr 8, 2010, 12:45:00 PM4/8/10
to clo...@googlegroups.com
On Thu, Apr 8, 2010 at 11:33, Alex Osborne <a...@meshy.org> wrote:
> Tassilo Horn <tas...@member.fsf.org> writes:
>> Isn't it a bad idea to include all deps into a project, so that one ends
>> up with so much duplication?
>
> What is a "bad idea" is subjective and depends on your use case and your
> workflow.  You may need to use a particular version of Clojure for a
> particular project, for example because AOT-compiled 1.1.0 and git
> master are incompatible.  Similarly I find having a project checkout
> fully self-contained so that it can just be copied to a server and run
> without any prior setup except having a JVM installed extremely handy.
> But it seems a lot of people don't agree and would prefer to save a small
> amount of disk space by sharing jars between projects.

It's not about saving disk space. Copying files around like this
creates another sort of maintenance burden, familiar to anyone who's
used frameworks that auto-generate any sort of files (code, .jar's,
...).

If I have 10 Clojure projects I'm going to have 10 src/clojure.jar
files. Do they really need to be there or could I just use the clojure
that comes with my operating system (Debian)?

When I hack Common Lisp I don't copy sbcl into all my projects, I just
install it once globally. I'd like to do the same with clojure.

> It's up to you really, you can use symlinks if you prefer (and there's
> apparently a patch you can apply to Lein that makes it use symlinks).
> There's also a branch of Lein which allows you to use checked out
> projects as dependencies which lets you hack on multiple inter-dependent
> projects at once nicely:

I'd rather just avoid the whole concept of having some files being
autogenerated in my ~/ and have swank-clojure use one copy of
clojure*.jar globally by default, which is what I've done.

Ævar Arnfjörð Bjarmason

unread,
Apr 8, 2010, 12:36:00 PM4/8/10
to clo...@googlegroups.com
On Thu, Apr 8, 2010 at 05:08, Phil Hagelberg <ph...@hagelb.org> wrote:
> On Wed, Apr 7, 2010 at 7:57 PM, Brent Millare <brent....@gmail.com> wrote:
>> http://tentclube.blogspot.com/
>>
>> I made a blog post on this a while ago, but I've simplified the
>> process now. I'm still working on making it easier to deploy on
>> different systems though.
>
> Both those options sound like an awful lot of work. I'm curious as to
> what advantages there are to this method over the original
> installation instructions.

They're only a lot of work because the existing .el code all assumes
that you're working with ELPA and that you want magic like
auto-downloading of .jar's and having them dropped into all your
project directories.

Usually installing Emacs Lisp packages like this is easy and requires
1-2 lines of Elisp in your ~/.emacs, swank-clojure is the exception.

Phil Hagelberg

unread,
Apr 10, 2010, 12:21:40 AM4/10/10
to clo...@googlegroups.com
On Thu, Apr 8, 2010 at 2:42 AM, Tassilo Horn <tas...@member.fsf.org> wrote:
> I already installed leiningen, so all clojure files are already
> contained in leiningen-1.1.0-standalone.jar somewhere in
> ~/.m2/repository/.  Can I use those somehow?

Sure, you can set lein-swank as a dev-dependency of your project, then
run "lein swank" to start the server. M-x slime-connect will open a
connection from within Emacs. This is probably the best way to do it.
Standalone M-x slime has never been intended for anything more than
experimentation and letting newbies get going faster, since it doesn't
have a very useful classpath.

M-x swank-clojure-project is also an option, but from a packaging and
maintenance perspective it's a lot easier to distribute updates for
clojure code than for elisp, so solutions that rely on as little
changing elisp as possible are preferable.

> BTW: Now I installed slime, slime-repl, clojure-mode and swank-clojure
> from ELPA.  I symlinked the leiningen-1.1.0-standalone.jar in the maven
> repo from ~/.clojure/ so that the jar should be picked up.  When I do
>
>  M-x slime RET
>
> I only get this error:
>
> ,----
> | Clojure 1.1.0
> | user=> java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath:  (NO_SOURCE_FILE:0)
> | user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:0)
> | user=> user=> nil
> | java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:0)
> `----

Currently swank-clojure.el looks for the presence of a ~/.clojure
directory, and if it finds it, it will attempt to use it. Otherwise it
will attempt to auto-configure itself with the ~/.swank-clojure
directory.

This is probably no longer the right thing to do. Probably a better
idea would be to only use ~/.clojure if it detects clojure and
swank-clojure jars in there, or possibly to ignore it altogether. Any
opinions on this subject? At the very least it should be
better-documented.

-Phil

DanL

unread,
Apr 10, 2010, 12:10:02 PM4/10/10
to Clojure
Hello!

On 8 Apr., 18:36, Ævar Arnfjörð Bjarmason <ava...@gmail.com> wrote:

> > Both those options sound like an awful lot of work. I'm curious as to
> > what advantages there are to this method over the original
> > installation instructions.
>
> They're only a lot of work because the existing .el code all assumes

> that you're working withELPAand that you want magic like


> auto-downloading of .jar's and having them dropped into all your
> project directories.
>
> Usually installing Emacs Lisp packages like this is easy and requires
> 1-2 lines of Elisp in your ~/.emacs,swank-clojureis the exception.

That's how I see it, too.

I really do appreciate the work being done, and trying to make things
simpler for newcomers is commendable, but if the price is making it
hard/awkward for people used to emacs and its usual ways, I can't
approve that.

Like Ævar, I am not aware of any other language mode that makes the
usual way of installing/configuring as hard as swank-clojure. That is
why I use a pretty ancient version of it, which in turn prevents me
from using the latest cvs slime (I don't know if swank-clojure works
with slime head atm), another PITA for people using Slime for both CL
and Clojure, but another topic.

Ideally, it should be made easy for both groups.

Regards

dhl

Phil Hagelberg

unread,
Apr 10, 2010, 12:57:52 PM4/10/10
to clo...@googlegroups.com
On Sat, Apr 10, 2010 at 9:10 AM, DanL <leid...@gmail.com> wrote:
>> Usually installing Emacs Lisp packages like this is easy and requires
>> 1-2 lines of Elisp in your ~/.emacs,swank-clojureis the exception.
>
> Like Ævar, I am not aware of any other language mode that makes the
> usual way of installing/configuring as hard as swank-clojure. That is
> why I use a pretty ancient version of it, which in turn prevents me
> from using the latest cvs slime (I don't know if swank-clojure works
> with slime head atm), another PITA for people using Slime for both CL
> and Clojure, but another topic.

I don't think that's a fair comparison. Do you know of any other elisp
modes that must maintain compatibility across three wildly different
Lisp dialects while being distributed across two separate package
managers?

> Ideally, it should be made easy for both groups.

A capital idea. Are you volunteering? =)

-Phil

DanL

unread,
Apr 10, 2010, 1:31:37 PM4/10/10
to Clojure
Hello!

On 10 Apr., 18:57, Phil Hagelberg <p...@hagelb.org> wrote:

> > Like Ævar, I am not aware of any other language mode that makes the

> > usual way of installing/configuring as hard asswank-clojure. That is


> > why I use a pretty ancient version of it, which in turn prevents me
> > from using the latest cvs slime (I don't know ifswank-clojureworks
> > with slime head atm), another PITA for people using Slime for both CL

> > andClojure, but another topic.


>
> I don't think that's a fair comparison. Do you know of any other elisp
> modes that must maintain compatibility across three wildly different
> Lisp dialects while being distributed across two separate package
> managers?

I didn't mean to be unfair, I know you a little from IRC, you were
always polite and helpful, and as I said, I really appreciate the work
being done. The problems (for me) started before you were swank-
clojure's maintainer.

There was a time when installing swank-clojure in the "usual" emacs
way was basically a no-brainer for someone accustomed to emacs.
Granted, it is definitely not a trivial language-mode, but I just feel
that every improvement that has been done to make swank-clojure more
newbie-friendly made it more hard to use in the "traditional" way.

I am not sure wether that it is distributed across two separate
package managers or compatibility across Lisp dialects is the reason
for the status quo. I rather have the impression that much more time
and work was invested in making it easy to use in an automagical than
in keeping it useable the "traditional" way. Don't get me wrong: I
don't want to blame you or anyone else, and after all it's just an
impression.

> > Ideally, it should be made easy for both groups.
>
> A capital idea. Are you volunteering? =)

While I am capable of keeping an old version working for me, I am not
sure if I could be of much help for you. What I do is just having one
clojure.jar, running it from the command line, and connecting to swank
via slime-connect. No downloading of anything, no automatic
configuration of anything, no automatic testing. That's pretty much
all I need and want. Since the current version of swank-clojure seems
to have moved on from what I use and (half-way) understand, I think
I'd be of little help. Frankly, I care as much about Elpa as I care
about customize ... I'm happy when I don't have to deal with it.

That being said, I'll take a look at the recend codebase and see if I
can wrap my head around it. If I can contribute anything of help, I'll
let you know.


Cheers

dhl

Ævar Arnfjörð Bjarmason

unread,
Apr 10, 2010, 1:44:20 PM4/10/10
to clo...@googlegroups.com

What would be involved in that? The hack I have is just a monkeypatch
on top of swank-clojure that Works For Me. It may not be the best idea
to do it.

Maybe swank-clojure could provide some settable variables / core code
to make the stuff I and DanL want to do with it easy.

I'm not familiar with the history but is there any reason why
swank-clojure isn't being integrated into the SLIME distribution
itself? That should make it easier to make it work out of the box.

DanL

unread,
Apr 10, 2010, 5:49:08 PM4/10/10
to Clojure
On 10 Apr., 19:44, Ævar Arnfjörð Bjarmason <ava...@gmail.com> wrote:
> I'm not familiar with the history but is there any reason why
> swank-clojure isn't being integrated into the SLIME distribution
> itself? That should make it easier to make it work out of the box.

As far as I know, there were problems with the protocol using symbols
in CL's package::symbol syntax (and some other characters not being
allowed in Clojure) after changes in CVS Slime about five months ago.
Even if swank-clojure was integrated, it wouldn't be an "official"
part of Slime, but a contrib. I suppose CVS Slime's restless nature
and (as far as I know) non-existent documentation of the protocol also
have their parts to play.

Regards

dhl

Ævar Arnfjörð Bjarmason

unread,
Apr 10, 2010, 6:34:39 PM4/10/10
to clo...@googlegroups.com
On Sat, Apr 10, 2010 at 21:49, DanL <leid...@gmail.com> wrote:
> On 10 Apr., 19:44, Ævar Arnfjörð Bjarmason <ava...@gmail.com> wrote:
>> I'm not familiar with the history but is there any reason why
>> swank-clojure isn't being integrated into the SLIME distribution
>> itself? That should make it easier to make it work out of the box.
>
> As far as I know, there were problems with the protocol using symbols
> in CL's package::symbol syntax (and some other characters not being
> allowed in Clojure) after changes in CVS Slime about five months ago.

So it would just need to use a sexp parser instead of directly
interning the foreign symbols? Not that I'm volunteering or anything
:)

> Even if swank-clojure was integrated, it wouldn't be an "official"
> part of Slime, but a contrib. I suppose CVS Slime's restless nature
> and (as far as I know) non-existent documentation of the protocol also
> have their parts to play.

Because of some policy that slime is Common Lisp-only? I see all the
*.scm files are in contrib/ and not in the main slime directory.

DanL

unread,
Apr 10, 2010, 6:59:47 PM4/10/10
to Clojure
On 11 Apr., 00:34, Ævar Arnfjörð Bjarmason <ava...@gmail.com> wrote:

> > As far as I know, there were problems with the protocol using symbols
> > in CL's package::symbol syntax (and some other characters not being
> > allowed in Clojure) after changes in CVS Slime about five months ago.
>
> So it would just need to use a sexp parser instead of directly
> interning the foreign symbols? Not that I'm volunteering or anything

A small custom reader would be part of the solution, I guess.

> > Even if swank-clojure was integrated, it wouldn't be an
"official"
> > part of Slime, but a contrib. I suppose CVS Slime's restless nature
> > and (as far as I know) non-existent documentation of the protocol also
> > have their parts to play.
>
> Because of some policy that slime is Common Lisp-only? I see all the
> *.scm files are in contrib/ and not in the main slime directory.

I don't really know much more about this. Maybe try searching the
slime-devel mailing list archives for Clojure ... There was some
discussion about this topic a while ago, but I don't remember the
details.

Regards

dhl

Brian Troutwine

unread,
Apr 10, 2010, 12:31:07 AM4/10/10
to clo...@googlegroups.com
Speaking as a newbie, playing nice with ~/.clojure would be great,
giving a more helpful error message would be better. I suffered the
same FileNotFoundException given above, nuked ~/.clojure and got going
quickly enough. I didn't know _what_ was wrong, however, as I had only
stumbled across the solution by chance.

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
> To unsubscribe, reply using "remove me" as the subject.
>

Constantine Vetoshev

unread,
Apr 11, 2010, 6:03:21 PM4/11/10
to Clojure
On Apr 8, 12:45 pm, Ævar Arnfjörð Bjarmason <ava...@gmail.com> wrote:
> If I have 10 Clojure projects I'm going to have 10 src/clojure.jar
> files. Do they really need to be there or could I just use the clojure
> that comes with my operating system (Debian)?
>
> When I hack Common Lisp I don't copy sbcl into all my projects, I just
> install it once globally. I'd like to do the same with clojure.

Although I'm with you about ELPA and preferring the traditional way to
install Emacs packages, I disagree on this point. I find it
counterproductive to think of Clojure and its distribution in the same
terms as Common Lisp's. It's easier to think of Clojure apps more like
Java apps which happen to use a much better language.

I actually prefer to have a lib/clojure-X.Y.Z.jar in my project. This
guarantees that, as long as the deployment machine has a Clojure-
supporting JVM, the app has no other system-level dependencies. It
also allows flexibility with trying out unreleased and unpackaged
versions of Clojure. This eliminates the hideous mess in most
distributions of having packages like python24, python25, python26,
python30 (and resulting things like python24-somelib and python26-
somelib).

Constantine Vetoshev

unread,
Apr 11, 2010, 6:30:00 PM4/11/10
to Clojure
This thread encouraged me to post what I did to make swank-clojure
1.1.0 work with the the latest SLIME. It does not use any of swank-
clojure's automatic .jar downloading features (as of version 1.1.0).
These instructions won't work on Windows, but may work if you have
Cygwin.

Note that this sets up some Common Lisp installations. Delete those
lines if you don't want them.

If you already figured out how to put SLIME and swank-clojure on your
classpath, omit that part of the setup. See the comments.

Assumptions:
- SLIME in ~/.emacs.d/site-lisp/slime
- swank-clojure in ~/.emacs.d/site-lisp/swank-clojure
- your project is laid out with a src/ directory containing your
actual code; it goes on the classpath
- you want all .jar files in your project on your classpath
- several directories, including classes/ and resources/, also get
added to your classpath
- you have exactly one file called clojure-<version-number>.jar in
the resulting classpath; this becomes the version of Clojure launched
by SLIME

Instructions:
- put the code below into your .emacs.d/init.el or .emacs file
- use M-x clojure-project to launch SLIME; this is my variant of
swank-clojure-project, but it makes no assumptions about Maven,
magical downloads, ELPA, or anything else

Limitation:
- slime-connect doesn't seem to work right; you have to launch
Clojure and your app using clojure-project

One more thing: swank-clojure 1.1.0 requires a tiny patch to work with
the latest SLIME. This patch seems to already be in swank-clojure's
master branch, but be aware of it: http://groups.google.com/group/swank-clojure/msg/01ff818359061a28

Could this be a good start to making swank-clojure both newbie-and-
ELPA-friendly and Emacs-graybeard-friendly?

;;; generic Emacs utility
;;; ------------------------------------------------------------------

(defun add-subdirs-to-load-path (dir)
(let ((default-directory (concat dir "/")))
(normal-top-level-add-subdirs-to-load-path)))


;;; basic load-path setup
;;; ------------------------------------------------------------------

(add-to-list 'load-path "~/.emacs.d/site-lisp")
(add-subdirs-to-load-path "~/.emacs.d/site-lisp")


;;; SLIME and swank-clojure
;;; ------------------------------------------------------------------

(require 'slime-autoloads)
(add-to-list 'load-path "~/.emacs.d/site-lisp/slime/contrib")
;(slime-setup '(slime-fancy slime-asdf))
(slime-setup '(slime-repl))

(setq slime-net-coding-system 'utf-8-unix)

(setq slime-lisp-implementations
'((acl ("/opt/acl/alisp"))
(sbcl ("/opt/sbcl/run-sbcl.sh"))
(ccl ("/opt/ccl/dx86cl64"))))

(defmacro defslime-start (name mapping)
`(defun ,name ()
(interactive)
(let ((slime-default-lisp ,mapping))
(slime))))

(defslime-start acl 'acl)
(defslime-start sbcl 'sbcl)
(defslime-start ccl 'ccl)
(defslime-start clojure 'clojure)

(setq swank-clojure-classpath '("~/.emacs.d/site-lisp/swank-clojure/
src"))
(setq swank-clojure-extra-vm-args
(list "-server" "-Xms128M" "-Xmx512M" "-Dfile.encoding=UTF-8"))

(autoload 'clojure-mode "clojure-mode" "A major mode for Clojure" t)
(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
(require 'swank-clojure)

(add-hook 'slime-mode-hook
(lambda ()
(setq slime-truncate-lines nil)
(slime-redirect-inferior-output)))

(defun clojure-slime-reset ()
"Helper function which resets Clojure in SLIME's list of
implementations. Useful for changing Clojure's classpath."


(setq slime-lisp-implementations
(cons `(clojure ,(swank-clojure-cmd) :init swank-clojure-init)
(remove-if #'(lambda (x) (eq (car x) 'clojure))
slime-lisp-implementations))))

(defun clojure-project-prompt (path)
(interactive "GProject path: ")
(list path))

(defun clojure-project (path)
"Set up Clojure classpath and other swank-clojure variables for
the project with root at 'path'. Include all *.jar files under
path. Also include 'classes' subdirectory."
(interactive
(let* ((dominating-file (locate-dominating-file buffer-file-name
"src/"))
(default-directory (if (and buffer-file-name dominating-
file)
dominating-file
default-directory)))
(call-interactively 'clojure-project-prompt)))
(when (and (fboundp 'slime-connected-p) (slime-connected-p))
(slime-quit-lisp)
(sleep-for 1)
(slime-kill-all-buffers))
(flet ((clojure-jar-p (s) (string-match
"clojure\\(-[0-9a-f\\.]*\\)?\\.jar$"
s))
(validate-path (p) (when (file-accessible-directory-p p)
(list p))))
(let* ((src-path
(append
(validate-path (expand-file-name "src" path))
(validate-path (expand-file-name "source" path))
(validate-path (expand-file-name "code" path))))
(test-path
(append
(validate-path (expand-file-name "test" path))
(validate-path (expand-file-name "tests" path))))
(examples-path
(append
(validate-path (expand-file-name "demo" path))
(validate-path (expand-file-name "sample" path))
(validate-path (expand-file-name "example" path))
(validate-path (expand-file-name "examples" path))))
(libs-path
(split-string
(shell-command-to-string
(format "find %s -type f -name '*.jar' -print0" path))
"[\000]+"))
(classes-path
(append
(validate-path (expand-file-name "classes" path))))
(resources-path
(append
(validate-path (expand-file-name "resource" path))
(validate-path (expand-file-name "resources" path))))
(swank-clojure-classpath
(append swank-clojure-classpath src-path libs-path
classes-path resources-path))
;; swank-clojure configuration dynamic variable rebinding
(swank-clojure-binary nil)
(swank-clojure-jar-path ; override if provided in project
(let ((project-clojure-jar
(first (member-if #'clojure-jar-p
swank-clojure-classpath))))
(if project-clojure-jar
project-clojure-jar
swank-clojure-jar-path))))
(clojure-slime-reset)
(save-window-excursion
(clojure)))))

Robert Ewald

unread,
May 2, 2010, 6:13:40 PM5/2/10
to clo...@googlegroups.com
Am Sonntag, 11. April 2010 00:59:47 schrieb DanL:
> On 11 Apr., 00:34, Ævar Arnfjörð Bjarmason <ava...@gmail.com> wrote:
> > > As far as I know, there were problems with the protocol using symbols
> > > in CL's package::symbol syntax (and some other characters not being
> > > allowed in Clojure) after changes in CVS Slime about five months ago.
> >
> > So it would just need to use a sexp parser instead of directly
> > interning the foreign symbols? Not that I'm volunteering or anything
>
> A small custom reader would be part of the solution, I guess.

IIRC there has been some work on slime making a thin RPC layer. I haven't
looked recently how far that one has come. Unfortunatly I am not in the
position to contribute patches, but I think that swank-clojure should consider
adopting this protocol, although I don't think there are any promisies
regarding stability.

Robert

Ramakrishnan Muthukrishnan

unread,
May 2, 2010, 11:39:16 PM5/2/10
to clo...@googlegroups.com
On Mon, May 3, 2010 at 3:43 AM, Robert Ewald <robe...@gmx.net> wrote:
> Am Sonntag, 11. April 2010 00:59:47 schrieb DanL:
>> On 11 Apr., 00:34, Ævar Arnfjörð Bjarmason <ava...@gmail.com> wrote:
>> > > As far as I know, there were problems with the protocol using symbols
>> > > in CL's package::symbol syntax (and some other characters not being
>> > > allowed in Clojure) after changes in CVS Slime about five months ago.
>> >
>> > So it would just need to use a sexp parser instead of directly
>> > interning the foreign symbols? Not that I'm volunteering or anything
>>
>> A small custom reader would be part of the solution, I guess.
>
> IIRC there has been some work on slime making a thin RPC layer. I haven't
> looked recently how far that one has come. Unfortunatly I am not in the
> position to contribute patches, but I think that swank-clojure should consider
> adopting this protocol, although I don't think there are any promisies
> regarding stability.

Terje Norderhaug implemented it and is already in use in the latest
swank-clojure.

--
Ramakrishnan
Reply all
Reply to author
Forward
0 new messages