32

I am using Magit to work with git in emacs. I have bound magit-status to a key, but every time I hit the key it opens in a split in lower half of the window and i have to hit C-x 1 to get it into a full window. How can I make it open in a full window by default?

Mad Wombat
  • 14,490
  • 14
  • 73
  • 109

8 Answers8

31
(setq magit-status-buffer-switch-function 'switch-to-buffer)

or via customize:

M-x customize-variable RET magit-status-buffer-switch-function RET

N.N.
  • 8,336
  • 12
  • 54
  • 94
phils
  • 71,335
  • 11
  • 153
  • 198
23

For newer versions of Magit you can use this sanctioned snippet:

(setq magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)

I combine it with this to get a zen-like full window Git status after switching projects:

(setq projectile-switch-project-action 'magit-status)

Rudolf Adamkovič
  • 31,030
  • 13
  • 103
  • 118
gondalez
  • 1,225
  • 10
  • 13
8

Here is another way to achieve this:

(add-to-list 'same-window-regexps "\*magit: .*\*")

Bob
  • 81
  • 1
  • 2
4

This solution has the advantage that you can kill the fullscreen buffer in quit-window style:

(defadvice magit-status (around magit-fullscreen activate)
  (window-configuration-to-register :magit-fullscreen)
  ad-do-it
  (delete-other-windows))

(defadvice magit-mode-quit-window (after magit-restore-screen activate)
  "Restores the previous window configuration and kills the magit buffer"
  (jump-to-register :magit-fullscreen))

(define-key magit-status-mode-map (kbd "q") 'magit-mode-quit-window)

If you have an older version of magit then you might need to rename magit-mode-quit-window to magit-quit-window.

jhrr
  • 1,624
  • 14
  • 22
3

Note! Newer versions of magit use the function, magit-display-buffer-function, and this can be harnessed to get the same behaviour. The following snippet will give you the desired, fullscreen, magit bounty.

(defun display-buffer-full-screen (buffer alist)
  (delete-other-windows)
  (set-window-dedicated-p nil nil)
  (set-window-buffer nil buffer)
  (get-buffer-window buffer))

(setq magit-display-buffer-function
      (lambda (buffer)
        (if magit-display-buffer-noselect
            (magit-display-buffer-traditional buffer)
          (display-buffer buffer '(display-buffer-full-screen)))))
jhrr
  • 1,624
  • 14
  • 22
3

I use this:

(defun my-magit-status ()
  "Don't split window."
  (interactive)
  (let ((pop-up-windows nil))
    (call-interactively 'magit-status)))
N.N.
  • 8,336
  • 12
  • 54
  • 94
scottfrazer
  • 17,079
  • 4
  • 51
  • 49
1

Another option is to customize the variable display-buffer-alist.

If all you want is magit, you can do this:

(customize-set-variable
     'display-buffer-alist
     '(("\\*magit: .*" display-buffer-same-window)))
achalk
  • 3,229
  • 3
  • 17
  • 37
  • Nice, but for recent versions of magit you need to remove the leading asterisk in the condition: `"magit: .*"` – tmalsburg Mar 20 '23 at 09:47
1

For Magit v2.90.1, the correct answer didn't suit me. With the line below it achieved the best results.

(setq magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1)

Other display functions can be found by the prefix magit-display-buffer-.

Rigotti
  • 2,766
  • 23
  • 28