ob-core: Fix Invalid search bound (wrong side of point)

* lisp/ob-core.el (org-babel-where-is-src-block-result): Return nil when
  anonymous results would be located outside of the container of the
  source block.

* testing/lisp/test-ob.el (test-ob/where-is-src-block-result): Add test.

Reported-by: Dominik Schrempf <dominik.schrempf@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/105309>
This commit is contained in:
Nicolas Goaziou 2016-02-25 14:53:00 +01:00
parent 5660047846
commit 0f3cb188a9
2 changed files with 12 additions and 3 deletions

View file

@ -1962,11 +1962,16 @@ to HASH."
;; Named results expect but none to be found.
(name)
;; No possible anonymous results at the very end of
;; buffer.
((eobp))
;; buffer or outside CONTEXT parent.
((eq (point)
(or (org-element-property
:contents-end (org-element-property :parent context))
(point-max))))
;; Check if next element is an anonymous result below
;; the current block.
((let* ((next (org-element-at-point))
((let* ((next (save-excursion
(skip-chars-forward " \t\n")
(org-element-at-point)))
(end (save-excursion
(goto-char
(org-element-property :post-affiliated next))

View file

@ -1623,6 +1623,10 @@ echo \"$data\"
(should-not
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
(org-babel-where-is-src-block-result)))
(should-not
(org-test-with-temp-text
"- item\n #+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC\n\n"
(org-babel-where-is-src-block-result)))
;; When optional argument INSERT is non-nil, add RESULTS keyword
;; whenever no RESULTS can be found.
(should