Subject: Re: bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer

From: Juri Linkov <[email-masked]>
Date: Sat, 30 Nov 2024 20:58:04 +0200

>> And imenu.el calls minibuffer-completion-help conditionally
>> unless imenu-eager-completion-buffer is not nil.
>
> Thanks, I wasn't aware of this option. It seems the behavior is
> inverted? The completion buffer pops up if imenu-eager-completion-buffer
> is nil.

Unfortunately, it is inverted indeed.  And there is even bug#52389
about this, but it can't be changed for backward-compatibility reasons.

> It is likely that there are more such uses in the Emacs code and other
> packages. One possible solution would be a display-eager metadata:
>
> (completing-read "Test: "
>  (lambda (string pred action)
>    (if (eq action 'metadata)
>        '(metadata (display-eager . t))
>      (complete-with-action action #'read-file-name-internal string pred))))
>
> This pushes the responsibility of displaying the candidates to
> `completing-read'. In `completing-read-default' the following code
> would have to be added to the `minibuffer-with-setup-hook':
>                 
> (when (completion-metadata-get
>        (completion-metadata "" minibuffer-completion-table nil)
>        'display-eager)
>   (minibuffer-completion-help))

Adding a new metadata item looks like the right thing to do.
Then it will be possible to configure it via completion-category-overrides.