From c8f0efc2e89d9cfc7befa7f20f584f3f0b12f487 Mon Sep 17 00:00:00 2001 From: Andreas Politz Date: Fri, 29 Nov 2013 05:38:20 +0200 Subject: [PATCH] * doc/lispref/modes.texi (Imenu): Make it clear that sub-alist is the cdr. * lisp/imenu.el (imenu--subalist-p): Don't error on non-conses and allow non-lambda lists as functions. (imenu--in-alist): Don't recurse into non-subalists. (imenu): Don't pass function itself as an argument. Fixes: debbugs:14029 --- doc/lispref/ChangeLog | 5 +++++ doc/lispref/modes.texi | 2 +- lisp/ChangeLog | 6 ++++++ lisp/imenu.el | 16 ++++++++++------ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index ba7fe63a1b5..59e61bbdc74 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,8 @@ +2013-11-29 Andreas Politz + + * modes.texi (Imenu): Make it clear that sub-alist is the cdr + (Bug#14029). + 2013-11-27 Glenn Morris * loading.texi (Library Search): diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 180fef7241d..dc643bda9c8 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -2483,7 +2483,7 @@ Selecting a special element performs: A nested sub-alist element looks like this: @example -(@var{menu-title} @var{sub-alist}) +(@var{menu-title} . @var{sub-alist}) @end example It creates the submenu @var{menu-title} specified by @var{sub-alist}. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6e1e8d17fee..ab72f160670 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-11-29 Andreas Politz + * imenu.el (imenu--subalist-p): Don't error on non-conses and + allow non-lambda lists as functions. + (imenu--in-alist): Don't recurse into non-subalists. + (imenu): Don't pass function itself as an argument (Bug#14029). + 2013-11-29 Stefan Monnier * progmodes/python.el (python-mode-map): Remove binding for ":". diff --git a/lisp/imenu.el b/lisp/imenu.el index f41fcda2713..5e03a3a9081 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -293,8 +293,10 @@ The function in this variable is called when selecting a normal index-item.") (defun imenu--subalist-p (item) - (and (consp (cdr item)) (listp (cadr item)) - (not (eq (car (cadr item)) 'lambda)))) + (and (consp item) + (consp (cdr item)) + (listp (cadr item)) + (not (functionp (cadr item))))) (defmacro imenu-progress-message (_prevpos &optional _relpos _reverse) "Macro to display a progress message. @@ -645,9 +647,11 @@ Non-nil arguments are in recursive calls." ;; (INDEX-NAME (INDEX-NAME . INDEX-POSITION) ...) ;; while a bottom-level element looks like ;; (INDEX-NAME . INDEX-POSITION) + ;; or + ;; (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...) ;; We are only interested in the bottom-level elements, so we need to - ;; recurse if TAIL is a list. - (cond ((listp tail) + ;; recurse if TAIL is a nested ALIST. + (cond ((imenu--subalist-p elt) (if (setq res (imenu--in-alist str tail)) (setq alist nil))) ((if imenu-name-lookup-function @@ -1033,8 +1037,8 @@ for more information." (nth 2 index-item) imenu-default-goto-function)) (position (if is-special-item (cadr index-item) (cdr index-item))) - (rest (if is-special-item (cddr index-item)))) - (apply function (car index-item) position rest)) + (args (if is-special-item (cdr (cddr index-item))))) + (apply function (car index-item) position args)) (run-hooks 'imenu-after-jump-hook))) (provide 'imenu) -- 2.11.4.GIT