branch: externals/org commit 791c2285e57a1c74f04c09f931d76c336f74d342 Author: Ihor Radchenko <yanta...@posteo.net> Commit: Ihor Radchenko <yanta...@posteo.net>
org-element-context: Do not return the last title object when on tags * lisp/org-element.el (org-element-context): When point is _after_ title (on tags), return headline. * testing/lisp/test-org-element.el (test-org-element/context): New test case. Reported-by: Miki Kawabe <inf73...@outlook.com> Link: https://orgmode.org/list/dm4pr11mb599571f25f6e7e324f902e6cbf...@dm4pr11mb5995.namprd11.prod.outlook.com --- lisp/org-element.el | 2 +- testing/lisp/test-org-element.el | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 12450bb10e..062141fcea 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -8604,7 +8604,7 @@ This function may modify match data." (goto-char (org-element-begin element)) (looking-at org-complex-heading-regexp) (let ((end (match-end 4))) - (if (not end) (throw 'objects-forbidden element) + (if (or (not end) (> pos end)) (throw 'objects-forbidden element) (goto-char (match-beginning 4)) (when (looking-at org-element-comment-string) (goto-char (match-end 0))) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 2e85df3634..817451d340 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -4780,6 +4780,11 @@ Text (eq 'underline (org-test-with-temp-text "* Headline _<point>with_ underlining" (org-element-type (org-element-context))))) + ;; Should not find objects in headline tags + (should-not + (eq 'timestamp + (org-test-with-temp-text "* Headline <2020-04-01> :tag1<point>:" + (org-element-type (org-element-context))))) ;; Find objects in objects. (should (eq 'macro