Subject: bug#11939: 24.1; `save-buffers-kill-emacs' loses minibuffer focus whenit calls `list-processes'

From: "Drew Adams" <[email-masked]>
Date: Thu, 26 Jul 2012 06:51:38 -0700

>  > I do not understand, BTW, why you redirect the focus from 
>  > the new frame to itself, instead of to the minibuffer frame.
> 
> I came to this when trying out various scenarios and it 
> seemed this worked for me.

OK.  It does not work for me.

>  > So I tried instead redirecting the focus to the minibuffer 
>  > frame.  That worked OK, but the default buffer for killing
>  > with C-x k was ` *Minibuf-0*', not *shell* or *Process List*.
>  >
>  > It seems that when a new frame is created, the default 
>  > value for C-x k (and other buffer commands) becomes *Minibuf-0*.
>  > I can of course choose not to use the default value, but it
>  > would be good to get this part fixed also.
> 
> You mean *Minibuf-0* became the current buffer?  Probably so 
> because you selected its window.

I did not do so explicitly, AFAIK.  But perhaps read-from-minibuffer (actually
the C code for it) does that?  I do not see anywhere that I do so in my code.

>  > Or as a workaround I can explicitly select the frame of 
>  > the buffer I want to kill - e.g., click the title bar of frame
>  > *shell*.  After I do that, that buffer becomes the default
>  > value for C-x k.
>  >
>  > IOW, it seems that not only is the input focus redirected 
>  > to the minibuffer frame, but also the current buffer is
>  > changed to *Minibuf-0*.  And if I do `M-:
>  > (current-buffer)' I do get *Minibuf-0*.  Is it normal for 
>  > frame-focus redirection to change the current buffer also?
>  > That does not seem right to me.
> 
> I nowhere in the code see that it does.  Are you sure you did
> not use `select-frame-set-input-focus' in this case?

Yes, I'm pretty sure.  I can always try to look closer, but there is certainly
nothing in oneonone.el that does that.

>  > Anyway, aside from this problem of default value for C-x 
>  > k, things seemed to work OK.  So overall this seems like a
>  > reasonable solution, except for the default buffer problem.
>  > This is all I did, along with my usual setup:
>  >
>  > (add-hook 'after-make-frame-functions
>  >           (lambda (frame)
>  >             (redirect-frame-focus frame
>  >               (window-frame (minibuffer-window)))))
> 
> That was my initial idea.  I forgot why it didn't work (maybe 
> it failed when I created a new frame with a minibuffer).

What do you think about it now?  Do you see a problem with it (aside from the
current-buffer problem I mentioned)?  Maybe it is worth pursuing; dunno.