From 136bdc0e83358fa3f6af1d8b3b0cd71cace61efe Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Fri, 20 Sep 2013 15:07:15 -0600 Subject: [PATCH] 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. --- lisp/ob-core.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index cc6b7a9..e2404c1 100644 --- a/lisp/ob-core.el +++ b/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." -- 1.8.4