Subject: Re: bug#24500: 25.1.50; Can't other-window from minibuffer if Ediff control panel frame present

From: Eli Zaretskii <[email-masked]>
Date: Thu, 22 Sep 2016 18:26:06 +0300

> From: Richard Copley <[email-masked]>
> Date: Wed, 21 Sep 2016 21:09:46 +0100
> Cc: [email-masked]
> 
> >> C-x b * RET ; create a spare buffer so we can invoke ediff-buffers
> >> M-x ediff-buffers RET RET RET
> >> C-x 5 o ; Activate main frame
> >> M-x     ; Select minibuffer
> >> C-x C-o ; Something not very useful happens
> >>
> >> At this point in the recipe Emacs is in a strange state. The cursor in
> >> the minibuffer is solid but not blinking. There are visual changes in
> >> the Ediff control frame as though the window is selected, but the
> >> Ediff frame isn't actually activated. Typing C-g doesn't exit the
> >> minibuffer (which is still reading the command for M-x). Typing a
> >> self-inserting character does send that character to the minibuffer,
> >> and returns things to normal.
> >
> > Isn't this just the normal way of having input to one frame being
> > redirected to another?
> 
> I don't see how it is normal, so I'm probably missing something. The
> input to the main frame being redirected to the Ediff frame, or vice
> versa?

Vice versa.  The Ediff control frame is a minibuffer-less frame, and
when it is created, it specifies the minibuffer of the main frame as
its minibuffer.

> Why?

That is how Emacs uses frame A for minibuffer input that pertains to
frame B.

> And why did "C-x C-o" put me in that state, be it normal or
> otherwise, rather than selecting one of the windows in the main
> frame?

(You meant "C-x o", not "C-x C-o".)

"C-x o" switches to "some other window in the cyclic ordering of
windows".  It does so by calling next-window, which is called in a way
that doesn't limit it to return windows only on the current frame.  As
you yourself say in the original report:

  If you miss out the "Activate main frame" step, then you can cycle
  through all the windows of both frames [...]

So what happens here is that next-window returns the window on the
Ediff control frame, and Emacs then selects it, and also makes the
control frame the selected frame.  But because the original selected
frame, when you typed "M-x", was the main frame (and we are still
reading from its minibuffer), Emacs switches back to the main frame
right away.  And that's what you see: the single window of the Ediff
control frame becomes the selected window, but its frame doesn't
become the selected frame.

Not sure what, if anything, could or should be done about this.
Perhaps Martin will have some tricks up his sleeves.  It's a corner
use case, regardless.