Subject: bug#15469: 24.3; emacsclient -c fails to grab focus when asking “Revert buffer from file?”

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 06 Dec 2020 16:27:30 +0100

Anders Kaseorg <[email-masked]> writes:

> When using Emacs in server mode and ‘emacsclient -c’ as my preferred
> editor, new windows opened by emacsclient often fail to grab keyboard
> focus, correlated with Emacs asking minibuffer questions like “Revert
> buffer from file?” as the file is opened (e.g. on .git/COMMIT_EDITMSG
> which is frequently modified both inside and outside Emacs).  I can
> reproduce this reliably as follows:
>
> 1. emacs -Q /tmp/foo
> 2. M-x server-start
> 3. Type some text into the buffer; do not save.
> 4. Click outside the Emacs window to unfocus it.
> 5. Click inside the Emacs window to focus it.
> 6. Click outside the Emacs window to unfocus it.
> 7. Modify /tmp/foo outside Emacs.
> 8. emacsclient -c /tmp/foo
> 9. An _unfocused_ Emacs window pops up to ask “Revert buffer from file
> /tmp/foo?”.

(This bug report unfortunately got no response at the time.)

I can confirm that this bug is still present in Emacs 28, but I have not
tried to debug it.  Anybody with a guess at what's going on?

The new frame that's popped up does have focus, as expected, if the
"revert buffer" query isn't done.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no