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
;; higher ancestor not containing point.
(t
(let ((up cached))
(let ((up cached)
(origin (if (= (point-max) origin) (1- origin) origin)))
(goto-char (or (org-element-property :contents-begin cached)
begin))
(while (and up
(not (eobp))
(<= (org-element-property :end up) origin))
(goto-char (org-element-property :end up))
(setq up (org-element-property :parent up)))
(while (let ((end (org-element-property :end up)))
(and (<= end origin)
(goto-char end)
(setq up (org-element-property :parent up)))))
(cond ((not up))
((eobp) (setq element up))
(t (setq element up next (point))))))))