summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-11-27 23:23:04 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-11-27 23:23:04 +0100
commitd7940ae2a7ca01f01d17ba85e113ad7cc65b10ea (patch)
tree19adf3a180e9e623bf0dbadaa5410c84e508487e
parent5873d9912145fb19d00cfa47587f8e16c59da56a (diff)
downloadorg-mode-d7940ae2a7ca01f01d17ba85e113ad7cc65b10ea.tar.gz
ob-core: Fix removal of elements after RESULTS
* lisp/ob-core.el (org-babel-result-end): Ignore elements that do not correspond to a valid result type (e.g., a headline). Fixes commit 1d8126385cf979cfaade0e6a82040884bd6af56b. Reported-by: Kaushal Modi <kaushal.modi@gmail.com> <http://lists.gnu.org/r/emacs-orgmode/2017-11/msg00384.html>
-rw-r--r--lisp/ob-core.el18
1 files changed, 12 insertions, 6 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 106cfbd..0bf86df 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2460,12 +2460,18 @@ in the buffer."
(cond ((looking-at-p "^[ \t]*$") (point)) ;no result
((looking-at-p (format "^[ \t]*%s[ \t]*$" org-bracket-link-regexp))
(line-beginning-position 2))
- (t (save-excursion
- (goto-char
- (min (point-max) ;for narrowed buffers
- (org-element-property :end (org-element-at-point))))
- (skip-chars-backward " \r\t\n")
- (line-beginning-position 2)))))
+ (t
+ (let ((element (org-element-at-point)))
+ (if (memq (org-element-type element)
+ ;; Possible results types.
+ '(drawer export-block fixed-width item plain-list src-block
+ table))
+ (save-excursion
+ (goto-char (min (point-max) ;for narrowed buffers
+ (org-element-property :end element)))
+ (skip-chars-backward " \r\t\n")
+ (line-beginning-position 2))
+ (point))))))
(defun org-babel-result-to-file (result &optional description)
"Convert RESULT into an `org-mode' link with optional DESCRIPTION.