Aloha all,

The attached patch defines a new header argument, :special, which wraps
the results of Org babel source block execution in a #BEGIN_ ... #+END_
block.  The block name is taken from a new variable
org-babel-wrap-special, which is initialized as "results".

I use this in conjunction with org-special-blocks for LaTeX export.  I'm
writing a didactic article where I set off results and format them with
the LaTeX framed package. 

All the best,
Tom

>From 4a31fd6dc99168315dba91fea5df9f07233ad5e1 Mon Sep 17 00:00:00 2001
From: Thomas Dye <dk@poto.local>
Date: Sun, 8 Jan 2012 06:00:47 -1000
Subject: [PATCH] * lisp/ob.el: Add :special header argument

---
 lisp/ob.el |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/lisp/ob.el b/lisp/ob.el
index 0288eb3..da63675 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -378,7 +378,7 @@ then run `org-babel-pop-to-session'."
     (noweb-ref	. :any)
     (padline	. ((yes no)))
     (results	. ((file list vector table scalar verbatim)
-		    (raw org html latex code pp wrap)
+		    (raw org html latex code pp wrap special)
 		    (replace silent append prepend)
 		    (output value)))
     (rownames	. ((no yes)))
@@ -1622,6 +1622,7 @@ If the path of the link is a file path it is expanded using
       ;; scalar result
       (echo-res result))))
 
+(defvar org-babel-wrap-special "results")
 (defun org-babel-insert-result
   (result &optional result-params info hash indent lang)
   "Insert RESULT into the current buffer.
@@ -1663,6 +1664,10 @@ latex --- results are added inside of a #+BEGIN_LATEX block.
           This is a good option if you code block will output
           latex formatted text.
 
+special --- results are added inside of a #+BEGIN_ ... #+END_
+            block, with the block name taken from the variable
+            org-babel-wrap-special.
+
 code ---- the results are extracted in the syntax of the source
           code of the language being evaluated and are added
           inside of a #+BEGIN_SRC block with the source-code
@@ -1767,6 +1772,8 @@ code ---- the results are extracted in the syntax of the source
 	    (goto-char beg) (if (org-at-table-p) (org-cycle)))
 	   ((member "wrap" result-params)
 	    (wrap ":RESULTS:" ":END:"))
+	   ((member "special" result-params)
+	    (wrap (format "#+BEGIN_%s" org-babel-wrap-special)  (format "#+END_%s" org-babel-wrap-special) ))
 	   ((and (not (proper-list-p result))
 		 (not (member "file" result-params)))
 	    (org-babel-examplize-region beg end results-switches)
-- 
1.7.5.4

-- 
T.S. Dye & Colleagues, Archaeologists
735 Bishop St, Suite 315, Honolulu, HI 96813
Tel: 808-529-0866, Fax: 808-529-0884
http://www.tsdye.com

Reply via email to