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 1d8126385c.

Reported-by: Kaushal Modi <kaushal.modi@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2017-11/msg00384.html>
This commit is contained in:
Nicolas Goaziou 2017-11-27 23:23:04 +01:00
parent 5873d99121
commit d7940ae2a7
1 changed files with 12 additions and 6 deletions

View File

@ -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.