(cdr item)))
index-alist))))
(unless prompt (setq prompt (format-prompt "Index item" nil)))
- (when-let ((name (completing-read
- prompt
- (completion-table-with-metadata
- prepared-index-alist
- `((category . imenu)
- (eager-display . ,imenu-eager-completion-buffer)
- ,@(and imenu-flatten
- completions-group
- `((group-function
- . ,(lambda (s transform)
- (get-text-property
- 0 (if transform 'imenu-base-name 'imenu-section) s)))))))
- nil t nil 'imenu--history)))
+ (when-let ((name (minibuffer-with-setup-hook
+ (lambda ()
+ (setq-local
+ completion-extra-properties
+ `( :category imenu
+ :eager-display ,imenu-eager-completion-buffer
+ ,@(and imenu-flatten
+ completions-group
+ `(:group-function
+ ,(lambda (s transform)
+ (get-text-property
+ 0 (if transform 'imenu-base-name 'imenu-section) s)))))))
+ ;; Use a simple alist (rather than a function) as
+ ;; collection so the minibuffer action can easily
+ ;; inspect it.
+ (completing-read prompt prepared-index-alist nil t nil 'imenu--history))))
(setq choice (assoc name prepared-index-alist))
(if (imenu--subalist-p choice)
(imenu--completion-buffer (cdr choice) prompt)