summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2014-01-09 08:26:51 (GMT)
committer Nicolas Goaziou <n.goaziou@gmail.com>2014-01-09 10:55:49 (GMT)
commitf75f3dd1c12f7f6fd51c46f9b31d03f3c39a49e1 (patch)
tree0a03cb41748ce4b7372757fd5d043eabaaa1772d
parente0f46e9a1da0d511ceac24202d26943fab653069 (diff)
downloadorg-mode-f75f3dd1c12f7f6fd51c46f9b31d03f3c39a49e1.zip
org-mode-f75f3dd1c12f7f6fd51c46f9b31d03f3c39a49e1.tar.gz
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.
-rw-r--r--lisp/org-element.el12
1 files changed, 6 insertions, 6 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 8eeb929..e6dcc61 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -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))))))))