diff options
authorNicolas Goaziou <>2014-01-11 09:12:45 (GMT)
committer Nicolas Goaziou <>2014-01-11 09:12:45 (GMT)
commita4b1fa7ca1bf63075c29a89f1379a4726313db68 (patch)
parent525304cbdae5fdd13c661f6d0400a378ca47deef (diff)
org-element: New accessor for cache root
* lisp/org-element.el (org-element--cache-root): New function. (org-element--cache-sync, org-element-cache-get): Use new function. This is a workaround for `avl-tree--root' bug before Emacs 24. Thanks to Daniel Clemente for reporting it.
1 files changed, 7 insertions, 2 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index e6dcc61..fdcbf8d 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -5220,6 +5220,11 @@ This cache is used in `org-element-context'.")
(memq (org-element-type a) '(plain-list table))
(memq (org-element-type b) '(item table-row))))))
+(defsubst org-element--cache-root ()
+ "Return root value in cache.
+This function assumes `org-element--cache' is a valid AVL tree."
+ (avl-tree--node-left (avl-tree--dummyroot org-element--cache)))
;;;; Staging Buffer Changes
@@ -5506,7 +5511,7 @@ removed from the cache."
(if (< (org-element-property :end element) beg)
(org-element-property :end element)
(org-element-property :begin element))))))))
- (while (let ((node (avl-tree--root org-element--cache)) data)
+ (while (let ((node (org-element--cache-root)) data)
;; DATA will contain the closest element from
;; BEG, always after it.
(while node
@@ -5589,7 +5594,7 @@ cache, unless optional argument IGNORE-CHANGES is non-nil."
(when (and (not ignore-changes) (org-element--cache-pending-changes-p))
(org-element--cache-sync (current-buffer)))
(if (not (wholenump key)) (gethash key org-element--cache-objects)
- (let ((node (avl-tree--root org-element--cache)) last)
+ (let ((node (org-element--cache-root)) last)
(catch 'found
(while node
(let* ((element (avl-tree--node-data node))