changeset 16315:cca1c6324cab

(imenu--cleanup): Handle shared structure in alist.
author Richard M. Stallman <rms@gnu.org>
date Tue, 24 Sep 1996 22:50:24 +0000
parents c72b7ee606a3
children 50be5f6cb5e6
files lisp/imenu.el
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/imenu.el	Tue Sep 24 21:19:03 1996 +0000
+++ b/lisp/imenu.el	Tue Sep 24 22:50:24 1996 +0000
@@ -469,16 +469,21 @@
       (setq imenu--index-alist (list nil)))
   ;; Add a rescan option to the index.
   (cons imenu--rescan-item imenu--index-alist))
-;;;
+
 ;;; Find all markers in alist and makes
 ;;; them point nowhere.
-;;;
+;;; The top-level call uses nil as the argument;
+;;; non-nil arguments are in recursivecalls.
+(defvar imenu--cleanup-seen)
+
 (defun imenu--cleanup (&optional alist)
-  ;; Sets the markers in imenu--index-alist 
-  ;; point nowhere.
-  ;; if alist is provided use that list.
-  (or alist
-      (setq alist imenu--index-alist))
+  ;; If alist is provided use that list. 
+  ;; If not, empty the table of lists already seen
+  ;; and use imenu--index-alist.
+  (if alist
+      (setq imenu--cleanup-seen (cons alist imenu--cleanup-seen))
+    (setq alist imenu--index-alist imenu--cleanup-seen (list alist)))
+
   (and alist
        (mapcar
 	(function
@@ -486,6 +491,8 @@
 	   (cond
 	    ((markerp (cdr item))
 	     (set-marker (cdr item) nil))
+	    ;; Don't process one alist twice.
+	    ((memq (cdr item) imenu--cleanup-seen))
 	    ((imenu--subalist-p item)
 	     (imenu--cleanup (cdr item))))))
 	alist)