More tweaks of skeleton documentation wrt \n behavior at bol/eol.
[bpt/emacs.git] / lisp / imenu.el
index f41fcda..e5f33a5 100644 (file)
@@ -1,10 +1,10 @@
 ;;; imenu.el --- framework for mode-specific buffer indexes  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1994-1998, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1998, 2001-2014 Free Software Foundation, Inc.
 
 ;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se>
 ;;         Lars Lindberg <lli@sypro.cap.se>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Created: 8 Feb 1994
 ;; Keywords: tools convenience
 
@@ -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.
@@ -461,7 +463,7 @@ Special elements look like (INDEX-NAME POSITION FUNCTION ARGUMENTS...).
 To \"go to\" a special element means applying FUNCTION
 to INDEX-NAME, POSITION, and the ARGUMENTS.
 
-A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).
+A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).
 The function `imenu--subalist-p' tests an element and returns t
 if it is a sub-alist.
 
@@ -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
@@ -722,8 +726,12 @@ for modes which use `imenu--generic-function'.  If it is not set, but
 ;; so it needs to be careful never to loop!
 (defun imenu--generic-function (patterns)
   "Return an index alist of the current buffer based on PATTERNS.
-PATTERNS should be an alist which has the same form as
-`imenu-generic-expression'.
+PATTERNS should be an alist with the same form as `imenu-generic-expression'.
+
+If `imenu-generic-skip-comments-and-strings' is non-nil, this ignores
+text inside comments and strings.
+
+If `imenu-case-fold-search' is non-nil, this ignores case.
 
 The return value is an alist of the form
  (INDEX-NAME . INDEX-POSITION)
@@ -1033,8 +1041,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)