Improve magit display-buffer logic

Now opens derivative magit buffers (from popup magit windows) in
fullscreen.
This commit is contained in:
Henrik Lissner 2018-06-16 14:38:52 +02:00
parent 709c708376
commit c305d63dd7
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -8,10 +8,21 @@
popups. popups.
2. The status screen isn't buried when viewing diffs or logs from the status 2. The status screen isn't buried when viewing diffs or logs from the status
screen." screen."
(let ((buffer-mode (buffer-local-value 'major-mode buffer)))
(display-buffer (display-buffer
buffer (cond ((or (bound-and-true-p git-commit-mode) buffer (cond
;; If opened from a magit window from a popup, open the results
;; full screen. We want to see it all.
((eq (window-dedicated-p) 'side)
'(magit--display-buffer-fullframe))
;; From a commit or magit-log buffer, open detail buffers below
;; this one.
((or (bound-and-true-p git-commit-mode)
(derived-mode-p 'magit-log-mode)) (derived-mode-p 'magit-log-mode))
'(display-buffer-below-selected)) '(display-buffer-below-selected))
;; From a magit buffer, set aside the magit-status window if it
;; exists (we want it always to be visible), then display the
;; target buffer in the current window.
((derived-mode-p 'magit-mode) ((derived-mode-p 'magit-mode)
(when (eq major-mode 'magit-status-mode) (when (eq major-mode 'magit-status-mode)
(display-buffer-in-side-window (display-buffer-in-side-window
@ -19,16 +30,19 @@
(window-width . 0.35) (window-width . 0.35)
(window-parameters (quit))))) (window-parameters (quit)))))
'(display-buffer-same-window)) '(display-buffer-same-window))
((buffer-local-value 'git-commit-mode buffer) ;; If the target buffer opening is a commit, revision or diff, we
;; want to see the whole thing.
((or (buffer-local-value 'git-commit-mode buffer)
(memq buffer-mode '(magit-revision-mode magit-diff-mode)))
'(magit--display-buffer-fullframe)) '(magit--display-buffer-fullframe))
((memq (buffer-local-value 'major-mode buffer) ;; log/stash/process buffers, unless opened from a magit-status
'(magit-process-mode ;; window, should be opened in popups.
magit-revision-mode ((memq buffer-mode '(magit-process-mode
magit-log-mode magit-log-mode
magit-diff-mode
magit-stash-mode)) magit-stash-mode))
'(display-buffer-in-side-window)) '(display-buffer-in-side-window))
('(magit--display-buffer-fullframe))))) ;; Last resort: plain old fullscreen.
('(magit--display-buffer-fullframe))))))
;; ;;