From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Clojure Code Block Results not Tabularized Date: Wed, 29 Jan 2014 08:02:19 -0700 Message-ID: <87d2ja4yro.fsf@gmail.com> References: <1390915384.2241.11.camel@raven-CM5571> <1390998988.2272.12.camel@raven-CM5571> <1391000780.2272.18.camel@raven-CM5571> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Wgm-0000ba-O6 for emacs-orgmode@gnu.org; Wed, 29 Jan 2014 10:04:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8Wgh-0006De-Hn for emacs-orgmode@gnu.org; Wed, 29 Jan 2014 10:04:28 -0500 Received: from mail-pd0-x22f.google.com ([2607:f8b0:400e:c02::22f]:50042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Wgh-0006DW-AK for emacs-orgmode@gnu.org; Wed, 29 Jan 2014 10:04:23 -0500 Received: by mail-pd0-f175.google.com with SMTP id w10so1778864pde.6 for ; Wed, 29 Jan 2014 07:04:22 -0800 (PST) In-Reply-To: <1391000780.2272.18.camel@raven-CM5571> (Soapy Smith's message of "Wed, 29 Jan 2014 08:06:20 -0500") 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: Soapy Smith Cc: emacs-orgmode@gnu.org, Christian Moe Soapy Smith writes: > Yes, I agree the Clojure behavior is not quite correct. But all the > functionality is there if both the old and new are combined. I think > only a rearrangement of existing code is required. > Try evaluating the following and see how it works. This simply copies the results handling from the slime backend to the cider backend (which currently does not appear to have any results handling). While you're at it the nrepl results handling looks broken to me as well. Maybe Bastien (who I believe wrote or committed this code) can help. (defun org-babel-execute:clojure (body params) "Execute a block of Clojure code with Babel." (let ((expanded (org-babel-expand-body:clojure body params))) (case org-babel-clojure-backend (cider (require 'cider) (let ((result (or (nth 1 (nrepl-send-string-sync expanded (cider-current-ns) (nrepl-current-tooling-session))) (error "nREPL not connected! Use M-x cider-jack-in RET")))) (org-babel-result-cond (cdr (assoc :result-params params)) result (condition-case nil (org-babel-script-escape result) (error result))))) (nrepl (require 'nrepl) (if (nrepl-current-connection-buffer) (let* ((result (nrepl-eval expanded)) (s (plist-get result :stdout)) (r (plist-get result :value))) (if s (concat s "\n" r) r)) (error "nREPL not connected! Use M-x nrepl-jack-in RET"))) (slime (require 'slime) (with-temp-buffer (insert expanded) ((lambda (result) (let ((result-params (cdr (assoc :result-params params)))) (org-babel-result-cond result-params result (condition-case nil (org-babel-script-escape result) (error result))))) (slime-eval `(swank:eval-and-grab-output ,(buffer-substring-no-properties (point-min) (point-max))) (cdr (assoc :package params))))))))) I don't have clojure installed locally and can't test. Best, > > I like the idea of comparing to the behavior of Python code blocks. > I've got a Coursera class coming up which will use Python, so I need to > get it set it up here. > > Thank you for the assistance! > Greg > > On Wed, 2014-01-29 at 13:58 +0100, Christian Moe wrote: >> Soapy Smith writes: >> >> > Christian, could you try :results table with Python and reply back with >> > the #+RESULTS:? >> >> Same as the default, i.e. a table, as expected. >> #+RESULTS: >> | 1 | 2 | 3 | >> >> The Babel/Clojure behavior you report does seem buggy. >> >> I'm afraid I can't be of further help, but hopefully others will pick up >> on this. >> >> Yours, >> Christian > > > -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D