From a706d16127d463adaa4f038b776e58326a5eea5b Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 11 Dec 2011 09:27:48 -0700 Subject: [PATCH] wrap code block results in drawers rather than blocks * lisp/ob.el (org-babel-insert-result): Do not examplize wrapped scalar results, simply wrap them. (org-babel-result-end): Find the end of results wrapped in a RESULTS drawer. --- lisp/ob.el | 10 +++++++--- lisp/org.el | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index 5610924c4..4d779d550 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1703,6 +1703,10 @@ raw ----- results are added directly to the Org-mode file. This is a good option if you code block will output org-mode formatted text. +wrap ---- results are added directly to the Org-mode file as with + \"raw\", but are wrapped in a RESULTS drawer, allowing + them to later be replaced or removed automatically. + org ----- similar in effect to raw, only the results are wrapped in an org code block. Similar to the raw option, on export the results will be interpreted as org-formatted @@ -1821,9 +1825,7 @@ code ---- the results are extracted in the syntax of the source ((member "raw" result-params) (goto-char beg) (if (org-at-table-p) (org-cycle))) ((member "wrap" result-params) - (when (and (stringp result) (not (member "file" result-params))) - (org-babel-examplize-region beg end results-switches)) - (wrap "#+BEGIN_RESULT" "#+END_RESULT")) + (wrap ":RESULTS:" ":END:")) ((and (not (proper-list-p result)) (not (member "file" result-params))) (org-babel-examplize-region beg end results-switches) @@ -1858,6 +1860,8 @@ code ---- the results are extracted in the syntax of the source ((org-at-item-p) (let* ((struct (org-list-struct)) (prvs (org-list-prevs-alist struct))) (org-list-get-list-end (point-at-bol) struct prvs))) + ((looking-at "^\\([ \t]*\\):RESULTS:") + (re-search-forward (concat "^" (match-string 1) ":END:"))) (t (let ((case-fold-search t) (blocks-re (regexp-opt diff --git a/lisp/org.el b/lisp/org.el index a505b3421..30f92d1eb 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -846,7 +846,7 @@ than its value." (const :tag "No limit" nil) (integer :tag "Maximum level"))) -(defcustom org-drawers '("PROPERTIES" "CLOCK" "LOGBOOK") +(defcustom org-drawers '("PROPERTIES" "CLOCK" "LOGBOOK" "RESULTS") "Names of drawers. Drawers are not opened by cycling on the headline above. Drawers only open with a TAB on the drawer line itself. A drawer looks like this: -- git format-patch -1 --stdout -C a706d16127d463adaa4f038b776e58326a5eea5b