Subject: Re: bug#45072: 28.0.50; Emacs switches other buffer back uncontrollably, if other window's buffer is changed by user during minibuffer editing

From: Juri Linkov <[email-masked]>
Date: Wed, 09 Dec 2020 21:11:39 +0200

>> Thanks, sometime ago I asked how this would be possible to do,
>> and now I'm testing your patch (it missed trailing spaces on diff
>> context lines, but still applies without problems).
>>
>> It seems to be really useful this option needs to keep only windows
>> implicitly created by the user, but remove windows created
>> automatically by mibibuffer-related commands such as the buffer
>> *Completions*.
>
> Such windows must be removed by the mechanism that created them.  I
> hardly ever see such windows here because I'm apparently using some
> arcane completions mechanism that always puts them in place right away.
> But if I'm not mistaken, several such windows may pop up during one and
> the same minibuffer input operation and IMO all of them should pop down
> automatically as soon as they served their purpose.
>
> A case could be made in the sense that by default the minibuffer window
> itself won't shrink back after the completions have been shown there.
> But I suppose that people using such a mechanism should also set
> 'resize-mini-windows' to t.

What do you think about let-binding a new variable
read-minibuffer-record-windows to nil around functions
that pop up completion windows?

I mean for example in minibuffer-completion-help:

  (let ((read-minibuffer-record-windows nil))
    (display-completion-list completions))

The default value of read-minibuffer-record-windows could be t,
so it will record new windows created by the user, e.g. by C-x 2.
But when let-bound to nil, it won't record windows created
by completion commands, so these windows won't be restored
after exiting the minibuffer.