aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/imenu.el105
2 files changed, 61 insertions, 57 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 812738145b3..5a73c6c747a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,7 +1,16 @@
12003-05-16 Stefan Monnier <monnier@cs.yale.edu>
2
3 * imenu.el (imenu--split-menu): Remove unused var `count'.
4 Don't copy the sequence since we're already modifying it elsewhere.
5 (imenu--create-keymap): Rename from imenu--create-keymap-1.
6 Add optional `cmd' argument. Remove unused var `counter'.
7 (imenu-update-menubar): Use the new arg to keep the old behavior.
8 (imenu--mouse-menu): Don't use the arg, to recover the lost behavior.
9
12003-05-16 Lute Kamstra <Lute.Kamstra@cwi.nl> 102003-05-16 Lute Kamstra <Lute.Kamstra@cwi.nl>
2 11
3 * hl-line.el (hl-line-highlight, global-hl-line-highlight): Use 12 * hl-line.el (hl-line-highlight, global-hl-line-highlight):
4 `line-beginning-position' to determine the beginning of the next 13 Use `line-beginning-position' to determine the beginning of the next
5 line. 14 line.
6 15
72003-05-16 Kenichi Handa <handa@m17n.org> 162003-05-16 Kenichi Handa <handa@m17n.org>
diff --git a/lisp/imenu.el b/lisp/imenu.el
index a27243d0c18..f4c378a5e15 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -1,6 +1,6 @@
1;;; imenu.el --- framework for mode-specific buffer indexes 1;;; imenu.el --- framework for mode-specific buffer indexes
2 2
3;; Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 2003 Free Software Foundation, Inc.
4 4
5;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se> 5;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se>
6;; Lars Lindberg <lli@sypro.cap.se> 6;; Lars Lindberg <lli@sypro.cap.se>
@@ -527,22 +527,17 @@ This variable is local in all buffers, once set.")
527 menulist (delq imenu--rescan-item menulist))) 527 menulist (delq imenu--rescan-item menulist)))
528 (setq tail menulist) 528 (setq tail menulist)
529 (dolist (item tail) 529 (dolist (item tail)
530 (if (imenu--subalist-p item) 530 (when (imenu--subalist-p item)
531 (setq keep-at-top (cons item keep-at-top) 531 (push item keep-at-top)
532 menulist (delq item menulist)))) 532 (setq menulist (delq item menulist))))
533 (if imenu-sort-function 533 (if imenu-sort-function
534 (setq menulist 534 (setq menulist (sort menulist imenu-sort-function)))
535 (sort
536 (copy-sequence menulist)
537 imenu-sort-function)))
538 (if (> (length menulist) imenu-max-items) 535 (if (> (length menulist) imenu-max-items)
539 (let ((count 0)) 536 (setq menulist
540 (setq menulist 537 (mapcar
541 (mapcar 538 (lambda (menu)
542 (function 539 (cons (format "From: %s" (caar menu)) menu))
543 (lambda (menu) 540 (imenu--split menulist imenu-max-items))))
544 (cons (format "From: %s" (caar menu)) menu)))
545 (imenu--split menulist imenu-max-items)))))
546 (cons title 541 (cons title
547 (nconc (nreverse keep-at-top) menulist)))) 542 (nconc (nreverse keep-at-top) menulist))))
548 543
@@ -634,19 +629,18 @@ as a way for the user to ask to recalculate the buffer's index alist."
634 alist) 629 alist)
635 t)) 630 t))
636 631
637(defun imenu--create-keymap-1 (title alist) 632(defun imenu--create-keymap (title alist &optional cmd)
638 (let ((counter 0)) 633 (list* 'keymap title
639 (list* 'keymap title 634 (mapcar
640 (mapcar 635 (lambda (item)
641 (lambda (item) 636 (list* (car item) (car item)
642 (list* (car item) (car item) 637 (cond
643 (cond 638 ((imenu--subalist-p item)
644 ((imenu--subalist-p item) 639 (imenu--create-keymap (car item) (cdr item) cmd))
645 (imenu--create-keymap-1 (car item) (cdr item))) 640 (t
646 (t 641 `(lambda () (interactive)
647 `(lambda () (interactive) 642 ,(if cmd `(,cmd ',item) (list 'quote item)))))))
648 (imenu--menubar-select ',item)))))) 643 alist)))
649 alist))))
650 644
651(defun imenu--in-alist (str alist) 645(defun imenu--in-alist (str alist)
652 "Check whether the string STR is contained in multi-level ALIST." 646 "Check whether the string STR is contained in multi-level ALIST."
@@ -717,25 +711,25 @@ Their results are gathered into an index alist."
717 (error "This buffer cannot use `imenu-default-create-index-function'")))) 711 (error "This buffer cannot use `imenu-default-create-index-function'"))))
718 712
719;; Not used and would require cl at run time 713;; Not used and would require cl at run time
720;;; (defun imenu--flatten-index-alist (index-alist &optional concat-names prefix) 714;; (defun imenu--flatten-index-alist (index-alist &optional concat-names prefix)
721;;; ;; Takes a nested INDEX-ALIST and returns a flat index alist. 715;; ;; Takes a nested INDEX-ALIST and returns a flat index alist.
722;;; ;; If optional CONCAT-NAMES is non-nil, then a nested index has its 716;; ;; If optional CONCAT-NAMES is non-nil, then a nested index has its
723;;; ;; name and a space concatenated to the names of the children. 717;; ;; name and a space concatenated to the names of the children.
724;;; ;; Third argument PREFIX is for internal use only. 718;; ;; Third argument PREFIX is for internal use only.
725;;; (mapcan 719;; (mapcan
726;;; (lambda (item) 720;; (lambda (item)
727;;; (let* ((name (car item)) 721;; (let* ((name (car item))
728;;; (pos (cdr item)) 722;; (pos (cdr item))
729;;; (new-prefix (and concat-names 723;; (new-prefix (and concat-names
730;;; (if prefix 724;; (if prefix
731;;; (concat prefix imenu-level-separator name) 725;; (concat prefix imenu-level-separator name)
732;;; name)))) 726;; name))))
733;;; (cond 727;; (cond
734;;; ((or (markerp pos) (numberp pos)) 728;; ((or (markerp pos) (numberp pos))
735;;; (list (cons new-prefix pos))) 729;; (list (cons new-prefix pos)))
736;;; (t 730;; (t
737;;; (imenu--flatten-index-alist pos new-prefix))))) 731;; (imenu--flatten-index-alist pos new-prefix)))))
738;;; index-alist)) 732;; index-alist))
739 733
740;;; 734;;;
741;;; Generic index gathering function. 735;;; Generic index gathering function.
@@ -905,10 +899,10 @@ INDEX-ALIST is the buffer index and EVENT is a mouse event.
905Returns t for rescan and otherwise an element or subelement of INDEX-ALIST." 899Returns t for rescan and otherwise an element or subelement of INDEX-ALIST."
906 (setq index-alist (imenu--split-submenus index-alist)) 900 (setq index-alist (imenu--split-submenus index-alist))
907 (let* ((menu (imenu--split-menu index-alist (or title (buffer-name)))) 901 (let* ((menu (imenu--split-menu index-alist (or title (buffer-name))))
908 (map (imenu--create-keymap-1 (car menu) 902 (map (imenu--create-keymap (car menu)
909 (if (< 1 (length (cdr menu))) 903 (cdr (if (< 1 (length (cdr menu)))
910 (cdr menu) 904 menu
911 (cdr (car (cdr menu))))))) 905 (car (cdr menu)))))))
912 (popup-menu map event))) 906 (popup-menu map event)))
913 907
914(defun imenu-choose-buffer-index (&optional prompt alist) 908(defun imenu-choose-buffer-index (&optional prompt alist)
@@ -1001,10 +995,11 @@ This value becomes local in every buffer when it is set.")
1001 (setq index-alist (imenu--split-submenus index-alist)) 995 (setq index-alist (imenu--split-submenus index-alist))
1002 (setq menu (imenu--split-menu index-alist 996 (setq menu (imenu--split-menu index-alist
1003 (buffer-name))) 997 (buffer-name)))
1004 (setq menu1 (imenu--create-keymap-1 (car menu) 998 (setq menu1 (imenu--create-keymap (car menu)
1005 (if (< 1 (length (cdr menu))) 999 (cdr (if (< 1 (length (cdr menu)))
1006 (cdr menu) 1000 menu
1007 (cdr (car (cdr menu)))))) 1001 (car (cdr menu))))
1002 'imenu--menubar-select))
1008 (setq old (lookup-key (current-local-map) [menu-bar index])) 1003 (setq old (lookup-key (current-local-map) [menu-bar index]))
1009 (setcdr old (cdr menu1))))))) 1004 (setcdr old (cdr menu1)))))))
1010 1005