(cdr item)))
index-alist))))
(unless prompt (setq prompt (format-prompt "Index item" nil)))
- (when-let ((name (minibuffer-with-setup-hook
- (lambda ()
- (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
- ;; Display the completion buffer.
- (minibuffer-completion-help)))
- (completing-read prompt prepared-index-alist nil t nil 'imenu--history))))
+ (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)))
(setq choice (assoc name prepared-index-alist))
(if (imenu--subalist-p choice)
(imenu--completion-buffer (cdr choice) prompt)
(defvar completion-show-inline-help t
"If non-nil, print helpful inline messages during completion.")
+(defcustom completion-eager-display 'auto
+ "Whether completion commands should display *Completions* buffer eagerly.
+
+If the variable is set to t, completion commands show the *Completions*
+buffer always immediately. Setting the variable to nil disables the
+eager *Completions* display for all commands.
+
+For the value `auto', completion commands show the *Completions* buffer
+immediately only if requested by the completion command. Completion
+tables can request eager display via the `eager-display' metadata.
+
+See also the variables `completion-category-overrides' and
+`completion-extra-properties' for the `eager-display' completion
+metadata."
+ :type '(choice (const :tag "Never show *Completions* eagerly" nil)
+ (const :tag "Always show *Completions* eagerly" t)
+ (const :tag "If requested by the completion command" auto))
+ :version "31.1")
+
(defcustom completion-auto-help t
"Non-nil means automatically provide help for invalid completion input.
If the value is t, the *Completions* buffer is displayed whenever completion
`:narrow-completions-function': function for narrowing the completions list.
+`:eager-display': Show the *Completions* buffer eagerly.
+
See more information about these functions above
in `completion-metadata'.
(setq-local minibuffer--require-match require-match)
(setq-local minibuffer--original-buffer buffer)
(add-hook 'minibuffer-exit-hook
- #'minibuffer-kill-completions-buffer nil t))
+ #'minibuffer-kill-completions-buffer nil t)
+ ;; Show the completion help eagerly if
+ ;; `completion-eager-display' is t or if eager display
+ ;; has been requested by the completion table.
+ (when completion-eager-display
+ (let* ((md (completion-metadata (or initial-input "")
+ collection predicate))
+ (fun (completion-metadata-get md 'eager-display)))
+ (when (or fun (eq completion-eager-display t))
+ (funcall (if (functionp fun)
+ fun #'minibuffer-completion-help))))))
(read-from-minibuffer prompt initial-input keymap
nil hist def inherit-input-method))))
(when (and (equal result "") def)