浏览代码

org-babel-remove-result option keep result keyword

This patch is based off of a request and an initial patch supplied by
Daniele Pizzolli.

* lisp/ob-core.el (org-babel-remove-result): Added an option to keep
  the results keyword when removing the content of results.
Eric Schulte 11 年之前
父节点
当前提交
136bdc0e83
共有 1 个文件被更改,包括 7 次插入5 次删除
  1. 7 5
      lisp/ob-core.el

+ 7 - 5
lisp/ob-core.el

@@ -2159,15 +2159,17 @@ code ---- the results are extracted in the syntax of the source
 	  (set-marker visible-beg nil)
 	  (set-marker visible-end nil))))))
 
-(defun org-babel-remove-result (&optional info)
+(defun org-babel-remove-result (&optional info keep-keyword)
   "Remove the result of the current source block."
   (interactive)
-  (let ((location (org-babel-where-is-src-block-result nil info)) start)
+  (let ((location (org-babel-where-is-src-block-result nil info)))
     (when location
-      (setq start (- location 1))
       (save-excursion
-        (goto-char location) (forward-line 1)
-        (delete-region start (org-babel-result-end))))))
+        (goto-char location)
+	(when (looking-at org-babel-result-regexp)
+	  (delete-region
+	   (if keep-keyword (1+ (match-end 0)) (match-beginning 0))
+	   (progn (forward-line 1) (org-babel-result-end))))))))
 
 (defun org-babel-result-end ()
   "Return the point at the end of the current set of results."