org-element: Fix `org-element-at-point' at eob

* lisp/org-element.el (org-element-at-point): Return appropriate value
  when point is at end of buffer and a cached element was found above.
This commit is contained in:
Nicolas Goaziou 2014-01-09 09:26:51 +01:00
parent e0f46e9a1d
commit f75f3dd1c1
1 changed files with 6 additions and 6 deletions

View File

@ -4789,14 +4789,14 @@ element ending there."
;; parsing from NEXT, which is located after CACHED or its ;; parsing from NEXT, which is located after CACHED or its
;; higher ancestor not containing point. ;; higher ancestor not containing point.
(t (t
(let ((up cached)) (let ((up cached)
(origin (if (= (point-max) origin) (1- origin) origin)))
(goto-char (or (org-element-property :contents-begin cached) (goto-char (or (org-element-property :contents-begin cached)
begin)) begin))
(while (and up (while (let ((end (org-element-property :end up)))
(not (eobp)) (and (<= end origin)
(<= (org-element-property :end up) origin)) (goto-char end)
(goto-char (org-element-property :end up)) (setq up (org-element-property :parent up)))))
(setq up (org-element-property :parent up)))
(cond ((not up)) (cond ((not up))
((eobp) (setq element up)) ((eobp) (setq element up))
(t (setq element up next (point)))))))) (t (setq element up next (point))))))))