This is what I was doing before Magit 2.3, adapted from What the .emacs.d!?:
(defadvice magit-status (around magit-fullscreen activate)
"Turn fullscreen on for magit-status."
(window-configuration-to-register :magit-fullscreen)
ad-do-it
(delete-other-windows))
(defun magit-quit-session ()
"Restore previous window configuration and cleanup buffers."
(interactive)
(mu-kill-buffers "^\\*magit")
(jump-to-register :magit-fullscreen))
(bind-key "q" #'magit-quit-session magit-status-mode-map)
(defun mu-kill-buffers (regexp)
"Kill buffers matching REGEXP without asking for confirmation."
(interactive "sKill buffers matching this regular expression: ")
(cl-letf (((symbol-function 'kill-buffer-ask)
(lambda (buffer) (kill-buffer buffer))))
(kill-matching-buffers regexp)))
The difference from the solution on What the .emacs.d!? is that I like q
to close all Magit buffers and not only magit-status
.
If you don't have bind-key
, you can just use regular define-key
:
(define-key magit-status-mode-map (kbd "q") #'magit-quit-session)
Following the new Magit guidelines, this is the solution that is now working for me:
(setq magit-post-display-buffer-hook
#'(lambda ()
(when (derived-mode-p 'magit-status-mode)
(delete-other-windows))))
magit-display-buffer
, which is a wrapper around the low-leveldisplay-buffer
... " There is some additional discussion about how to customize buffer display behavior via themagit-display-buffer-function
option, but I haven't experimented with this yet.