]> code.delx.au - gnu-emacs/blobdiff - lisp/imenu.el
Document what does mouse-3 do on the mode line if there's only one window.
[gnu-emacs] / lisp / imenu.el
index eb7dc042e68a5cf782fc3d92ad2cee320ba2874d..3f3a174abf643e659be2fd317007689ab5a26e6c 100644 (file)
@@ -557,15 +557,18 @@ This variable is local in all buffers, once set.")
 
 ;;; Truncate all strings in MENULIST to imenu-max-item-length
 (defun imenu--truncate-items (menulist)
-  (dolist (item menulist)
-    (cond
-     ((consp (cdr item))
-      (imenu--truncate-items (cdr item)))
-     (t
-      ;; truncate if necessary
-      (if (and (numberp imenu-max-item-length)
-              (> (length (car item)) imenu-max-item-length))
-         (setcar item (substring (car item) 0 imenu-max-item-length)))))))
+  (mapcar (function
+          (lambda (item)
+            (cond
+             ((consp (cdr item))
+              (imenu--truncate-items (cdr item)))
+             (t
+              ;; truncate if necessary
+              (if (and (numberp imenu-max-item-length)
+                       (> (length (car item)) imenu-max-item-length))
+                  (setcar item (substring (car item) 0
+                                          imenu-max-item-length)))))))
+         menulist))
 
 
 (defun imenu--make-index-alist (&optional noerror)
@@ -631,26 +634,26 @@ as a way for the user to ask to recalculate the buffer's index alist."
 (defun imenu--create-keymap-2 (alist counter &optional commands)
   (let ((map nil))
     (mapcar
-     (function
-      (lambda (item)
-       (cond
-        ((imenu--subalist-p item)
-         (append (list (setq counter (1+ counter))
-                       (car item) 'keymap (car item))
-                 (imenu--create-keymap-2 (cdr item) (+ counter 10) commands)))
-        (t
-         (let ((end (if commands `(lambda () (interactive)
-                                    (imenu--menubar-select ',item))
-                      (cons '(nil) item))))
-           (cons (car item)
-                 (cons (car item) end)))))))
+     (lambda (item)
+       (cond
+       ((imenu--subalist-p item)
+        (nconc (list (setq counter (1+ counter))
+                     (car item) 'keymap (car item))
+               (imenu--create-keymap-2 (cdr item) (+ counter 10) commands)))
+       (t
+        (let ((end (if commands `(lambda ()
+                                   (interactive)
+                                   (imenu--menubar-select ',item))
+                     (cons '(nil) item))))
+          (cons (car item)
+                (list 'menu-item (car item) end :key-sequence nil))))))
      alist)))
 
 ;; If COMMANDS is non-nil, make a real keymap
 ;; with a real command used as the definition.
 ;; If it is nil, make something suitable for x-popup-menu.
 (defun imenu--create-keymap-1 (title alist &optional commands)
-  (append (list 'keymap title) (imenu--create-keymap-2 alist 0 commands)))
+  (cons 'keymap (cons title (imenu--create-keymap-2 alist 0 commands))))
 
 (defun imenu--in-alist (str alist)
   "Check whether the string STR is contained in multi-level ALIST."
@@ -686,6 +689,7 @@ a string, all the characters in the string get the specified syntax.
 This is typically used to give word syntax to characters which
 normally have symbol syntax to simplify `imenu-expression'
 and speed-up matching.")
+;;;###autoload
 (make-variable-buffer-local 'imenu-syntax-alist)
 
 (defun imenu-default-create-index-function ()