From 34edfd846f63e5e3ecbb0f9f95cdb5560b1c7454 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 21 Jan 2014 18:14:37 +0100 Subject: [PATCH] org-element: Preserve Emacs 23 compatibility * lisp/org-element.el (org-element--cache-mapc): New function. (org-element--cache-sync): Use new function. `avl-tree-mapc' exists in Emacs 24's "avl-tree" but not in Emacs 23's. The new function implements it. --- lisp/org-element.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index fc204f308..0027f1fe4 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -5436,6 +5436,16 @@ Properties are modified by side-effect. Return ELEMENT." (and value (plist-put properties key (+ offset value)))))) element) +(defun org-element--cache-mapc (__map-function__ &optional reverse) + "Apply FUNCTION to all elements in cache. +FUNCTION is applied to the elements in ascending order, or +descending order if REVERSE is non-nil." + (avl-tree--mapc + #'(lambda (node) + (funcall __map-function__ (avl-tree--node-data node))) + (org-element--cache-root) + (if reverse 1 0))) + (defun org-element--cache-sync (buffer) "Synchronize cache with recent modification in BUFFER. Elements ending before modification area are kept in cache. @@ -5553,7 +5563,7 @@ removed from the cache." ;; before END. (unless (zerop offset) (catch 'exit - (avl-tree-mapc + (org-element--cache-mapc #'(lambda (data) (if (<= (org-element-property :begin data) end) (throw 'exit t) @@ -5568,7 +5578,7 @@ removed from the cache." (dolist (object (cddr object-data)) (org-element--cache-shift-positions object offset))))) - org-element--cache 'reverse))))) + 'reverse))))) ;; Eventually signal cache as up-to-date. (org-element--cache-cancel-changes)))))