;; Display the completion buffer.
(minibuffer-with-setup-hook
(lambda ()
- (setq-local completion-extra-properties '(:category imenu))
+ (setq-local
+ completion-extra-properties
+ `( :category imenu
+ ,@(and imenu-flatten
+ completions-group
+ `(:group-function
+ ,(lambda (s transform)
+ (get-text-property
+ 0 (if transform 'imenu-base-name 'imenu-section) s))))))
(when imenu-eager-completion-buffer (minibuffer-completion-help)))
- (setq name (completing-read prompt
- prepared-index-alist
- nil t nil 'imenu--history name)))
-
+ (setq name (completing-read prompt prepared-index-alist
+ nil t nil 'imenu--history name)))
(when (stringp name)
(progn
(setq choice (assoc name prepared-index-alist))
name))))
(cond
((not (imenu--subalist-p item))
- (list (cons new-prefix pos)))
+ `((,(propertize (or new-prefix name)
+ 'imenu-section (or prefix "*")
+ 'imenu-base-name name)
+ . ,pos)))
(t
(imenu--flatten-index-alist pos concat-names new-prefix)))))
index-alist))