summaryrefslogtreecommitdiff
path: root/lisp/imenu.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-09-21 23:00:40 +0000
committerRichard M. Stallman <rms@gnu.org>1996-09-21 23:00:40 +0000
commit19a8765762d073def3cb2c6fdb76b5128075523b (patch)
tree41f96edcc63fdcd2979c2de7f0775ec99ee92f96 /lisp/imenu.el
parent0394591cb5cff2de04d02b9c92bce6a88647e43d (diff)
downloademacs-19a8765762d073def3cb2c6fdb76b5128075523b.tar.gz
(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.
Diffstat (limited to 'lisp/imenu.el')
-rw-r--r--lisp/imenu.el51
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
;;; Split the alist MENULIST into a nested alist, if it is long enough.
;;; In any case, add TITLE to the front of the alist.
(defun imenu--split-menu (menulist title)
- (if imenu-sort-function
- (setq menulist
- (sort
- (let ((res nil)
- (oldlist menulist))
- ;; Copy list method from the cl package `copy-list'
- (while (consp oldlist) (push (pop oldlist) res))
- (prog1 (nreverse res) (setcdr res oldlist)))
- imenu-sort-function)))
- (if (> (length menulist) imenu-max-items)
- (let ((count 0))
- (cons title
- (mapcar
- (function
- (lambda (menu)
- (cons (format "(%s-%d)" title (setq count (1+ count)))
- menu)))
- (imenu--split menulist imenu-max-items))))
- (cons title menulist)))
+ (let (keep-at-top tail)
+ (if (memq imenu--rescan-item menulist)
+ (setq keep-at-top (cons imenu--rescan-item nil)
+ menulist (delq imenu--rescan-item menulist)))
+ (setq tail menulist)
+ (while tail
+ (if (imenu--subalist-p (car tail))
+ (setq keep-at-top (cons (car tail) keep-at-top)
+ menulist (delq (car tail) menulist)))
+ (setq tail (cdr tail)))
+ (if imenu-sort-function
+ (setq menulist
+ (sort
+ (let ((res nil)
+ (oldlist menulist))
+ ;; Copy list method from the cl package `copy-list'
+ (while (consp oldlist) (push (pop oldlist) res))
+ (prog1 (nreverse res) (setcdr res oldlist)))
+ imenu-sort-function)))
+ (if (> (length menulist) imenu-max-items)
+ (let ((count 0))
+ (setq menulist
+ (mapcar
+ (function
+ (lambda (menu)
+ (cons (format "From: %s" (caar menu)) menu)))
+ (imenu--split menulist imenu-max-items)))))
+ (cons title
+ (nconc (nreverse keep-at-top) menulist))))
;;; Split up each long alist that are nested within ALIST
;;; into nested alists.
@@ -675,7 +685,8 @@ pattern.
patterns))))
(imenu-progress-message prev-pos 100 t)
(let ((main-element (assq nil index-alist)))
- (nconc (delq main-element (delq 'dummy index-alist)) main-element))))
+ (nconc (delq main-element (delq 'dummy index-alist))
+ (cdr main-element)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;