diff options
| author | Richard M. Stallman | 1996-09-21 23:00:40 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-09-21 23:00:40 +0000 |
| commit | 7ebea14458b0cde69ac904c4de95615a045d1ca7 (patch) | |
| tree | 3c988ca4c5e540a747a3b1c075cd9abed785f2d1 | |
| parent | 215b077e2ffb6442b0072802186f02055fe88541 (diff) | |
| download | emacs-7ebea14458b0cde69ac904c4de95615a045d1ca7.tar.gz emacs-7ebea14458b0cde69ac904c4de95615a045d1ca7.zip | |
(imenu--split-menu): Keep the rescan item at top level.
Keep subalists at top level too.
Name the split-off submenus from the first item in them.
(imenu--generic-function): Avoid adding nil as elt of the result.
| -rw-r--r-- | lisp/imenu.el | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el index 6cefcfdfdb4..64d5007e855 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el | |||
| @@ -406,25 +406,35 @@ This function is called after the function pointed out by | |||
| 406 | ;;; Split the alist MENULIST into a nested alist, if it is long enough. | 406 | ;;; Split the alist MENULIST into a nested alist, if it is long enough. |
| 407 | ;;; In any case, add TITLE to the front of the alist. | 407 | ;;; In any case, add TITLE to the front of the alist. |
| 408 | (defun imenu--split-menu (menulist title) | 408 | (defun imenu--split-menu (menulist title) |
| 409 | (if imenu-sort-function | 409 | (let (keep-at-top tail) |
| 410 | (setq menulist | 410 | (if (memq imenu--rescan-item menulist) |
| 411 | (sort | 411 | (setq keep-at-top (cons imenu--rescan-item nil) |
| 412 | (let ((res nil) | 412 | menulist (delq imenu--rescan-item menulist))) |
| 413 | (oldlist menulist)) | 413 | (setq tail menulist) |
| 414 | ;; Copy list method from the cl package `copy-list' | 414 | (while tail |
| 415 | (while (consp oldlist) (push (pop oldlist) res)) | 415 | (if (imenu--subalist-p (car tail)) |
| 416 | (prog1 (nreverse res) (setcdr res oldlist))) | 416 | (setq keep-at-top (cons (car tail) keep-at-top) |
| 417 | imenu-sort-function))) | 417 | menulist (delq (car tail) menulist))) |
| 418 | (if (> (length menulist) imenu-max-items) | 418 | (setq tail (cdr tail))) |
| 419 | (let ((count 0)) | 419 | (if imenu-sort-function |
| 420 | (cons title | 420 | (setq menulist |
| 421 | (mapcar | 421 | (sort |
| 422 | (function | 422 | (let ((res nil) |
| 423 | (lambda (menu) | 423 | (oldlist menulist)) |
| 424 | (cons (format "(%s-%d)" title (setq count (1+ count))) | 424 | ;; Copy list method from the cl package `copy-list' |
| 425 | menu))) | 425 | (while (consp oldlist) (push (pop oldlist) res)) |
| 426 | (imenu--split menulist imenu-max-items)))) | 426 | (prog1 (nreverse res) (setcdr res oldlist))) |
| 427 | (cons title menulist))) | 427 | imenu-sort-function))) |
| 428 | (if (> (length menulist) imenu-max-items) | ||
| 429 | (let ((count 0)) | ||
| 430 | (setq menulist | ||
| 431 | (mapcar | ||
| 432 | (function | ||
| 433 | (lambda (menu) | ||
| 434 | (cons (format "From: %s" (caar menu)) menu))) | ||
| 435 | (imenu--split menulist imenu-max-items))))) | ||
| 436 | (cons title | ||
| 437 | (nconc (nreverse keep-at-top) menulist)))) | ||
| 428 | 438 | ||
| 429 | ;;; Split up each long alist that are nested within ALIST | 439 | ;;; Split up each long alist that are nested within ALIST |
| 430 | ;;; into nested alists. | 440 | ;;; into nested alists. |
| @@ -675,7 +685,8 @@ pattern. | |||
| 675 | patterns)))) | 685 | patterns)))) |
| 676 | (imenu-progress-message prev-pos 100 t) | 686 | (imenu-progress-message prev-pos 100 t) |
| 677 | (let ((main-element (assq nil index-alist))) | 687 | (let ((main-element (assq nil index-alist))) |
| 678 | (nconc (delq main-element (delq 'dummy index-alist)) main-element)))) | 688 | (nconc (delq main-element (delq 'dummy index-alist)) |
| 689 | (cdr main-element))))) | ||
| 679 | 690 | ||
| 680 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 691 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 681 | ;;; | 692 | ;;; |