Subject: bug#23092: 25.0.92; Minibuffer completion fails to resize completion window if reused during same command

From: martin rudalics <[email-masked]>
Date: Wed, 23 Mar 2016 09:09:05 +0100

>> However, it's interesting that with the recipe reversed, the completions
 >> window _does_ get resized.:
 >>
 >>      src/emacs -Q
 >>
 >>      C-x C-f            ; find-file
 >>      lib/s TAB          ; A largish completions window is shown.
 >>      <backspace> v TAB  ; Completions window shrinks.
 >>
 >> So it seems that the existing implementation has logic in it for
 >> resizing the completions window to fit the completions but it just isn't
 >> working quite right. Unless the design is that the completions window
 >> can only be "shrunk" but not "grown".
 >
 > I'm sure Martin will be able to explain this ;-)

I never worked in this area but will try to do my best ;-) The behavior
is due to the following form in ‘minibuffer-completion-help’:

	    ,(if temp-buffer-resize-mode
		 '(window-height . resize-temp-buffer-window)
	       '(window-height . shrink-window-if-larger-than-buffer))

The first branch of the ‘if’ means that if ‘temp-buffer-resize-mode’ is
enabled, this function will always try to fit the window to the buffer.
The second branch means that if ‘temp-buffer-resize-mode’ is not
enabled, the window may only shrink to occupy less space.

Obviously, the second branch is based on the assumption that a user will
"refine" her completions in the sense that she starts with a large
number of possible completions and, by typing characters in the
minibuffer, reduces the number of possible completions until she found
the right one.  Apparently, the OP works in the opposite direction - he
starts with few suggestions and removes characters from the minibuffer
ending up with more and more suggestions.

martin