Function: imenu--completion-buffer
imenu--completion-buffer is a byte-compiled function defined in
imenu.el.gz.
Signature
(imenu--completion-buffer INDEX-ALIST &optional PROMPT)
Documentation
Let the user select from INDEX-ALIST in a completion buffer with PROMPT.
Return one of the entries in index-alist or nil.
Source Code
;; Defined in /usr/src/emacs/lisp/imenu.el.gz
(defun imenu--completion-buffer (index-alist &optional prompt)
"Let the user select from INDEX-ALIST in a completion buffer with PROMPT.
Return one of the entries in index-alist or nil."
;; Create a list for this buffer only when needed.
(let ((name (thing-at-point 'symbol))
choice
(prepared-index-alist
(if (not imenu-space-replacement) index-alist
(mapcar
(lambda (item)
(cons (subst-char-in-string ?\s (aref imenu-space-replacement 0)
(car item))
(cdr item)))
index-alist))))
(when (stringp name)
(setq name (or (imenu-find-default name prepared-index-alist) name)))
(unless prompt
(setq prompt (format-prompt
"Index item"
(and name
(imenu--in-alist name prepared-index-alist)
;; Default to `name' if it's in the alist.
name))))
(minibuffer-with-setup-hook
(lambda () (setq-local minibuffer-allow-text-properties t))
(setq name (completing-read
prompt
(completion-table-with-metadata
prepared-index-alist
`((category . imenu)
(eager-display . ,(not imenu-eager-completion-buffer))
,@(when (eq imenu-flatten 'annotation)
`((annotation-function
. ,(lambda (s) (get-text-property
0 'imenu-section s)))))
,@(when (eq imenu-flatten 'group)
`((group-function
. ,(lambda (s transform)
(if transform s
(get-text-property
0 'imenu-section s))))))))
nil t nil 'imenu--history-list name)))
(when (stringp name)
(or (get-text-property 0 'imenu-choice name)
(progn
(setq choice (assoc name prepared-index-alist))
(if (imenu--subalist-p choice)
(imenu--completion-buffer (cdr choice) prompt)
choice))))))