瀏覽代碼

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.
Eric Schulte 13 年之前
父節點
當前提交
a706d16127
共有 2 個文件被更改,包括 8 次插入4 次删除
  1. 7 3
      lisp/ob.el
  2. 1 1
      lisp/org.el

+ 7 - 3
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
           is a good option if you code block will output org-mode
           formatted text.
           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
 org ----- similar in effect to raw, only the results are wrapped
           in an org code block.  Similar to the raw option, on
           in an org code block.  Similar to the raw option, on
           export the results will be interpreted as org-formatted
           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)
 	   ((member "raw" result-params)
 	    (goto-char beg) (if (org-at-table-p) (org-cycle)))
 	    (goto-char beg) (if (org-at-table-p) (org-cycle)))
 	   ((member "wrap" result-params)
 	   ((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))
 	   ((and (not (proper-list-p result))
 		 (not (member "file" result-params)))
 		 (not (member "file" result-params)))
 	    (org-babel-examplize-region beg end results-switches)
 	    (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))
      ((org-at-item-p) (let* ((struct (org-list-struct))
 			     (prvs (org-list-prevs-alist struct)))
 			     (prvs (org-list-prevs-alist struct)))
 			(org-list-get-list-end (point-at-bol) struct prvs)))
 			(org-list-get-list-end (point-at-bol) struct prvs)))
+     ((looking-at "^\\([ \t]*\\):RESULTS:")
+      (re-search-forward (concat "^" (match-string 1) ":END:")))
      (t
      (t
       (let ((case-fold-search t)
       (let ((case-fold-search t)
 	    (blocks-re (regexp-opt
 	    (blocks-re (regexp-opt

+ 1 - 1
lisp/org.el

@@ -846,7 +846,7 @@ than its value."
 	  (const :tag "No limit" nil)
 	  (const :tag "No limit" nil)
 	  (integer :tag "Maximum level")))
 	  (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.
   "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
 Drawers only open with a TAB on the drawer line itself.  A drawer looks like
 this:
 this: