SLIME REPL broken

53 views
Skip to first unread message

Stefan Kamphausen

unread,
Nov 15, 2009, 9:21:03 AM11/15/09
to Clojure
Hi,

a short discussion on the SLIME mailinglist lead to the result that
the arglist of a backend function in swank did change.

Current checkouts of SLIME do not work with Clojure, at least if you
use autodoc.

http://common-lisp.net/pipermail/slime-devel/2009-November/016919.html

I took a quick look at the relevant function (src/main/clojure/swank/
commands/contrib/swank_arglists.clj) in swank-clojure but it would
need some diving into the code for me to help with this. Maybe
someone more experienced than me can step in?

Kind regards,
Stefan Kamphausen

Cyrus Harmon

unread,
Nov 15, 2009, 10:59:56 AM11/15/09
to clo...@googlegroups.com
Heh: " ;; Yeah, I'm lazy -- I'll flesh this out later"

Not sure if that's related to the problem, but it's amusing at least.

Cyrus
> --
> 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

Phil Hagelberg

unread,
Nov 16, 2009, 2:12:11 PM11/16/09
to clo...@googlegroups.com
Right now the best thing to do is to use slime, swank-clojure, and
clojure-mode from ELPA, as the versions there are known to work well
together.

http://tromey.com/elpa/install.html

Unless there are some really great features added upstream in slime,
fixing swank-clojure to work with their latest changes is a low priority.

-Phil

Stefan Kamphausen

unread,
Nov 16, 2009, 5:15:40 PM11/16/09
to Clojure
Hi,

Phil Hagelberg wrote:
> Unless there are some really great features added upstream in slime,
> fixing swank-clojure to work with their latest changes is a low priority.

this is a pity, at least for those of us, who also use Slime to do
some CL hacking. For that setup it is quite common to always update
to CVS head because that may be the only version working with current
releases of, e.g., SBCL. Well, currently I don't really do CL stuff,
it's just that I set up another machine doing lots of VC-checkouts...
I could just copy an older version of Slime there.

I'll take a look at it the next few days (er, evenings that is), if I
find the time. No promises ;-)

Over there at Slime's people are thinking, the Clojure family forked
Slime, maybe that's not the worst idea. Things would probably get
easier if there were only one backend to support.

Best regards,
Stefan

Cyrus Harmon

unread,
Nov 16, 2009, 11:29:08 PM11/16/09
to clo...@googlegroups.com

Stefan put in words what I was thinking earlier today. For those of us that use both CL and clojure, keeping swank-clojure up to date wrt the slime HEAD is a good thing, if you ask me. It is, however, a two-way street and I would imagine that the swank-clojure implementors don't want to spend too much time chasing SLIME's tail, as it were. Keeping the clojure backend on the radar of the core SLIME development team is probably a good thing. I think it would be unfortunate if swank-clojure were to require a different SLIME emacs piece than the CL swank (and scheme48, etc...) backends.

cyrus

Stefan Kamphausen

unread,
Nov 17, 2009, 7:47:23 AM11/17/09
to Clojure
Hi,

Stefan Kamphausen wrote:
> I'll take a look at it the next few days (er, evenings that is), if I
> find the time. No promises ;-)

Not that I'm close to a solution, but at least I have stacktrace...
After some digging in the clojure-swank code I came across this piece
in swank.clj:

(defn- connection-serve [conn]
(let [control
(dothread-swank
(thread-set-name "Swank Control Thread")
(try
(control-loop conn)
(catch Exception e
;; fail silently
nil)))
....

and I didn't like that comment. So I changed that to

(defn- connection-serve [conn]
(let [control
(dothread-swank
(thread-set-name "Swank Control Thread")
(try
(control-loop conn)
(catch Exception e
;; fail silently
(.printStackTrace e)
(.printStackTrace (.getCause e))
nil)))


Then after typing just "(+" into the SLIME-REPL-Buffer (obviously
without the quotes) I see a stacktrace in the *inferior-lisp*-Buffer:

user=> user=> Connection opened on local port 37693
#<ServerSocket ServerSocket
[addr=0.0.0.0/0.0.0.0,port=0,localport=37693]>
user=> user=> java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer
$ConditionObject.reportInterruptAfterWait
(AbstractQueuedSynchronizer.java:1899)
at java.util.concurrent.locks.AbstractQueuedSynchronizer
$ConditionObject.await(AbstractQueuedSynchronizer.java:1934)
at java.util.concurrent.LinkedBlockingQueue.take
(LinkedBlockingQueue.java:358)
at swank.util.concurrent.mbox$receive__214.invoke(mbox.clj:28)
at swank.core$control_loop__249.invoke(core.clj:258)
at swank.swank$connection_serve__365$fn__397$fn__399.invoke(swank.clj:
29)
at clojure.lang.AFn.applyToHelper(AFn.java:171)
at clojure.lang.AFn.applyTo(AFn.java:164)
at clojure.core$apply__4305.invoke(core.clj:420)
at swank.swank$connection_serve__365$fn__397.doInvoke(swank.clj:26)
at clojure.lang.RestFn.invoke(RestFn.java:402)
at clojure.lang.AFn.run(AFn.java:37)
at java.lang.Thread.run(Thread.java:619)
Exception in thread "Swank Control Thread" java.lang.RuntimeException:
java.lang.NullPointerException
at clojure.lang.AFn.run(AFn.java:41)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at swank.swank$connection_serve__365$fn__397$fn__399.invoke(swank.clj:
33)
at clojure.lang.AFn.applyToHelper(AFn.java:171)
at clojure.lang.AFn.applyTo(AFn.java:164)
at clojure.core$apply__4305.invoke(core.clj:420)
at swank.swank$connection_serve__365$fn__397.doInvoke(swank.clj:26)
at clojure.lang.RestFn.invoke(RestFn.java:402)
at clojure.lang.AFn.run(AFn.java:37)
... 1 more

(I hope, google-group-posting will not mess with the pasted code, I
can see no preview-button on the posting-page)

And sending a SIGQUIT to the java-process shows that at least the
"Swank Control Thread" died (I think some other swank-threads, too).

What's most annoying is that I have not yet found a way to debug this
without restarting the JVM every few minutes. Still working on
this...

If anyone can give me a pointer where to look next, the help will be
highly appreciated.

Kind regards,
Stefan

Stefan Kamphausen

unread,
Nov 17, 2009, 2:44:01 PM11/17/09
to Clojure
Hi,

On Nov 17, 1:47 pm, Stefan Kamphausen <ska2...@googlemail.com> wrote:

[...]
> user=> user=> Connection opened on local port  37693
> #<ServerSocket ServerSocket
> [addr=0.0.0.0/0.0.0.0,port=0,localport=37693]>
> user=> user=> java.lang.InterruptedException
> [...]
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.NullPointerException
> [...]

> And sending a SIGQUIT to the java-process shows that at least the
> "Swank Control Thread" died (I think some other swank-threads, too).

By now, I think the NPE is the thread that was killed. Actually I
have made some progress in gettings things into a working state again,
but that would need some changes on the Slime-side. So I asked over
there:

http://article.gmane.org/gmane.lisp.slime.devel/9197

Kind regards,
Stefan

David Nolen

unread,
Nov 17, 2009, 2:52:49 PM11/17/09
to clo...@googlegroups.com
Stefan,

Thanks for pursuing this so adamantly :) For a long time (more than a year) it was possible to use SLIME tip. It would be great for that to continue.

David


Kind regards,
Stefan

Constantine Vetoshev

unread,
Nov 17, 2009, 9:26:44 PM11/17/09
to Clojure
On Nov 17, 2:52 pm, David Nolen <dnolen.li...@gmail.com> wrote:
> Thanks for pursuing this so adamantly :) For a long time (more than a year)
> it was possible to use SLIME tip. It would be great for that to continue.

You can still use SLIME; just avoid the slime-autodoc contrib. Use

(slime-setup '(slime-repl))

to initialize SLIME. At least, this works for me. Make sure you don't
use (slime-setup '(slime-fancy)), because slime-fancy includes slime-
autodoc. You lose the nicer minibuffer function argument display, but
at least the basic environment works.

Phil Hagelberg

unread,
Nov 18, 2009, 12:40:31 AM11/18/09
to clo...@googlegroups.com
Stefan Kamphausen <ska...@googlemail.com> writes:

>> Unless there are some really great features added upstream in slime,
>> fixing swank-clojure to work with their latest changes is a low priority.
>
> this is a pity, at least for those of us, who also use Slime to do
> some CL hacking. For that setup it is quite common to always update
> to CVS head because that may be the only version working with current
> releases of, e.g., SBCL. Well, currently I don't really do CL stuff,
> it's just that I set up another machine doing lots of VC-checkouts...
> I could just copy an older version of Slime there.
>
> I'll take a look at it the next few days (er, evenings that is), if I
> find the time. No promises ;-)

Cool. I don't mean to discourage this work, I just mean that I have
little personal motivation to implement it myself.

> Over there at Slime's people are thinking, the Clojure family forked
> Slime, maybe that's not the worst idea. Things would probably get
> easier if there were only one backend to support.

Honestly I don't know the server-side bit of swank-clojure that well;
I've mostly been focusing on the elisp side. So I don't know the
protocol that well myself; the server-side stuff was mostly written by
jochu, the original author.

-Phil

Kei Suzuki

unread,
Nov 19, 2009, 12:29:04 AM11/19/09
to Clojure
You can still use slime-fancy and the arglist display feature by just
disabling autodoc mode like this:

(setq slime-use-autodoc-mode nil)
(slime-setup '(slime-fancy))

Robert Ewald

unread,
Nov 21, 2009, 6:09:54 PM11/21/09
to clo...@googlegroups.com

Hello,

At Sun, 15 Nov 2009 06:21:03 -0800 (PST),
Not that I am experienced, but the problem is that the reader of
clojure doesn't allow double colons (::) and the percent-sign (%) has
a special meaning. For Common Lisp the double colon means a "private"
symbol of a package. I don't remember what the percent-sign means by
convention. So I have created a patch that replaces these illegal
character sequences. But that is of course not the right way to
go. The intention of the symbols needs to be preserved and I am not
quite sure how to do that. That would require some work with the slime
guys. I don't have time for that today so maybe somebody wants to pick
up from here.

Best regards

Robert

PS: Apologies if the patch is not in the format that you expect.

This patch is in the public domain.
diff --git a/src/main/clojure/swank/core/protocol.clj b/src/main/clojure/swank/core/protocol.clj
index 89f0890..8d4a44a 100644
--- a/src/main/clojure/swank/core/protocol.clj
+++ b/src/main/clojure/swank/core/protocol.clj
@@ -4,6 +4,20 @@

;; Read forms
(def #^{:private true}
+ *percent-re* #"%")
+
+(defn- fix-percent
+ "Replace double colons with a /."
+ ([text] (.replaceAll (re-matcher *percent-re* text) "?")))
+
+(def #^{:private true}
+ *double-colon-re* #"::")
+
+(defn- fix-double-colon
+ "Replace double colons with a /."
+ ([text] (.replaceAll (re-matcher *double-colon-re* text) "/")))
+
+(def #^{:private true}
*namespace-re* #"(^\(:emacs-rex \([a-zA-Z][a-zA-Z0-9]+):")

(defn- fix-namespace
@@ -50,7 +64,7 @@
([#^java.io.Reader reader]
(let [len (Integer/parseInt (read-chars reader 6 read-fail-exception) 16)
msg (read-chars reader len read-fail-exception)
- form (read-string (fix-namespace msg))]
+ form (read-string (fix-namespace (fix-double-colon (fix-percent msg))))]
(if (seq? form)
(deep-replace {'t true} form)
form))))

Reply all
Reply to author
Forward
0 new messages