5

In previous versions (before 2.3) M-x magit-status showed the status buffer taking the whole size of the current window. However, now it instead pops up a half-sized buffer (like e.g. C-h f does). This looked fine but only until I wanted to review a diff of changes, as then it became apparent I want a full-sized window with the status buffer.

Is it possible to return the previous behavior of M-x magit-status?

1
  • 1
    The 2.3 release notes discuss this change a bit, see raw.githubusercontent.com/magit/magit/master/Documentation/…. "All Magit-Mode buffers ... are now displayed using magit-display-buffer, which is a wrapper around the low-level display-buffer ... " There is some additional discussion about how to customize buffer display behavior via the magit-display-buffer-function option, but I haven't experimented with this yet.
    – glucas
    Commented Oct 29, 2015 at 15:12

2 Answers 2

5

Magit itself did never make the status buffer full screen. But many starter-kits do that and there also exist a few blog posts which explain how to do it. You are probably using such a starter-kit or a snippet you found somewhere, and that code stopped working due to changes in Magit v2.3.

These changes are actually intended to make it easier to customize how Magit buffers are displayed and switched to, but apparently these changes also break some existing kludges which were previously used to accomplish the same without any explicit support in Magit.

Starting with v2.3 Magit displays all Magit (-mode derived) buffers using magit-display-buffer which in turn calls the function specified by the option magit-display-buffer-function. The default value is magit-display-buffer-traditional which displays the buffer in much the same way as in previous releases. All the rules which control how certain Magit buffers are displayed are now contained in this function, previously they were scattered all over the place.

You can learn more about this in Switching Buffers from the Magit manual and in Choosing a Window for Display from the Elisp manual.

Once you have found a satisfactory solution to make the status buffer full screen (which uses "display actions" instead of third party packages), then please post that here.

9
  • FWIW, the solution I posted is still working. But thanks for this comment, I'll try reworking that "fix" with solution closer to Magit standards. Commented Oct 29, 2015 at 18:11
  • Well, in the post itself I said "as large as the current window", which is what I really meant, title is a misnomer. To return the old behavior I now customize magit-display-buffer-function to (lambda (buffer) (switch-to-buffer buffer) (selected-window)).
    – user8782
    Commented Oct 30, 2015 at 8:28
  • Which is not that good, because it also makes diff buffer when committing take the whole window... In general, new options are nice, except it would be even nicer if you provided a simple way to retain old behavior.
    – user8782
    Commented Oct 30, 2015 at 10:47
  • I did. magit-display-buffer-traditional is supposed to display the buffer as it would traditionally have been displayed, and I think it mostly succeeds in that. What broke is a third-party hack and I now provide a way to implement that without using a hack. Implementing that is quite simple, though not as trivial as the snippet you posted.
    – tarsius
    Commented Oct 30, 2015 at 11:00
  • 1
    You could improve you snippet by adding (if (derived-mode-p 'magit-status-mode) ....
    – tarsius
    Commented Oct 30, 2015 at 11:06
4

This is what I was doing before Magit 2.3, adapted from What the .emacs.d!?:

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

(defun magit-quit-session ()
  "Restore previous window configuration and cleanup buffers."
  (interactive)
  (mu-kill-buffers "^\\*magit")
  (jump-to-register :magit-fullscreen))

(bind-key "q" #'magit-quit-session magit-status-mode-map)

(defun mu-kill-buffers (regexp)
  "Kill buffers matching REGEXP without asking for confirmation."
  (interactive "sKill buffers matching this regular expression: ")
  (cl-letf (((symbol-function 'kill-buffer-ask)
             (lambda (buffer) (kill-buffer buffer))))
    (kill-matching-buffers regexp)))

The difference from the solution on What the .emacs.d!? is that I like q to close all Magit buffers and not only magit-status.

If you don't have bind-key, you can just use regular define-key:

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

Following the new Magit guidelines, this is the solution that is now working for me:

(setq magit-post-display-buffer-hook
      #'(lambda ()
          (when (derived-mode-p 'magit-status-mode)
            (delete-other-windows))))
3
  • -1 for using advices for what can be done with existing configuration options.
    – user227
    Commented Oct 29, 2015 at 22:27
  • Yes, as I wrote in the comment on tarsius answer, I'm working on a solution that uses existing options. This was an old fix that has been serving me well so far. Commented Oct 30, 2015 at 8:01
  • @lunaryorn edited my answer according to new Magit standards. Commented Oct 30, 2015 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.