From 0f3cb188a9c76dc3207a08ab498e6d5814eeadc6 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 25 Feb 2016 14:53:00 +0100 Subject: [PATCH] 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 --- lisp/ob-core.el | 11 ++++++++--- testing/lisp/test-ob.el | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index c31869912..81687060d 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -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)) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index e686ae675..31b8ef29e 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -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