From: Richard M. Stallman Date: Mon, 26 Aug 1996 00:08:21 +0000 (+0000) Subject: (imenu--in-alist): Accept only bottom-level matches. X-Git-Tag: emacs-20.1~4015 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8396299d26c6901fa2cfba2b09ae819a9bb6e6af;p=emacs.git (imenu--in-alist): Accept only bottom-level matches. --- diff --git a/lisp/imenu.el b/lisp/imenu.el index bc9e8669369..b62b650e5e6 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -493,11 +493,17 @@ This function is called after the function pointed out by 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 ()