3

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?

4

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.

| improve this answer | |
3

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)
| improve this answer | |
  • 1
    This 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 Oct 7 '14 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 Oct 7 '14 at 22:40
  • actually, I asked because the Readme does not say what the exit-command is used for. :-) – Malabarba Oct 8 '14 at 5:46
  • Agreed, it's unclear. I've filed a patch. – sanityinc Oct 8 '14 at 7:36
  • 1
    Sorry @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 Oct 8 '14 at 17:13
2

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.

| improve this answer | |
1

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.

| improve this answer | |
0

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.