[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] org-clojure - How to emit an example block?

From: Phill Wolf
Subject: Re: [O] org-clojure - How to emit an example block?
Date: Sat, 8 Feb 2014 18:29:24 -0500

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))
    (case org-babel-clojure-backend
       (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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]