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)))
|
(let ((buffer-mode (buffer-local-value 'major-mode buffer)))
|
||||||
(display-buffer
|
(display-buffer
|
||||||
buffer (cond
|
buffer (cond
|
||||||
|
;; Prevent opening multiple status windows for the same project.
|
||||||
((and (eq buffer-mode 'magit-status-mode)
|
((and (eq buffer-mode 'magit-status-mode)
|
||||||
(get-buffer-window buffer))
|
(get-buffer-window buffer))
|
||||||
'(display-buffer-reuse-window))
|
'(display-buffer-reuse-window))
|
||||||
;; Any magit buffers opened from a commit window should open below
|
|
||||||
;; it. Also open magit process windows below.
|
((or
|
||||||
((or (bound-and-true-p git-commit-mode)
|
;; Any magit buffers opened from a commit window should open
|
||||||
(eq buffer-mode 'magit-process-mode))
|
;; 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)
|
(let ((size (if (eq buffer-mode 'magit-process-mode)
|
||||||
0.35
|
0.35
|
||||||
0.7)))
|
0.7)))
|
||||||
`(display-buffer-below-selected
|
`(display-buffer-below-selected
|
||||||
. ((window-height . ,(truncate (* (window-height) size)))))))
|
. ((window-height . ,(truncate (* (window-height) size)))))))
|
||||||
|
|
||||||
;; Everything else should reuse the current window.
|
((or
|
||||||
((or (not (derived-mode-p 'magit-mode))
|
;; If triggered from outside of magit, open magit in the current
|
||||||
(not (memq (with-current-buffer buffer major-mode)
|
;; window, rather than a far-away one.
|
||||||
'(magit-process-mode
|
(not (derived-mode-p 'magit-mode))
|
||||||
magit-revision-mode
|
;; If invoking a diff from the status buffer, use that window.
|
||||||
magit-diff-mode
|
(and (eq major-mode 'magit-status-mode)
|
||||||
magit-stash-mode
|
(memq buffer-mode
|
||||||
magit-status-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))
|
'(display-buffer-same-window))
|
||||||
|
|
||||||
('(+magit--display-buffer-in-direction))))))
|
('(+magit--display-buffer-in-direction))))))
|
||||||
|
Reference in New Issue
Block a user