emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Phill Wolf <phill.wolf@gmail.com>
To: "Thomas S. Dye" <tsd@tsdye.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-clojure - How to emit an example block?
Date: Sat, 8 Feb 2014 18:29:24 -0500	[thread overview]
Message-ID: <CAH+qJs+S5++ywC8Mjfxy8b3asQehnvRAG2vq9feXw2L9pJgmgw@mail.gmail.com> (raw)
In-Reply-To: <m2bnyhp7yg.fsf@tsdye.com>

[-- Attachment #1: Type: text/plain, Size: 1348 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 1815 bytes --]

  reply	other threads:[~2014-02-08 23:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-08 20:48 org-clojure - How to emit an example block? Phill Wolf
2014-02-08 22:15 ` Thomas S. Dye
2014-02-08 23:29   ` Phill Wolf [this message]
2014-02-09  7:57     ` Bastien

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=CAH+qJs+S5++ywC8Mjfxy8b3asQehnvRAG2vq9feXw2L9pJgmgw@mail.gmail.com \
    --to=phill.wolf@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tsd@tsdye.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).