From mboxrd@z Thu Jan 1 00:00:00 1970 From: Phill Wolf Subject: Re: org-clojure - How to emit an example block? Date: Sat, 8 Feb 2014 18:29:24 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c12c6010134d04f1ed7a7a Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCHKw-0002Wo-C3 for emacs-orgmode@gnu.org; Sat, 08 Feb 2014 18:29:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCHKu-0002sv-UK for emacs-orgmode@gnu.org; Sat, 08 Feb 2014 18:29:26 -0500 Received: from mail-qc0-x232.google.com ([2607:f8b0:400d:c01::232]:50304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCHKu-0002sp-Oz for emacs-orgmode@gnu.org; Sat, 08 Feb 2014 18:29:24 -0500 Received: by mail-qc0-f178.google.com with SMTP id m20so8309369qcx.37 for ; Sat, 08 Feb 2014 15:29:24 -0800 (PST) In-Reply-To: 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: "Thomas S. Dye" Cc: emacs-orgmode@gnu.org --001a11c12c6010134d04f1ed7a7a Content-Type: text/plain; charset=UTF-8 ob-clojure.el should use separate cider functions for value and output results, in order to avoid expressing standard output as some kind of programming-language string with embedded \n notation. I experimentally adjusted my copy of ob-clojure (obtained from git clone -b master today) like this: (1) In the cider block, access the result-params. (2) Put either 'cider-get-value or 'cider-get-raw-value into a variable, depending on the result-params. (3) funcall the variable instead of using cider-get-raw-value directly. (0) Up at the top, add a declare-function for cider-get-value, next to the declare-function for cider-get-raw-value. (defun org-babel-execute:clojure (body params) "Execute a block of Clojure code with Babel." (let ((expanded (org-babel-expand-body:clojure body params)) result) (case org-babel-clojure-backend (cider (require 'cider) (let* ((result-params (cdr (assoc :result-params params))) (cider-call-fn (cond ((member "output" result-params) 'cider-get-value) ((member "value" result-params) 'cider-get-raw-value) (t 'cider-get-raw-value)))) (setq result (or (funcall cider-call-fn [...] Together with :wrap example as suggested by Thomas S. Dye, the results are exemplary. --001a11c12c6010134d04f1ed7a7a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
ob-clojure.el should use separa= te cider functions for value and output results, in order to avoid expressi= ng standard output as some kind of programming-language string with embedde= d \n notation.=C2=A0 I experimentally adjusted my copy of ob-clojure (obtai= ned from git clone -b master today) like this:

(1) In the cider block, access the res= ult-params.
(2) Put either 'cider-get-value or 'cider-get-raw-v= alue into a variable, depending on the result-params.
(3) funcall the v= ariable instead of using cider-get-raw-value directly.
(0) Up at the top, add a declare-function = for cider-get-value, next to the declare-function for cider-get-raw-value.<= /div>

(defun org-babel-execute:clojure (body = params)
=C2=A0 "Execute a block of Clojure code with Babel."
=C2=A0 (l= et ((expanded (org-babel-expand-body:clojure body params))
=C2=A0=C2=A0= =C2=A0 result)
=C2=A0=C2=A0=C2=A0 (case org-babel-clojure-backend
=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 (cider
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = (require 'cider)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let* ((result-params (cdr (asso= c :result-params params)))
=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (cider-call= -fn (cond ((member "output" result-params) 'cider-get-value) =
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((member "= ;value" result-params) 'cider-get-raw-value)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (t 'cider-get-ra= w-value))))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq resu= lt
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 (or (funcall cider-call-fn [...]

Together with :wrap example as suggested by Thomas S. Dye, th= e results are exemplary.
--001a11c12c6010134d04f1ed7a7a--