From: Rick Moynihan <firstname.lastname@example.org> To: Eric Schulte <email@example.com> Cc: firstname.lastname@example.org Subject: Re: Org-Babel - Clojure & Lazy Sequences Bug Date: Wed, 24 Nov 2010 01:51:44 +0000 [thread overview] Message-ID: <AANLkTin4=Mu4G6zYhVcgVqmYxwgEVQncidRHA_fLVemail@example.com> (raw) In-Reply-To: <firstname.lastname@example.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 <email@example.com> wrote: > Hi Rick, > > I've noticed this as well. I'm not the original author of ob-clojure.el > (Joel Boehland is), so I'm not sure how the clojure interaction > currently works, although I know it makes heavy usage of slime. There > 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. I'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. I have not yet found out how to make this work. If you have, > 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. the 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. While 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 > (defun org-babel-execute:clojure (body params) > (with-temp-buffer > (insert body) > (read > (slime-eval > `(swank:interactive-eval-region > ,(buffer-substring-no-properties (point-min) (point-max))))))) > #+end_src > > which then results in > > #+begin_src clojure > (map (fn [el] (list el (* el el))) (range 10)) > #+end_src > > evaluating to > > #+results: > | 0 | 0 | > | 1 | 1 | > | 2 | 4 | > | 3 | 9 | > | 4 | 16 | > | 5 | 25 | > | 6 | 36 | > | 7 | 49 | > | 8 | 64 | > | 9 | 81 | > > Rick Moynihan <firstname.lastname@example.org> 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. Evaluating 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. >> Emacsemail@example.com >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >
next prev parent reply other threads:[~2010-11-24 1:52 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-11-04 14:11 Rick Moynihan 2010-11-06 17:58 ` Eric Schulte 2010-11-24 1:51 ` Rick Moynihan [this message] 2010-11-25 17:40 ` Eric Schulte 2010-11-25 18:31 ` Rick Moynihan 2010-11-26 20:29 ` Eric Schulte 2010-11-26 20:53 ` Rick Moynihan 2010-11-26 22:49 ` Eric Schulte 2010-11-27 8:27 ` Achim Gratz 2010-11-27 15:20 ` Eric Schulte 2010-11-28 23:23 ` Rick Moynihan 2010-11-29 3:59 ` 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='AANLkTin4=Mu4G6zYhVcgVqmYxwgEVQncidRHA_fLVfirstname.lastname@example.org' \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: Org-Babel - Clojure & Lazy Sequences Bug' \ /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
Code repositories for project(s) associated with this 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).