Subject: bug#5030: 23.1.50; Unexpected minibuffer tab completion behavior

From: Matthew Dempsky <[email-masked]>
Date: Tue, 24 Nov 2009 17:09:50 -0800

It seems like the unexpected buffer switching is because the
'dedicated' flag on the temporary window created for *Completions* is
getting cleared by set-window-buffer.

My understanding of the situation so far is:

 - The `(with-output-to-temp-buffer "*Completions*" ...)' form in
minibuffer-completion-help results in `display-buffer' being called
with `display-buffer-mark-dedicated' bound to `soft'.
 - The `(and pop-up-windows ...)' clause of `display-buffer' is
evaluated*, and calls `(set-window-dedicated-p window-to-use 'soft)'.
 - However, the `window--display-buffer-2' call then calls
`set-window-buffer', which sets `w->dedicated = Qnil'.
 - Later, when `(bury-buffer)' is called to hide the minibuffer help,
it sees the window is not dedicated, so it switches to a new buffer
instead of killing the window.

(* I haven't bothered yet to look into why that particular clause is
evaluated, but I don't think it matters; it's just the one that
stepping through the code took me to.)