From af9c0fbf9143883ce31478a137a60cc69428d4d4 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 11 Sep 2013 12:22:05 +0200 Subject: [PATCH] org-element: Fix bug in `org-element-at-point' * lisp/org-element.el (org-element-at-point): Return correct element when point is on a blank line just below a headline. * testing/lisp/test-org-element.el: Add test. --- lisp/org-element.el | 2 +- testing/lisp/test-org-element.el | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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