emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Adding support for :results output for clojure src blocks.
@ 2011-07-13  3:56 Robert McIntyre
  2011-07-13  9:00 ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Robert McIntyre @ 2011-07-13  3:56 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 223 bytes --]

This small patch handles :results output for clojure src blocks by using
clojure's with-out-str function.

Please let me know if I've done anything wrong as this is my first patch to
org-mode.

sincerely,
--Robert McIntyre

[-- Attachment #1.2: Type: text/html, Size: 251 bytes --]

[-- Attachment #2: ob-clojure.el.diff --]
[-- Type: text/x-patch, Size: 1300 bytes --]

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index a72b14c..00013b8 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -62,16 +62,22 @@
 			     vars "\n      ")
 			    "]\n" body ")")
 		  body))))
-    (if (or (member "code" result-params)
-	    (member "pp" result-params))
-	(format
-	 (concat
-	  "(let [org-mode-print-catcher (java.io.StringWriter.)] "
-	  "(clojure.pprint/with-pprint-dispatch clojure.pprint/%s-dispatch "
-	  "(clojure.pprint/pprint (do %s) org-mode-print-catcher) "
-	  "(str org-mode-print-catcher)))")
-	 (if (member "code" result-params) "code" "simple") body)
-      body)))
+    (cond 
+     ((or (member "code" result-params)
+	  (member "pp" result-params))
+      (format
+       (concat
+	"(let [org-mode-print-catcher (java.io.StringWriter.)] "
+	"(clojure.pprint/with-pprint-dispatch clojure.pprint/%s-dispatch "
+	"(clojure.pprint/pprint (do %s) org-mode-print-catcher) "
+	"(str org-mode-print-catcher)))")
+       (if (member "code" result-params) "code" "simple") body))
+     ;; if (:results output), collect printed output 
+     ((member "output" result-params)
+      (format "(clojure.core/with-out-str %s)" body))
+     (t body))))
+
+
 
 (defun org-babel-execute:clojure (body params)
   "Execute a block of Clojure code with Babel."

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Adding support for :results output for clojure src blocks.
  2011-07-13  3:56 [PATCH] Adding support for :results output for clojure src blocks Robert McIntyre
@ 2011-07-13  9:00 ` Bastien
  2011-07-13 17:48   ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Bastien @ 2011-07-13  9:00 UTC (permalink / raw)
  To: Robert McIntyre; +Cc: emacs-orgmode

Hi Robert,

Robert McIntyre <rlm@mit.edu> writes:

> This small patch handles :results output for clojure src blocks by
> using clojure's with-out-str function.

I let Eric Schulte apply (or not) your patch.

> Please let me know if I've done anything wrong as this is my first
> patch to org-mode.

It is more than 10 lines long, so for the patch to be applied we would
need you to sign FSF papers.  I will send them to you privately.

Thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Adding support for :results output for clojure src blocks.
  2011-07-13  9:00 ` Bastien
@ 2011-07-13 17:48   ` Eric Schulte
  2011-07-14 15:49     ` Bastien
  2011-07-16 13:09     ` Bastien
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Schulte @ 2011-07-13 17:48 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode, Robert McIntyre

Yes, please do consider signing the FSF papers to enable this and future
contributions to be included into Org-mode.

However, in this particular case, you could easily sneak your patch into
under 10 lines by replacing the `cond' with a nested `if', and I would
be happy to include such a patch immediately.

Also, for patches directed at ob-* files, if you don't mind building the
patch with "git format-patch" I would prefer that format -- although
I'll happily take patches in any format.

Thanks for contributing! -- Eric

Bastien <bzg@altern.org> writes:

> Hi Robert,
>
> Robert McIntyre <rlm@mit.edu> writes:
>
>> This small patch handles :results output for clojure src blocks by
>> using clojure's with-out-str function.
>
> I let Eric Schulte apply (or not) your patch.
>
>> Please let me know if I've done anything wrong as this is my first
>> patch to org-mode.
>
> It is more than 10 lines long, so for the patch to be applied we would
> need you to sign FSF papers.  I will send them to you privately.
>
> Thanks!

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Adding support for :results output for clojure src blocks.
  2011-07-13 17:48   ` Eric Schulte
@ 2011-07-14 15:49     ` Bastien
  2011-07-16 13:09     ` Bastien
  1 sibling, 0 replies; 5+ messages in thread
From: Bastien @ 2011-07-14 15:49 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Robert McIntyre

Eric Schulte <schulte.eric@gmail.com> writes:

> Yes, please do consider signing the FSF papers to enable this and future
> contributions to be included into Org-mode.

Robert sent the paper, let's wait till the process is done.

> However, in this particular case, you could easily sneak your patch into
> under 10 lines by replacing the `cond' with a nested `if', and I would
> be happy to include such a patch immediately.

:)

Robert, can you reapply a <10-lines patch?

> Also, for patches directed at ob-* files, if you don't mind building the
> patch with "git format-patch" I would prefer that format -- although
> I'll happily take patches in any format.

For the record, I much prefer patch with "git format-patch".  
Easy to read, easy to apply, easy to amend.

Thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Adding support for :results output for clojure src blocks.
  2011-07-13 17:48   ` Eric Schulte
  2011-07-14 15:49     ` Bastien
@ 2011-07-16 13:09     ` Bastien
  1 sibling, 0 replies; 5+ messages in thread
From: Bastien @ 2011-07-16 13:09 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, Robert McIntyre

Eric Schulte <schulte.eric@gmail.com> writes:

> However, in this particular case, you could easily sneak your patch into
> under 10 lines by replacing the `cond' with a nested `if', and I would
> be happy to include such a patch immediately.

I just applied Robert's patch in a way that makes his contribution 
short enough...  in size, not in significance!

Thanks again,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-16 13:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13  3:56 [PATCH] Adding support for :results output for clojure src blocks Robert McIntyre
2011-07-13  9:00 ` Bastien
2011-07-13 17:48   ` Eric Schulte
2011-07-14 15:49     ` Bastien
2011-07-16 13:09     ` Bastien

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).