From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: [babel] hemorrhaging at the bleeding edge: using clojure Date: Thu, 28 Apr 2011 17:53:53 +0100 Message-ID: <8762pyfhb2.fsf@ucl.ac.uk> References: <87k4egi0u5.fsf@ucl.ac.uk> <87wrifkevi.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:46216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFUTX-0000e5-Uj for emacs-orgmode@gnu.org; Thu, 28 Apr 2011 12:54:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QFUTW-0004Hw-Rr for emacs-orgmode@gnu.org; Thu, 28 Apr 2011 12:53:59 -0400 Received: from vscane-b.ucl.ac.uk ([144.82.108.141]:48859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFUTW-0004Hq-Jh for emacs-orgmode@gnu.org; Thu, 28 Apr 2011 12:53:58 -0400 In-Reply-To: <87wrifkevi.fsf@gmail.com> (Eric Schulte's message of "Wed, 27 Apr 2011 07:10:02 -0600") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode@gnu.org "Eric Schulte" 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 "#") 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)