]> code.delx.au - gnu-emacs/blobdiff - lisp/imenu.el
* net/tramp-cache.el (tramp-connection-properties): New customer option.
[gnu-emacs] / lisp / imenu.el
index c2a80d6967503fafb7d907a300ae7251de97fc1d..c1077a49d1a08d23643b77918639438ecd35e668 100644 (file)
@@ -1,6 +1,6 @@
 ;;; imenu.el --- framework for mode-specific buffer indexes  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1994-1998, 2001-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1998, 2001-2013 Free Software Foundation, Inc.
 
 ;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se>
 ;;         Lars Lindberg <lli@sypro.cap.se>
@@ -326,6 +326,7 @@ PREVPOS is the variable in which we store the last position displayed."
 (defun imenu-example--name-and-position ()
   "Return the current/previous sexp and its (beginning) location.
 Don't move point."
+  (declare (obsolete "use your own function instead." "23.2"))
   (save-excursion
     (forward-sexp -1)
     ;; [ydi] modified for imenu-use-markers
@@ -333,8 +334,6 @@ Don't move point."
          (end (progn (forward-sexp) (point))))
       (cons (buffer-substring beg end)
            beg))))
-(make-obsolete 'imenu-example--name-and-position
-              "use your own function instead." "23.2")
 
 ;;;
 ;;; Lisp
@@ -343,6 +342,7 @@ Don't move point."
 (defun imenu-example--lisp-extract-index-name ()
   ;; Example of a candidate for `imenu-extract-index-name-function'.
   ;; This will generate a flat index of definitions in a lisp file.
+  (declare (obsolete nil "23.2"))
   (save-match-data
     (and (looking-at "(def")
         (condition-case nil
@@ -353,11 +353,11 @@ Don't move point."
                     (end (progn (forward-sexp -1) (point))))
                 (buffer-substring beg end)))
           (error nil)))))
-(make-obsolete 'imenu-example--lisp-extract-index-name "your own" "23.2")
 
 (defun imenu-example--create-lisp-index ()
   ;; Example of a candidate for `imenu-create-index-function'.
   ;; It will generate a nested index of definitions.
+  (declare (obsolete nil "23.2"))
   (let ((index-alist '())
        (index-var-alist '())
        (index-type-alist '())
@@ -401,7 +401,6 @@ Don't move point."
         (push (cons "Syntax-unknown" index-unknown-alist)
               index-alist))
     index-alist))
-(make-obsolete 'imenu-example--create-lisp-index "your own" "23.2")
 
 ;; Regular expression to find C functions
 (defvar imenu-example--function-name-regexp-c
@@ -414,6 +413,7 @@ Don't move point."
    ))
 
 (defun imenu-example--create-c-index (&optional regexp)
+  (declare (obsolete nil "23.2"))
   (let ((index-alist '())
        char)
     (goto-char (point-min))
@@ -430,7 +430,6 @@ Don't move point."
        (if (not (eq char ?\;))
            (push (imenu-example--name-and-position) index-alist))))
     (nreverse index-alist)))
-(make-obsolete 'imenu-example--create-c-index "your own" "23.2")
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
@@ -448,6 +447,8 @@ Don't move point."
 Simple elements in the alist look like (INDEX-NAME . POSITION).
 POSITION is the buffer position of the item; to go to the item
 is simply to move point to that position.
+POSITION is passed to `imenu-default-goto-function', so it can be a non-number
+if that variable has been changed (e.g. Semantic uses overlays for POSITIONs).
 
 Special elements look like (INDEX-NAME POSITION FUNCTION ARGUMENTS...).
 To \"go to\" a special element means applying FUNCTION
@@ -547,25 +548,21 @@ The returned alist DOES NOT share structure with MENULIST."
 Return a split and sorted copy of ALIST.  The returned alist DOES
 NOT share structure with ALIST."
   (mapcar (lambda (elt)
-            (if (and (consp elt)
-                     (stringp (car elt))
-                     (listp (cdr elt)))
+            (if (imenu--subalist-p elt)
                 (imenu--split-menu (cdr elt) (car elt))
               elt))
          alist))
 
 (defun imenu--truncate-items (menulist)
   "Truncate all strings in MENULIST to `imenu-max-item-length'."
-  (mapcar (lambda (item)
-            (cond
-             ((consp (cdr item))
-              (imenu--truncate-items (cdr item)))
-             ;; truncate if necessary
-             ((and (numberp imenu-max-item-length)
-                   (> (length (car item)) imenu-max-item-length))
-              (setcar item (substring (car item) 0 imenu-max-item-length)))))
-         menulist))
-
+  (mapc (lambda (item)
+         ;; truncate if necessary
+         (when (and (numberp imenu-max-item-length)
+                    (> (length (car item)) imenu-max-item-length))
+           (setcar item (substring (car item) 0 imenu-max-item-length)))
+         (when (imenu--subalist-p item)
+           (imenu--truncate-items (cdr item))))
+       menulist))
 
 (defun imenu--make-index-alist (&optional noerror)
   "Create an index alist for the definitions in the current buffer.
@@ -679,12 +676,12 @@ The alternate method, which is the one most often used, is to call
   ;; in these major modes.  But save that change for later.
   (cond ((and imenu-prev-index-position-function
              imenu-extract-index-name-function)
-        (let ((index-alist '()) (pos (point))
+        (let ((index-alist '()) (pos (point-max))
               name)
-          (goto-char (point-max))
+          (goto-char pos)
           ;; Search for the function
           (while (funcall imenu-prev-index-position-function)
-             (when (= pos (point))
+             (unless (< (point) pos)
                (error "Infinite loop at %s:%d: imenu-prev-index-position-function does not move point" (buffer-name) pos))
              (setq pos (point))
             (save-excursion
@@ -1019,7 +1016,7 @@ for more information."
   (if (stringp index-item)
       (setq index-item (assoc index-item (imenu--make-index-alist))))
   (when index-item
-    (push-mark)
+    (push-mark nil t)
     (let* ((is-special-item (listp (cdr index-item)))
           (function
            (if is-special-item