From 8396299d26c6901fa2cfba2b09ae819a9bb6e6af Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Mon, 26 Aug 1996 00:08:21 +0000 Subject: [PATCH] (imenu--in-alist): Accept only bottom-level matches. --- lisp/imenu.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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 () -- 2.39.2