diff options
| author | Richard M. Stallman | 1996-03-01 18:09:57 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-03-01 18:09:57 +0000 |
| commit | 0c20ee618777e8f4b04cf2fe004a47b156e9cff9 (patch) | |
| tree | 5d9ed7185652bfd5a29e608e54f7a0e1738f6498 | |
| parent | df41821fa7e3aae5b2ea37c1aa24d5172ecf377e (diff) | |
| download | emacs-0c20ee618777e8f4b04cf2fe004a47b156e9cff9.tar.gz emacs-0c20ee618777e8f4b04cf2fe004a47b156e9cff9.zip | |
(imenu--menubar-select): No longer interactive.
(imenu-create-submenu-name): Function deleted.
(imenu-example--create-lisp-index): Don't use it.
(imenu--generic-function): Don't use imenu-create-submenu-name.
(imenu-submenu-name-format): Variable deleted.
(imenu--split-menu): Use TITLE as the head of the new list.
Don't split if everything fits in one level.
(imenu--split-submenus): New function.
(imenu-update-menubar): Use imenu--split-submenus.
(imenu--mouse-menu): Use imenu--split-submenus.
| -rw-r--r-- | lisp/imenu.el | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el index 8317946294d..4690c71aaf5 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el | |||
| @@ -98,7 +98,7 @@ element should come before the second. The arguments are cons cells; | |||
| 98 | \(NAME . POSITION). Look at `imenu--sort-by-name' for an example.") | 98 | \(NAME . POSITION). Look at `imenu--sort-by-name' for an example.") |
| 99 | 99 | ||
| 100 | (defvar imenu-max-items 25 | 100 | (defvar imenu-max-items 25 |
| 101 | "*Maximum number of elements in an index mouse-menu.") | 101 | "*Maximum number of elements in an mouse menu for Imenu.") |
| 102 | 102 | ||
| 103 | (defvar imenu-scanning-message "Scanning buffer for index (%3d%%)" | 103 | (defvar imenu-scanning-message "Scanning buffer for index (%3d%%)" |
| 104 | "*Progress message during the index scanning of the buffer. | 104 | "*Progress message during the index scanning of the buffer. |
| @@ -117,9 +117,6 @@ names work as tokens.") | |||
| 117 | Used for making mouse-menu titles and for flattening nested indexes | 117 | Used for making mouse-menu titles and for flattening nested indexes |
| 118 | with name concatenation.") | 118 | with name concatenation.") |
| 119 | 119 | ||
| 120 | (defvar imenu-submenu-name-format "%s" | ||
| 121 | "*The format for making a submenu name.") | ||
| 122 | |||
| 123 | ;;;###autoload | 120 | ;;;###autoload |
| 124 | (defvar imenu-generic-expression nil | 121 | (defvar imenu-generic-expression nil |
| 125 | "The regex pattern to use for creating a buffer index. | 122 | "The regex pattern to use for creating a buffer index. |
| @@ -282,13 +279,13 @@ This function is called after the function pointed out by | |||
| 282 | index-unknown-alist))))))) | 279 | index-unknown-alist))))))) |
| 283 | (imenu-progress-message prev-pos 100) | 280 | (imenu-progress-message prev-pos 100) |
| 284 | (and index-var-alist | 281 | (and index-var-alist |
| 285 | (push (cons (imenu-create-submenu-name "Variables") index-var-alist) | 282 | (push (cons "Variables" index-var-alist) |
| 286 | index-alist)) | 283 | index-alist)) |
| 287 | (and index-type-alist | 284 | (and index-type-alist |
| 288 | (push (cons (imenu-create-submenu-name "Types") index-type-alist) | 285 | (push (cons "Types" index-type-alist) |
| 289 | index-alist)) | 286 | index-alist)) |
| 290 | (and index-unknown-alist | 287 | (and index-unknown-alist |
| 291 | (push (cons (imenu-create-submenu-name "Syntax-unknown") index-unknown-alist) | 288 | (push (cons "Syntax-unknown" index-unknown-alist) |
| 292 | index-alist)) | 289 | index-alist)) |
| 293 | index-alist)) | 290 | index-alist)) |
| 294 | 291 | ||
| @@ -372,14 +369,6 @@ This function is called after the function pointed out by | |||
| 372 | (/ (1- pos) (max (/ total 100) 1)) | 369 | (/ (1- pos) (max (/ total 100) 1)) |
| 373 | (/ (* 100 (1- pos)) (max total 1))))) | 370 | (/ (* 100 (1- pos)) (max total 1))))) |
| 374 | 371 | ||
| 375 | ;;; | ||
| 376 | ;;; Function for supporting general looking submenu names. | ||
| 377 | ;;; Uses `imenu-submenu-name-format' for creating the name. | ||
| 378 | ;;; NAME is the base of the new submenu name. | ||
| 379 | ;;; | ||
| 380 | (defun imenu-create-submenu-name (name) | ||
| 381 | (format imenu-submenu-name-format name)) | ||
| 382 | |||
| 383 | ;; Split LIST into sublists of max length N. | 372 | ;; Split LIST into sublists of max length N. |
| 384 | ;; Example (imenu--split '(1 2 3 4 5 6 7 8) 3)-> '((1 2 3) (4 5 6) (7 8)) | 373 | ;; Example (imenu--split '(1 2 3 4 5 6 7 8) 3)-> '((1 2 3) (4 5 6) (7 8)) |
| 385 | (defun imenu--split (list n) | 374 | (defun imenu--split (list n) |
| @@ -401,16 +390,30 @@ This function is called after the function pointed out by | |||
| 401 | (push (nreverse sublist) result)) | 390 | (push (nreverse sublist) result)) |
| 402 | (nreverse result))) | 391 | (nreverse result))) |
| 403 | 392 | ||
| 404 | ;;; | 393 | ;;; Split the alist MENULIST into a nested alist, if it is long enough. |
| 405 | ;;; Split a menu in to several menus. | 394 | ;;; In any case, add TITLE to the front of the alist. |
| 406 | ;;; | ||
| 407 | (defun imenu--split-menu (menulist title) | 395 | (defun imenu--split-menu (menulist title) |
| 408 | (cons "Index menu" | 396 | (if (> (length menulist) imenu-max-items) |
| 409 | (mapcar | 397 | (let ((count 0)) |
| 410 | (function | 398 | (cons title |
| 411 | (lambda (menu) | 399 | (mapcar |
| 412 | (cons (format "(%s)" title) menu))) | 400 | (function |
| 413 | (imenu--split menulist imenu-max-items)))) | 401 | (lambda (menu) |
| 402 | (cons (format "(%s-%d)" title (setq count (1+ count))) | ||
| 403 | menu))) | ||
| 404 | (imenu--split menulist imenu-max-items)))) | ||
| 405 | (cons title menulist))) | ||
| 406 | |||
| 407 | ;;; Split up each long alist that are nested within ALIST | ||
| 408 | ;;; into nested alists. | ||
| 409 | (defun imenu--split-submenus (alist) | ||
| 410 | (mapcar (function (lambda (elt) | ||
| 411 | (if (and (consp elt) | ||
| 412 | (stringp (car elt)) | ||
| 413 | (listp (cdr elt))) | ||
| 414 | (imenu--split-menu (cdr elt) (car elt)) | ||
| 415 | elt))) | ||
| 416 | alist)) | ||
| 414 | 417 | ||
| 415 | ;;; | 418 | ;;; |
| 416 | ;;; Find all items in this buffer that should be in the index. | 419 | ;;; Find all items in this buffer that should be in the index. |
| @@ -629,18 +632,14 @@ pattern. | |||
| 629 | (push | 632 | (push |
| 630 | (cons (buffer-substring-no-properties beg end) beg) | 633 | (cons (buffer-substring-no-properties beg end) beg) |
| 631 | (cdr | 634 | (cdr |
| 632 | (or (if (not (stringp menu-title)) index-alist) | 635 | (or (assoc menu-title index-alist) |
| 633 | (assoc | ||
| 634 | (imenu-create-submenu-name menu-title) | ||
| 635 | index-alist) | ||
| 636 | (car (push | 636 | (car (push |
| 637 | (cons | 637 | (cons menu-title '()) |
| 638 | (imenu-create-submenu-name menu-title) | ||
| 639 | '()) | ||
| 640 | index-alist)))))))))) | 638 | index-alist)))))))))) |
| 641 | patterns)))) | 639 | patterns)))) |
| 642 | (imenu-progress-message prev-pos 100 t) | 640 | (imenu-progress-message prev-pos 100 t) |
| 643 | (delete 'dummy index-alist))) | 641 | (let ((main-element (assq nil index-alist))) |
| 642 | (nconc (delq main-element (delq 'dummy index-alist)) main-element)))) | ||
| 644 | 643 | ||
| 645 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 644 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 646 | ;;; | 645 | ;;; |
| @@ -696,6 +695,7 @@ Returns t for rescan and otherwise a position number." | |||
| 696 | INDEX-ALIST is the buffer index and EVENT is a mouse event. | 695 | INDEX-ALIST is the buffer index and EVENT is a mouse event. |
| 697 | 696 | ||
| 698 | Returns t for rescan and otherwise a position number." | 697 | Returns t for rescan and otherwise a position number." |
| 698 | (setq index-alist (imenu--split-submenus index-alist)) | ||
| 699 | (let* ((menu (imenu--split-menu | 699 | (let* ((menu (imenu--split-menu |
| 700 | (if imenu-sort-function | 700 | (if imenu-sort-function |
| 701 | (sort | 701 | (sort |
| @@ -810,6 +810,7 @@ See the command `imenu' for more information." | |||
| 810 | (or (equal index-alist imenu--last-menubar-index-alist) | 810 | (or (equal index-alist imenu--last-menubar-index-alist) |
| 811 | (let (menu menu1 old) | 811 | (let (menu menu1 old) |
| 812 | (setq imenu--last-menubar-index-alist index-alist) | 812 | (setq imenu--last-menubar-index-alist index-alist) |
| 813 | (setq index-alist (imenu--split-submenus index-alist)) | ||
| 813 | (setq menu (imenu--split-menu | 814 | (setq menu (imenu--split-menu |
| 814 | (if imenu-sort-function | 815 | (if imenu-sort-function |
| 815 | (sort | 816 | (sort |
| @@ -832,7 +833,6 @@ See the command `imenu' for more information." | |||
| 832 | 833 | ||
| 833 | (defun imenu--menubar-select (item) | 834 | (defun imenu--menubar-select (item) |
| 834 | "Use Imenu to select the function or variable named in this menu item." | 835 | "Use Imenu to select the function or variable named in this menu item." |
| 835 | (interactive) | ||
| 836 | (imenu item)) | 836 | (imenu item)) |
| 837 | 837 | ||
| 838 | ;;;###autoload | 838 | ;;;###autoload |