when executing magit-status and quickly focus out emacs, after the magit buffer pops up, emacs grabs the focus back. This is quite inconvenient. Is there a way to prevent that focus changing?

The way to reproduce this issue:

  1. emacs -Q and load magit.
  2. using magit-status command to load a middle size git project (which takes 1-2 seconds).
  3. in the meantime, quickly focus away from the Emacs frame, say clicking on a browser window.
  4. when magit-status buffer pops up, it grabs the focus back (which is what I'm trying to avoid)


Emacs 27.0.50
magit d9ae466377b30d544fcbf5c57af1a60b350931af
  • Maybe you can take a look at the variable magit-display-buffer-noselect, it seems when it is the default value, the function magit-display-buffer tries to raise the frame. FWIW, I can't reproduce the issue on Mac.
    – xuchunyang
    Commented Mar 14, 2018 at 19:21
  • @xuchunyang magit-display-buffer-noselect works! thank you.
    – Amos
    Commented Mar 15, 2018 at 2:17
  • 2
    Could one of you please turn this into an answer?
    – tarsius
    Commented Mar 17, 2018 at 12:41

2 Answers 2


Set magit-display-buffer-noselect to t to prevent magit-display-buffer from calling select-window.


Perhaps it has changed since the answer from March 2018, but setting magit-display-buffer-noselect didn’t work for me (i3 would still raise the Emacs window).

I found it necessary to configure Emacs like so:

;; By default, when e.g. M-x magit-status opens a new buffer, the frame is
;; raised, which focuses the X11 window in i3, thereby stealing focus.
;; By setting inhibit-switch-frame to t, Emacs will not call raise-frame.
 '(".*" . (display-buffer-reuse-window
           . ((inhibit-switch-frame . t)))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.