From a4b1fa7ca1bf63075c29a89f1379a4726313db68 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 11 Jan 2014 10:12:45 +0100 Subject: [PATCH] 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. --- lisp/org-element.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index e6dcc6146..fdcbf8de0 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))