Subject: bug#43120: 28.0.50; fido-mode: M-j before completions appear selects wrong choice

From: Lars Ingebrigtsen <[email-masked]>
Date: Sat, 05 Sep 2020 14:25:51 +0200

Sean Whitton <[email-masked]> writes:

> I think I see what the problem is.  I was doing the following to
> generate a test case: C-h f comp [wait for completions to appear] C-g

Oh, right; didn't think that through properly...

> This leaves completion-content-when-empty populated to interfere with
> the next run, as getting out of the minibuffer that way does not clear
> the variable, but it should.
>
> Might it work to set the variable buffer-local to the minibuffer?  Then
> we can be sure it would always be cleared.

All this time I thought the minibuffer was reused, but poking around a
bit now, it seems like it's not?

In which case -- does the following fix this problem?

diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 8a68df876c..ba266cfbfe 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -715,7 +715,7 @@ icomplete-completions
 	(setq prospects (nreverse prospects))
         ;; Return the first match if the user hits enter.
         (when icomplete-show-matches-on-no-input
-          (setq completion-content-when-empty (car prospects)))
+          (setq-local completion-content-when-empty (car prospects)))
         ;; Decorate first of the prospects.
 	(when prospects
 	  (let ((first (copy-sequence (pop prospects))))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no