Fix #3726: respect +magit-open-windows-in-direction

Also fixes an issue where `q` would not delete a magit-dedicated split
window (leaving duplicate magit-status windows about).
This commit is contained in:
Henrik Lissner 2020-08-11 13:48:12 -04:00
parent 050ac73789
commit 95c5ebc01a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 19 additions and 10 deletions

View file

@ -63,18 +63,26 @@
This differs from `display-buffer-in-direction' in one way: it will try to use a This differs from `display-buffer-in-direction' in one way: it will try to use a
window that already exists in that direction. It will split otherwise." window that already exists in that direction. It will split otherwise."
(let ((direction (or (alist-get 'direction alist) (let ((direction (or (alist-get 'direction alist)
+magit-open-windows-in-direction))) +magit-open-windows-in-direction))
(origin-window (selected-window)))
(if-let (window (window-in-direction direction)) (if-let (window (window-in-direction direction))
(select-window window) (select-window window)
(if-let (window (window-in-direction (if-let (window (and (not (one-window-p))
(window-in-direction
(pcase direction (pcase direction
(`right 'left) (`right 'left)
(`left 'right) (`left 'right)
((or `up `above) 'down) ((or `up `above) 'down)
((or `down `below) 'up)))) ((or `down `below) 'up)))))
(select-window window) (select-window window)
(split-window-horizontally))) (let ((window (split-window nil nil direction)))
(switch-to-buffer buffer) (when (memq direction '(right down below))
(select-window window))
(display-buffer-record-window 'reuse window buffer)
(set-window-buffer window buffer)
(set-window-parameter window 'quit-restore (list 'window 'window origin-window buffer))
(set-window-prev-buffers window nil))))
(switch-to-buffer buffer t t)
(selected-window))) (selected-window)))

View file

@ -75,7 +75,8 @@ For example, diffs and log buffers. Accepts `left', `right', `up', and `down'.")
;; 2. The status screen isn't buried when viewing diffs or logs from the ;; 2. The status screen isn't buried when viewing diffs or logs from the
;; status screen. ;; status screen.
(setq transient-display-buffer-action '(display-buffer-below-selected) (setq transient-display-buffer-action '(display-buffer-below-selected)
magit-display-buffer-function #'+magit-display-buffer-fn) magit-display-buffer-function #'+magit-display-buffer-fn
magit-bury-buffer-function #'magit-mode-quit-window)
(set-popup-rule! "^\\(?:\\*magit\\|magit:\\| \\*transient\\*\\)" :ignore t) (set-popup-rule! "^\\(?:\\*magit\\|magit:\\| \\*transient\\*\\)" :ignore t)
(add-hook 'magit-popup-mode-hook #'hide-mode-line-mode) (add-hook 'magit-popup-mode-hook #'hide-mode-line-mode)