Show Magit Status window in fullscreen

When I moved back to my own Emacs configuration from Spacemacs one thing that I missed most was to have Magit’s status window cover the whole frame.

Since Magit 2.8 from August 2016 that’s easy. It now ships pre-made variants for the magit-display-buffer-function option, one of those being magit-display-buffer-fullframe-status-v1 which displays the status buffer over the whole frame. Using it is as easy as:

(setq magit-display-buffer-function

But how would you reproduce this behaviour in older versions of Magit?

Turns out that for Emacs 24 and newer the solution is just one entry in display-buffer-alist away:

(add-to-list 'display-buffer-alist
             `(,(rx "*magit: ")
               (reusable-frames . nil)))

There’s no built-in display function to show a window over the whole frame but it’s simple to write one:

(defun lunaryorn-display-buffer-fullframe (buffer alist)
  "Display BUFFER in fullscreen.

ALIST is a `display-buffer' ALIST.

Return the new window for BUFFER."
  (let ((window (display-buffer-pop-up-window buffer alist)))
    (when window
      (delete-other-windows window))

We simply need to get hold of any arbitrary window for the buffer, and then just delete all other windows, leaving only the window for our buffer.

I’m using the “official” variant from Magit these days but the display-buffer-alist serves as a nice remainder of the powerful customisation options modern Emacs offers.