emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric S Fraga <e.fraga@ucl.ac.uk>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [babel] hemorrhaging at the bleeding edge: using clojure
Date: Thu, 28 Apr 2011 17:53:53 +0100	[thread overview]
Message-ID: <8762pyfhb2.fsf@ucl.ac.uk> (raw)
In-Reply-To: <87wrifkevi.fsf@gmail.com> (Eric Schulte's message of "Wed, 27 Apr 2011 07:10:02 -0600")

"Eric Schulte" <schulte.eric@gmail.com> 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)

  parent reply	other threads:[~2011-04-28 16:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27  7:56 [babel] hemorrhaging at the bleeding edge: using clojure Eric S Fraga
2011-04-27 13:10 ` Eric Schulte
2011-04-27 15:50   ` Eric S Fraga
2011-04-28 16:53   ` Eric S Fraga [this message]
2011-04-28 17:08     ` Eric S Fraga
2011-04-28 18:22     ` Eric Schulte
2011-04-28 20:21       ` Eric S Fraga
2011-04-28 20:41         ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8762pyfhb2.fsf@ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=schulte.eric@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).