org-babel-where-is-src-block-result: Fix inside affiliated parsed keyword

* lisp/ob-core.el (org-babel-where-is-src-block-result): Do not assume
that parent has contents-end and that we are inside contents, but not
inside secondary object/affiliated keyword.
*
testing/lisp/test-ob.el (test-ob/inline-src_blk-default-results-replace-line-1):
Add tests.

Reported-by: Tom Gillespie <tgbugs@gmail.com>
Link: https://orgmode.org/list/CA+G3_PNt7WqkCzChV+dx1FeSPgTEVkNSE41a3qC5wv3g+jTwrQ@mail.gmail.com
This commit is contained in:
Ihor Radchenko 2023-08-16 11:07:20 +03:00
parent 54c09c84e9
commit 9fd547dd3a
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 17 additions and 6 deletions

View File

@ -2187,11 +2187,8 @@ to HASH."
((or `inline-babel-call `inline-src-block)
;; Results for inline objects are located right after them.
;; There is no RESULTS line to insert either.
(let ((limit (pcase (org-element-type (org-element-parent context))
(`section (org-element-end
(org-element-parent context)))
(_ (org-element-contents-end
(org-element-parent context))))))
(let ((limit (or (org-element-contents-end (org-element-parent context))
(org-element-end (org-element-parent context)))))
(goto-char (org-element-end context))
(skip-chars-forward " \t\n" limit)
(throw :found

View File

@ -404,7 +404,21 @@ at the beginning of a line."
"src_emacs-lisp{(+ 1 2)}\n{{{results(=3=)}}}"
(org-test-with-temp-text "src_emacs-lisp{(+ 1 2)}\n{{{results(=2=)}}}"
(let ((org-babel-inline-result-wrap "=%s=")) (org-babel-execute-maybe))
(buffer-string))))))
(buffer-string)))))
;; Handle inline src blocks inside parsed affiliated keyword.
(should
(equal
"#+caption: src_elisp{1} {{{results(=1=)}}}\n#+begin_src emacs-lisp\n1\n#+end_src"
(org-test-with-temp-text "#+caption: <point>src_elisp{1}\n#+begin_src emacs-lisp\n1\n#+end_src"
(let ((org-babel-inline-result-wrap "=%s=")) (org-babel-execute-maybe))
(buffer-string))))
;; Handle inline src blocks inside heading title.
(should
(equal
"* Heading src_elisp{1} {{{results(=1=)}}}"
(org-test-with-temp-text "* Heading <point>src_elisp{1}"
(let ((org-babel-inline-result-wrap "=%s=")) (org-babel-execute-maybe))
(buffer-string)))))
(ert-deftest test-ob/inline-src_blk-default-results-replace-line-2 ()
;; src_ at bol line 2...