Subject: Re: bug#74616: 30.0.92; tmm always displays the *Completions* buffer

From: Daniel Mendler <[email-masked]>
Date: Sun, 15 Dec 2024 16:29:19 +0100

Daniel Mendler <[email-masked]> writes:

> Juri Linkov <[email-masked]> writes:
>
>>> Thanks for finding this. The problem was that `initial-input' was passed
>>> directly to `completion-metadata'. I replaced `initial-input' with `(or
>>> initial-input "")'. See the updated patch attached to this mail.
>>
>> It seems this change caused another regression: 'ffap' on a file name
>> fails with the error:
>
> Oh, I see. The INITIAL-INPUT argument can be a cons pair too.  See the
> patch attached to this mail which fixes the problem.

I've attached an ever better patch to this mail, where the minibuffer
content is simply used directly instead of handling the different
INITIAL-INPUT cases. This is simpler and more future proof.

Daniel

>From 254c3d7b1ae8224d305aff7f55817c6fd9fca1c5 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <[email-masked]>
Date: Sun, 15 Dec 2024 10:57:59 +0100
Subject: [PATCH] completion-eager-display: Use buffer content instead of
 INITIAL-INPUT

* lisp/minibuffer.el (completing-read-default): Use the
minibuffer content instead of handling INITIAL-INPUT directly.
---
 lisp/minibuffer.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index dfc62c25f38..91495f9f941 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -4857,8 +4857,10 @@ completing-read-default
                 ;; `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))
+                  (let* ((md (completion-metadata
+                              (buffer-substring-no-properties
+                               (minibuffer-prompt-end) (point))
+                              collection predicate))
                          (fun (completion-metadata-get md 'eager-display)))
                     (when (or fun (eq completion-eager-display t))
                       (funcall (if (functionp fun)
-- 
2.45.2