Patch: precompiling Clojure core sources in Ant build script

5 views
Skip to first unread message

Stuart Sierra

unread,
Nov 14, 2008, 12:51:55 PM11/14/08
to clo...@googlegroups.com
Patch attached. This precompiles everything except parallel.clj,
which requires an extra Jar. It also omits the source .clj files from
the clojure.jar file.
-Stuart Sierra
precompile.patch

Rich Hickey

unread,
Nov 14, 2008, 2:37:10 PM11/14/08
to Clojure


On Nov 14, 12:51 pm, "Stuart Sierra" <the.stuart.sie...@gmail.com>
wrote:
Patch applied (svn 1101) - thanks!

Rich

Graham Fawcett

unread,
Nov 14, 2008, 3:38:18 PM11/14/08
to clo...@googlegroups.com

Hi folks,

Just FYI, this breaks, at least for me, 'slime-edit-definition' in
swank-clojure (also known as "M-."), which pops open the source
definition of the word under point.

I'm sure there's a work-around, of course. The meta information is still there:

user> (meta #'last)
{:arglists ([coll]), :doc "Return the last item in coll, in linear
time", :name last, :file "core.clj", :line 161, :ns #<Namespace
clojure.core>}

so it must just be a configuration issue. I will read over the
swank-clojure code.

Best,
Graham

Stephen C. Gilardi

unread,
Nov 14, 2008, 4:01:35 PM11/14/08
to clo...@googlegroups.com

On Nov 14, 2008, at 3:38 PM, Graham Fawcett wrote:

I'm sure there's a work-around, of course. The meta information is still there:

This appears to be because the sources are no longer included in clojure.jar. I added "<path-to-clojure-trunk-svn-directory>/src/clj" to my classpath and now it works.

--Steve

Graham Fawcett

unread,
Nov 14, 2008, 4:09:05 PM11/14/08
to clo...@googlegroups.com
Thanks, Steve -- an easy fix!

Best,
Graham


> --Steve
>
> >
>

Feng

unread,
Nov 14, 2008, 4:38:03 PM11/14/08
to Clojure


On Nov 14, 4:09 pm, "Graham Fawcett" <graham.fawc...@gmail.com> wrote:
> On Fri, Nov 14, 2008 at 4:01 PM, Stephen C. Gilardi <squee...@mac.com> wrote:
>
>
>
> > On Nov 14, 2008, at 3:38 PM, Graham Fawcett wrote:
>
> > I'm sure there's a work-around, of course. The meta information is still
> > there:
>
> > This appears to be because the sources are no longer included in
> > clojure.jar. I added "<path-to-clojure-trunk-svn-directory>/src/clj" to my
> > classpath and now it works.
>
> Thanks, Steve -- an easy fix!
>
> Best,
> Graham
>
> > --Steve

M-. will jump to wrong place if defs are not in namespace master .clj.
I already reported it to swank-clojure owner. I guess the fix should
be in git repo soon.

This should fix it.

(defn- namespace-to-path [ns]
(let [ns-str (name (ns-name ns))]
(-> ns-str
(.substring 0 (.lastIndexOf ns-str "."))
(.replace \- \_)
(.replace \. \/))))

(defslimefn find-definitions-for-emacs [name]
(let [sym-name (read-from-string name)
sym-var (ns-resolve (maybe-ns *current-package*) sym-name)]
(when-let [meta (and sym-var (meta sym-var))]
(if-let [path (or (slime-find-file-in-paths (str (namespace-to-
path (:ns meta))
(.separator
File)
(:file meta))
(slime-search-paths))
;; This is OK for namespace master .clj, but not for help files.
; (slime-find-file-in-paths (str (namespace-
to-path (:ns meta)) ".clj")
; (slime-search-
paths))
(slime-find-file-in-paths (:file meta)
(slime-search-paths)))]
`((~(str "(defn " (:name meta) ")")
(:location
~path
(:line ~(:line meta))
nil)))
`((~(str (:name meta))
(:error "Source definition not found.")))))))

regards,

- Feng

MattyDub

unread,
Dec 9, 2008, 7:15:42 PM12/9/08
to Clojure
I recently tried M-. for the first time with clojure + SLIME and it
broke for me (with a "Lisp error: (error "Synchronous Lisp Evaluation
aborted.")"); other parts of SLIME work (e.g., C-M-x, or C-x C-e), but
this doesn't . I didn't understand the previous messages in this
thread:
1) Stephen Gilardi said to add "<path-to-clojure-trunk-svn-directory>/
src/clj" to his classpath - what classpath? The swank-clojure-jar-
path in my .emacs? Or another classpath?
2) Feng suggested a patch, but didn't mention what file to make that
patch in - what file was that for?
Has this problem been patched yet? Should I just update my swank-
clojure, or something? Any help is appreciated. (I'm inferring from
the first method that swank-clojure supports slime-edit-definition -
if I'm incorrect, please let me know.)
Thanks,
-Matt

Bill Clementson

unread,
Dec 9, 2008, 7:23:16 PM12/9/08
to clo...@googlegroups.com
Hi Matt,

On Tue, Dec 9, 2008 at 4:15 PM, MattyDub <Matty...@gmail.com> wrote:
>
> I recently tried M-. for the first time with clojure + SLIME and it
> broke for me (with a "Lisp error: (error "Synchronous Lisp Evaluation
> aborted.")"); other parts of SLIME work (e.g., C-M-x, or C-x C-e), but
> this doesn't . I didn't understand the previous messages in this
> thread:
> 1) Stephen Gilardi said to add "<path-to-clojure-trunk-svn-directory>/
> src/clj" to his classpath - what classpath? The swank-clojure-jar-
> path in my .emacs? Or another classpath?
> 2) Feng suggested a patch, but didn't mention what file to make that
> patch in - what file was that for?
> Has this problem been patched yet? Should I just update my swank-
> clojure, or something? Any help is appreciated. (I'm inferring from
> the first method that swank-clojure supports slime-edit-definition -
> if I'm incorrect, please let me know.)

The problem has been fixed. If you download both the latest SVN
version of Clojure and the latest GIT version of swank-clojure, you
should be fine.

- Bill

MattyDub

unread,
Dec 9, 2008, 9:43:30 PM12/9/08
to Clojure
I did an 'svn update' on my clojure (I'm now at revision 1149), and
ran ant clean, then ant (the default target). Then I deleted my old
swank-clojure directory, and did a git clone of git://github.com/jochu/swank-clojure.git.
I made sure my .emacs was correctly pointing to the appropriate
paths. I still get the same error. Perhaps I'm using it
incorrectly? What is the proper usage? I start slime:
M-x slime
then load the file by using C-x C-e on the following line in ants.clj:
(load-file "c:/home/ants.clj")
Then in a buffer pointing to ants.clj, I put the point over a call to
render-place, and do M-. And I get this stack trace:
Debugger entered--Lisp error: (error "Synchronous Lisp Evaluation
aborted.")
signal(error ("Synchronous Lisp Evaluation aborted."))
error("Synchronous Lisp Evaluation aborted.")
funcall(error "Synchronous Lisp Evaluation aborted.")
apply(funcall (error "Synchronous Lisp Evaluation aborted."))
(let* ((tag ...) (slime-stack-eval-tags ...)) (apply (function
funcall) (catch tag ... ...)))
slime-eval((swank:find-definitions-for-emacs "render-place"))
slime-find-definitions-rpc("render-place")
funcall(slime-find-definitions-rpc "render-place")
slime-find-definitions("render-place")
(slime-edit-definition-cont (slime-find-definitions name) name
where)
(or (run-hook-with-args-until-success (quote slime-edit-definition-
hooks) name where) (slime-edit-definition-cont (slime-find-definitions
name) name where))
slime-edit-definition("render-place")
call-interactively(slime-edit-definition)

I must be doing something wrong - any ideas what?
-Matt

Bill Clementson

unread,
Dec 10, 2008, 2:03:33 AM12/10/08
to clo...@googlegroups.com
Hi Matt,

Hmm, looks like I was mistaken in my earlier email. I get the same
thing when I do M-. on "render-place". However, if I place the point
on "defn" (or any other symbol name that is in a jar file), it goes to
the correct source in the jar file. At first, I thought it was because
ant.clj was not in the class path; however, it doesn't work when
ant.clj is in the class path either. I applied the
find-definitions-for-emacs patch proposed in the earlier email;
however, that doesn't work either. This used to work for local
definitions and was broken a few svn changes ago. It was fixed for
clojure definitions that are in jar files; however, it seems to still
be broken for local definitions.

- Bill

MattyDub

unread,
Dec 10, 2008, 12:20:27 PM12/10/08
to Clojure
Thanks for confirming the bug, Bill. Should we post this to Jeffrey
Chu (assuming it's a swank-clojure issue)? What's the protocol at
this point?
-Matt

Bill Clementson

unread,
Dec 10, 2008, 12:57:12 PM12/10/08
to clo...@googlegroups.com
Hi Matt,

Yes, you should let Jeffrey know about the bug.

- Bill

Bill Clementson

unread,
Dec 10, 2008, 2:44:48 PM12/10/08
to clo...@googlegroups.com
Hi Matt,

I had a bit of free time this morning, so I looked into this further
and came up with a patch (attached). I've forwarded the patch to
Jeffrey as well, so it should find it's way into swank-clojure in due
course.

Cheers,
Bill Clementson
patch

Bill Clementson

unread,
Dec 10, 2008, 3:00:14 PM12/10/08
to clo...@googlegroups.com
Oops, that patch had my debugging statements in it. Here's the correct
one to use.
patch

MattyDub

unread,
Dec 10, 2008, 3:47:09 PM12/10/08
to Clojure
I can confirm that that patch fixed my problem - I can now M-. to
render-place. Thanks, Bill!
What paths does slime-edit-definition search for the definitions?
It's not finding the clojure macros/functions (like defn, dosync,
etc.), so I must not have that path configured correctly.
-Matt

On Dec 10, 12:00 pm, "Bill Clementson" <billc...@gmail.com> wrote:
> Oops, that patch had my debugging statements in it. Here's the correct
> one to use.
>
> On Wed, Dec 10, 2008 at 11:44 AM, Bill Clementson <billc...@gmail.com> wrote:
> > Hi Matt,
>
> > I had a bit of free time this morning, so I looked into this further
> > and came up with a patch (attached). I've forwarded the patch to
> > Jeffrey as well, so it should find it's way into swank-clojure in due
> > course.
>
> > Cheers,
> > Bill Clementson
>
> > On Wed, Dec 10, 2008 at 9:57 AM, Bill Clementson <billc...@gmail.com> wrote:
> >> Hi Matt,
>
> >> Yes, you should let Jeffrey know about the bug.
>
> >> - Bill
>
>  patch
> 1KViewDownload

Bill Clementson

unread,
Dec 10, 2008, 4:09:34 PM12/10/08
to clo...@googlegroups.com
Hi Matt,

On Wed, Dec 10, 2008 at 12:47 PM, MattyDub <Matty...@gmail.com> wrote:
>
> I can confirm that that patch fixed my problem - I can now M-. to
> render-place. Thanks, Bill!

Good to hear that the patch fixes the issue for you.

> What paths does slime-edit-definition search for the definitions?
> It's not finding the clojure macros/functions (like defn, dosync,
> etc.), so I must not have that path configured correctly.
> -Matt

Basically, it searches a bunch of standard Java locations plus the
locations you specified in your classpath. If you want to see what
will be searched, enter the following 2 statements in your Clojure
REPL:
(in-ns 'swank.commands.basic)
(slime-search-paths)

Note: the function "slime-search-paths" isn't public

If M-. isn't working on standard Clojure symbols, it could be for a
number of reasons:
1. You're using an old version of Clojure
2. You've built Clojure excluding source from the jar file
3. The Clojure source isn't in your classpath (only necessary if #2 is true)

- Bill

Bill Clementson

unread,
Dec 11, 2008, 12:04:35 AM12/11/08
to clo...@googlegroups.com
Hi Matt,

FYI - Jeffrey Chu just sent me an email and the patch has now been
applied to swank-clojure.

- Bill

MattyDub

unread,
Dec 11, 2008, 1:03:17 PM12/11/08
to Clojure
Well, I had the .clj files in my clojure.jar, and clojure.jar is on
slime-search-paths, but I still wasn't getting M-. to work with
clojure's functions and macros. I added the source files to my
classpath, and I get them now.
Also, I updated clojure and swank-clojure this morning, so it looks
like the latest and greatest are playing well with each other.
Thanks for the help, Bill.
-Matt


On Dec 10, 9:04 pm, "Bill Clementson" <billc...@gmail.com> wrote:
> Hi Matt,
>
> FYI - Jeffrey Chu just sent me an email and the patch has now been
> applied to swank-clojure.
>
> - Bill
>
> On Wed, Dec 10, 2008 at 1:09 PM, Bill Clementson <billc...@gmail.com> wrote:
> > Hi Matt,
>

kunnar

unread,
Dec 14, 2008, 4:41:55 PM12/14/08
to Clojure
Hi,

Looks like patch is already applied, but i now i get following error
after "M-."

java.lang.IllegalArgumentException: No matching field found: separator
for class java.lang.Class (NO_SOURCE_FILE:0)
[Thrown class clojure.lang.Compiler$CompilerException]


I updated everything clojure related - clojure itself, swank-clojure,
clojure-mode, slime, clojure-contrib, but i still get that error.
Before update "M-." did work.

Kunnar

On Dec 11, 7:04 am, "Bill Clementson" <billc...@gmail.com> wrote:
> Hi Matt,
>
> FYI - Jeffrey Chu just sent me an email and the patch has now been
> applied to swank-clojure.
>
> - Bill
>
> On Wed, Dec 10, 2008 at 1:09 PM, Bill Clementson <billc...@gmail.com> wrote:
> > Hi Matt,
>
> > On Wed, Dec 10, 2008 at 12:47 PM, MattyDub <MattyDu...@gmail.com> wrote:
>
> >> I can confirm that that patch fixed my problem - I can now M-. to
> >> render-place.  Thanks, Bill!
>
> > Good to hear that the patch fixes the issue for you.
>
> >>   What paths doesslime-edit-definitionsearch for the definitions?

Feng

unread,
Dec 14, 2008, 5:20:44 PM12/14/08
to Clojure
This is due to the change in clojure svn 1158. (.method ClassName ...)
syntax has been changed to call java.lang.Class method for ClassName,
not static field/method any more. Use namespace syntax instead.

diff --git a/swank/commands/basic.clj b/swank/commands/basic.clj
index ac0736f..4705cd5 100644
--- a/swank/commands/basic.clj
+++ b/swank/commands/basic.clj
@@ -273,7 +273,7 @@
(when-let [meta (and sym-var (meta sym-var))]
(if-let [path (or (slime-find-file-in-paths (:file meta) (slime-
search-paths))
(slime-find-file-in-paths (str (namespace-to-
path (:ns meta))
- (.separator
File)
+ File/separator
(:file meta))
(slime-search-paths))
`((~(str "(defn " (:name meta) ")")
(:location
diff --git a/swank/util/io.clj b/swank/util/io.clj
index 56b037e..48fd5b8 100644
--- a/swank/util/io.clj
+++ b/swank/util/io.clj
@@ -28,7 +28,7 @@
(dothread
(thread-set-name "Call-on-write Stream")
(continuously
- (.sleep Thread 200)
+ (Thread/sleep 200)
(when-not @closed?
(.flush stream))))

Bill Clementson

unread,
Dec 16, 2008, 12:54:26 PM12/16/08
to clo...@googlegroups.com
FYI - I forwarded the patch to Jeffrey Chu and he has patched
swank-clojure in git.

- Bill
Reply all
Reply to author
Forward
0 new messages