diff --git a/lisp/org-element.el b/lisp/org-element.el index 564a434a8..0037f0386 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -4736,7 +4736,7 @@ first element of current section." ;; In blank lines just after the headline, point still ;; belongs to the headline. (throw 'exit - (progn (org-back-to-heading) + (progn (skip-chars-backward " \r\t\n") (if (not keep-trail) (org-element-headline-parser (point-max) t) (list (org-element-headline-parser diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index feb70d2ff..bc2b5aa13 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -2819,6 +2819,12 @@ Paragraph \\alpha." (progn (search-forward "A") (org-element-type (org-element-property :parent (org-element-at-point))))))) + ;; Special case: at a blank line just below a headline, return that + ;; headline. + (should + (equal "H1" (org-test-with-temp-text "* H1\n \n* H2\n" + (forward-line) + (org-element-property :title (org-element-at-point))))) ;; Special case: at the very beginning of a table, return `table' ;; object instead of `table-row'. (should