org-element: Fix cache when point is at eob

* lisp/org-element.el (org-element-at-point): Fix cache when point is
  at eob and shortcut found something above.
This commit is contained in:
Nicolas Goaziou 2013-12-30 14:02:25 +01:00
parent 405b505c73
commit fde42c5303
1 changed files with 7 additions and 8 deletions

View File

@ -5252,20 +5252,19 @@ first row."
;; check. Otherwise, move at top level and start
;; parsing right after its broader ancestor.
(let ((cache-end (org-element-property :end cached)))
(if (or (> cache-end origin)
(and (= cache-end origin) (= (point-max) origin)))
(if (> cache-end origin)
(setq element cached
parent (org-element-property :parent cached)
end cache-end)
(goto-char cache-end)
(let ((up cached))
(let ((up cached) (last cached))
(while (and (setq up (org-element-property :parent up))
(<= (org-element-property :end up) origin))
(goto-char (org-element-property :end up)))
(when up
(setq element up
parent (org-element-property :parent up)
end (org-element-property :end up))))))
(goto-char (org-element-property :end up))
(setq last up))
(setq element (or up last)
parent (org-element-property :parent up)
end (org-element-property :end up)))))
(throw 'loop nil)))))
;; Opportunistic search failed. Move back to beginning of
;; section in current headline, if any, or to first non-empty