changeset 15929:955269257adf

(imenu--in-alist): Accept only bottom-level matches.
author Richard M. Stallman <rms@gnu.org>
date Mon, 26 Aug 1996 00:08:21 +0000
parents 2882af484d9c
children 811f16bdff08
files lisp/imenu.el
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/imenu.el	Sun Aug 25 23:31:20 1996 +0000
+++ b/lisp/imenu.el	Mon Aug 26 00:08:21 1996 +0000
@@ -493,11 +493,17 @@
 	    tail (cdr elt)
 	    alist (cdr alist) 
 	    head (car elt)) 
-      (if (string= str head)
-	  (setq alist nil res elt)
-	(if (and (listp tail)
-		 (setq res (imenu--in-alist str tail)))
-	    (setq alist nil))))
+      ;; A nested ALIST element looks like
+      ;;   (INDEX-NAME (INDEX-NAME . INDEX-POSITION) ...)
+      ;; while a bottom-level element looks like
+      ;;   (INDEX-NAME . INDEX-POSITION)
+      ;; We are only interested in the bottom-level elements, so we need to
+      ;; recurse if TAIL is a list.
+      (cond ((listp tail)
+	     (if (setq res (imenu--in-alist str tail))
+		 (setq alist nil)))
+	    ((string= str head)
+	     (setq alist nil res elt))))
     res))
 
 (defun imenu-default-create-index-function ()