I'd like magit to default to a large buffer instead of one that is half the size of the available space. Even better would be a way to wrap the call to a major mode to make this happen when opening any major mode?
5 Answers
Not sure about applying this in general but magit has a configuration variable for this, magit-status-buffer-switch-function. By default it is set to pop-to-buffer which prefers to open an alternate buffer, ie other-window or split screen and other-window. However, if you customize the value to switch-to-buffer it will swap out the current buffer for magit-status. Throw the following in your init file and it should open it in the current window:
(setq magit-status-buffer-switch-function 'switch-to-buffer) Edit: It appears the general solution to this problem may be encoded in the documentation for display-buffer, specifically Choosing Window and Display Action Functions.
How about fullframe ?
From their docs:
;;; Open magit-status in a single window in fullscreen (require 'fullframe) (fullframe magit-status magit-mode-quit-window nil) - 1This looks like a nice package. It'd be great to add a few words about it. Does it just make the command full screen, or does it also revert to the previous configuration when quitting?Malabarba– Malabarba2014-10-07 22:34:52 +00:00Commented Oct 7, 2014 at 22:34
- Well, it's documented on their github README. You pass in a function and an 'exit function'. In this example when you quit the magit-status window, it runs magit-mode-quit-window.Mr. Wacky– Mr. Wacky2014-10-07 22:40:30 +00:00Commented Oct 7, 2014 at 22:40
- actually, I asked because the Readme does not say what the exit-command is used for. :-)Malabarba– Malabarba2014-10-08 05:46:58 +00:00Commented Oct 8, 2014 at 5:46
-
- 1Sorry @Malabarba. I guess it made sense to me. Meanwhile, sanityinc posted a more complete answer below. And, of course, I found fullframe by reading his .emacs configs. So he wins!Mr. Wacky– Mr. Wacky2014-10-08 17:13:18 +00:00Commented Oct 8, 2014 at 17:13
Here are some examples using fullframe, lifted straight from my emacs config:
(eval-after-load 'package '(fullframe list-packages quit-window)) (eval-after-load 'magit '(fullframe magit-status magit-mode-quit-window)) (eval-after-load 'ibuffer '(fullframe ibuffer ibuffer-quit)) The first parameter for fullframe is any command which creates and switches to a new window, and the second is a function which is called when that window is quit - either the command the user uses to quit the window, or a command which is called in the course of the window being quit.
Specifically with regards to Magit and magit-status, the following should do the trick for you: Magit Status Fullscreen from Magnar Sveen's What the .emacs.d!? blog.
;; full screen magit-status (defadvice magit-status (around magit-fullscreen activate) (window-configuration-to-register :magit-fullscreen) ad-do-it (delete-other-windows)) ;; restore previously hidden windows (defadvice magit-quit-window (around magit-restore-screen activate) ad-do-it (jump-to-register :magit-fullscreen)) Updated with Brad Wright's comment with regards to restoring previous view.
This is the solution I currently use.
(defadvice magit-status (around magit-fullscreen activate) (window-configuration-to-register :magit-fullscreen) ad-do-it (delete-other-windows)) (defun custom-kill-buffers (regexp) "Kill buffers matching REGEXP without asking for confirmation." (interactive "sKill buffers matching this regular expression: ") (flet ((kill-buffer-ask (buffer) (kill-buffer buffer))) (kill-matching-buffers regexp))) (defun magit-quit-session () "Restores the previous window configuration and kills the magit buffer" (interactive) (custom-kill-buffers "^\\*magit") (jump-to-register :magit-fullscreen)) (define-key magit-status-mode-map (kbd "q") 'magit-quit-session) I customized the solution explained on whattheemacsd.com: I close every magit buffer when I press "q".