emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [babel] hemorrhaging at the bleeding edge: using clojure


From: Eric S Fraga
Subject: Re: [O] [babel] hemorrhaging at the bleeding edge: using clojure
Date: Thu, 28 Apr 2011 17:53:53 +0100
User-agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux)

"Eric Schulte" <address@hidden> writes:

[...]

> I would suggest using that latest version of ELPA, and adding the
> following repository sources to your ELPA archives...

[...]

> Once you have slime working, then Babel code blocks should be trivial
> (they rely on a slime session).  Be sure to use the ":package" header
> argument to specify the namespace in which to evaluate your clojure
> code.

Eric (and/or anybody else with babel+clojure expertise?),

again, thanks for your help on this but I hope I can continue to bother
you!

I have finally managed to get clojure working in org+babel.  To cut a
very long story short, there were two problems (for the benefit of the
mailing list):

1. I had a previously installed version of slime on my system that was
   conflicting with the new version being installed by elpa.  In moving
   from emacs 23.x to 24.x, a number of old packages remained and slime
   was one of them.  Removing the old version suddenly made things work
   (sort of).

2. Because I'm using clojure as an interface to an existing Java package
   (in-house, written over the past 15 years so a large investment in
   effort), the whole issue of classpaths raised its ugly head (the
   worst aspect of java, IMO).  I finally sorted this out by making my
   own version of the swank-clojure script to automatically include my
   own very complex classpath.

So, now I have a setup in which my clojure code is executed just fine,
Java packages are found as are clojure packages, etc.  However, I cannot
get output into my org file.  For instance, the following code

--8<---------------cut here---------------start------------->8---
    #+srcname: simple
    #+begin_src clojure :results output raw
(variable [-1 1 2 3])
    #+end_src
--8<---------------cut here---------------end--------------->8---

works, in that the output I would expect appears in the =*slime-events*=
buffer: 

--8<---------------cut here---------------start------------->8---
(:emacs-rex
 (swank:interactive-eval-region "(variable [-1 1 2 3])")
 "user" t 17)
(:return
 (:ok "#<Variables x={ -1.0, 1.0, 2.0, 3.0 }>")
 17)
--8<---------------cut here---------------end--------------->8---

(don't worry about what the output says...  Variables is a Java object I
need to work with.)

The problem is that nothing appears in the org file; instead, I get the
following error message:

--8<---------------cut here---------------start------------->8---
Evaluate this clojure code block (simple) on your system? (y or n)  y
executing Clojure code block (simple)...
org-babel-execute:clojure: Invalid read syntax: "#"
--8<---------------cut here---------------end--------------->8---

This is very confusing...  From looking at the relevant elisp code:

--8<---------------cut here---------------start------------->8---
(read
     (slime-eval
      `(swank:interactive-eval-region
        ,(buffer-substring-no-properties (point-min) (point-max)))
      (cdr (assoc :package params))))
--8<---------------cut here---------------end--------------->8---

=read= is trying to interpret the code.  But I'm not sure what this is
intended to do in this case.

If I change my code to use the Java =.toString= method on my object, and
ask for either output or value results, it works:

--8<---------------cut here---------------start------------->8---
    #+srcname: simple
    #+begin_src clojure :results value
(.toString (variable [-1 1 2 3]))
    #+end_src

    #+results: simple
    : x={ -1.0, 1.0, 2.0, 3.0 }
--8<---------------cut here---------------end--------------->8---


Can you help at all?  I am a little confused, to say the least :(

But happy in that I've made some progress at least!  Although it *has*
taken me all afternoon!

Thanks again and sorry for the long diatribe,
eric

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.222.g0846a)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]