Browse Source

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.
Nicolas Goaziou 11 years ago
parent
commit
af9c0fbf91
2 changed files with 7 additions and 1 deletions
  1. 1 1
      lisp/org-element.el
  2. 6 0
      testing/lisp/test-org-element.el

+ 1 - 1
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

+ 6 - 0
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