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?

有帮助吗?

解决方案

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

or via customize:

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

其他提示

Here is another way to achieve this:

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

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 this to get a zen-like full window git status after switching projects:

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

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.

I use this:

(defun my-magit-status ()
  "Don't split window."
  (interactive)
  (let ((pop-up-windows nil))
    (call-interactively 'magit-status)))

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)))))

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)))

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-.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top