From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rick Moynihan Subject: Re: Org-Babel - Clojure & Lazy Sequences Bug Date: Wed, 24 Nov 2010 01:51:44 +0000 Message-ID: References: <87k4kqpc4q.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=38904 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PL4Wr-00066M-Uq for emacs-orgmode@gnu.org; Tue, 23 Nov 2010 20:52:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PL4Wk-0007p2-KN for emacs-orgmode@gnu.org; Tue, 23 Nov 2010 20:52:13 -0500 Received: from mail-qy0-f169.google.com ([209.85.216.169]:61645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PL4Wk-0007oy-HN for emacs-orgmode@gnu.org; Tue, 23 Nov 2010 20:52:06 -0500 Received: by qyk4 with SMTP id 4so3058998qyk.0 for ; Tue, 23 Nov 2010 17:52:05 -0800 (PST) In-Reply-To: <87k4kqpc4q.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode@gnu.org Hi Eric, Sorry for the delay in getting back to you. I can confirm the fix you quoted below works for me also. I've not been using any of the multiple session features, so I haven't run into the other problems you mention. Any idea on what a more permanent solution might be? R. On 6 November 2010 17:58, Eric Schulte wrote: > Hi Rick, > > I've noticed this as well. =A0I'm not the original author of ob-clojure.e= l > (Joel Boehland is), so I'm not sure how the clojure interaction > currently works, although I know it makes heavy usage of slime. =A0There > must be an existing mechanism used by slime to unroll these lazy > evaluations, for example in the repl (range 10) *is* expanded > > user> (range 10) > (0 1 2 3 4 5 6 7 8 9) > > I'm using clojure extensively in my studies so I have all the more > reason to try to figure this out. =A0I'll put this on my stack. > > BTW: I've noticed that I am unable to get Clojure code blocks to play > nicely with existing slime sessions, say for example I have some large > piece of data in scope in a slime sessions and I'd like to access that > data from a clojure code block and dump some analysis to an Org-mode > document. =A0I have not yet found out how to make this work. =A0If you ha= ve, > I'd love to hear how, otherwise I'll look into this as well. > > Best -- Eric > > Having just looked at this quickly, the following function over-defines > `org-babel-execute:clojure' s.t. =A0the body of the code block is sent to > the superior list in the same manner as when calling `slime-eval-defun' > from within a .clj file. =A0While this doesn't handle starting up clojure > instances or differentiate between session and external evaluation it > should fix the issues mentioned above and could be the beginning of a > permanent solution. > > #+begin_src emacs-lisp > =A0(defun org-babel-execute:clojure (body params) > =A0 =A0(with-temp-buffer > =A0 =A0 =A0(insert body) > =A0 =A0 =A0(read > =A0 =A0 =A0 (slime-eval > =A0 =A0 =A0 =A0`(swank:interactive-eval-region > =A0 =A0 =A0 =A0 =A0,(buffer-substring-no-properties (point-min) (point-ma= x))))))) > #+end_src > > which then results in > > #+begin_src clojure > =A0(map (fn [el] (list el (* el el))) (range 10)) > #+end_src > > evaluating to > > #+results: > | 0 | =A00 | > | 1 | =A01 | > | 2 | =A04 | > | 3 | =A09 | > | 4 | 16 | > | 5 | 25 | > | 6 | 36 | > | 7 | 49 | > | 8 | 64 | > | 9 | 81 | > > Rick Moynihan writes: > >> I have the following org file: >> >> #+BEGIN_SRC clojure >> (range 10) >> #+END_SRC >> >> #+results: >> : clojure.lang.LazySeq@f35bf8c6 >> >> Where as I would expect to see the sequence. =A0Evaluating the code >> inside a doall doesn't seem to do anything either: >> >> #+BEGIN_SRC clojure >> (doall (range 10)) >> #+END_SRC >> >> #+results: >> : clojure.lang.LazySeq@f35bf8c6 >> >> Is there any parameter I can pass to the block to get the code to >> execute in a doall and return the sequence values rather than the >> lazy-seq object itself? >> >> R. >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >