mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
fix(magit): polish +magit-display-buffer-fn
- Ensure `magit-log-select-mode` windows use the same window as the magit-status buffer, and that the revision buffer is displayed below it (similar to commit window configs). - Uses the same window when invoking diffs (#8083). Fix: #8083
This commit is contained in:
@ -20,27 +20,42 @@
|
||||
(let ((buffer-mode (buffer-local-value 'major-mode buffer)))
|
||||
(display-buffer
|
||||
buffer (cond
|
||||
;; Prevent opening multiple status windows for the same project.
|
||||
((and (eq buffer-mode 'magit-status-mode)
|
||||
(get-buffer-window buffer))
|
||||
'(display-buffer-reuse-window))
|
||||
;; Any magit buffers opened from a commit window should open below
|
||||
;; it. Also open magit process windows below.
|
||||
((or (bound-and-true-p git-commit-mode)
|
||||
(eq buffer-mode 'magit-process-mode))
|
||||
|
||||
((or
|
||||
;; Any magit buffers opened from a commit window should open
|
||||
;; below the selected one.
|
||||
(bound-and-true-p git-commit-mode)
|
||||
;; ...Or process log buffers...
|
||||
(eq buffer-mode 'magit-process-mode)
|
||||
;; Nothing should replace the log-select buffer (revision buffers
|
||||
;; during rebasing, in particular).
|
||||
(eq major-mode 'magit-log-select-mode))
|
||||
(let ((size (if (eq buffer-mode 'magit-process-mode)
|
||||
0.35
|
||||
0.7)))
|
||||
`(display-buffer-below-selected
|
||||
. ((window-height . ,(truncate (* (window-height) size)))))))
|
||||
|
||||
;; Everything else should reuse the current window.
|
||||
((or (not (derived-mode-p 'magit-mode))
|
||||
(not (memq (with-current-buffer buffer major-mode)
|
||||
'(magit-process-mode
|
||||
magit-revision-mode
|
||||
magit-diff-mode
|
||||
magit-stash-mode
|
||||
magit-status-mode))))
|
||||
((or
|
||||
;; If triggered from outside of magit, open magit in the current
|
||||
;; window, rather than a far-away one.
|
||||
(not (derived-mode-p 'magit-mode))
|
||||
;; If invoking a diff from the status buffer, use that window.
|
||||
(and (eq major-mode 'magit-status-mode)
|
||||
(memq buffer-mode
|
||||
'(magit-diff-mode
|
||||
magit-stash-mode)))
|
||||
;; These buffers should open in another (but nearby) window,
|
||||
;; because they compliment the current one being visible.
|
||||
(not (memq buffer-mode
|
||||
'(magit-process-mode
|
||||
magit-revision-mode
|
||||
magit-stash-mode
|
||||
magit-status-mode))))
|
||||
'(display-buffer-same-window))
|
||||
|
||||
('(+magit--display-buffer-in-direction))))))
|
||||
|
Reference in New Issue
Block a user