Subject: 24.0.50; `minibuffer-scroll-window' with active minibuffer: always *Completions*?

From: "Drew Adams" <[email-masked]>
Date: Sun, 27 Mar 2011 15:03:17 -0700

`minibuffer-scroll-window' is the window to be scrolled by
`scroll-other-window' from the minibuffer.
 
The doc suggests that setting `minibuffer-scroll-window' to some window
when the minibuffer is active would make other-window scrolling use that
window.  E.g. the doc for `scroll-other-window' includes this:
 
"If in the minibuffer, `minibuffer-scroll-window' if non-nil specifies
the window to scroll.  This takes precedence over
`other-window-scroll-buffer'."
 
It doesn't say that the *Completions* window is always the other window
scrolled.  But `minibuffer-scroll-window' always seems to be reset to
the *Completions* window, AFAICT.
 
Help me understand how to make some other window than the *Completions*
window the target to be scrolled by `scroll-other-window' from the
minibuffer.
 
emacs -Q
 
C-x d RET
C-x 4 b *scratch* RET
 
(defun foo ()
 (setq minibuffer-scroll-window 
       (get-buffer-window (get-buffer "*scratch*") 0))
 (message "fffff, MSW: %S" minibuffer-scroll-window) (sleep-for 2))
 
(add-hook 'completion-setup-hook 'foo 'append)
 
(defun bar (arg)
  (interactive "P")
  (message "BBBBB, MSW: %S" minibuffer-scroll-window) (sleep-for 2)
  (scroll-other-window arg))
 
(define-key minibuffer-local-completion-map "\C-\M-v" 'bar)
 
Return focus to the Dired window.
 
M-x for TAB C-M-v
 
That shows that `minibuffer-scroll-window' is the *Completions* window
when `C-M-v' is pressed, even though `minibuffer-scroll-window' was the
*scratch* window just after *Completions* was shown.
 
I looked at the code in minibuffer.el and window.c to try to understand
where `minibuffer-scroll-window' is getting reset (to *Completions*),
but I haven't understood, so far.
 
(`minibuffer-complete' does set `minibuffer-scroll-window' (e.g. to
nil), but debugging that function shows that it doesn't seem to make a
difference here.  And my own code, where I also see the problem, doesn't
even call `minibuffer-complete'.)
 
Help appreciated.  Is this a bug?  Shouldn't you be able to set the
window to be scrolled (using `scroll-other-window') during minibuffer
input to be some window other than *Completions*?  How can I do that?
Just where is `minibuffer-scroll-window' getting set and reset?  Thx.
 
In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2011-03-21 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.5) --no-opt --cflags
-Ic:/imagesupport/include'