From 3a1fd7b282071ae0dd6fe93907864262c613ba13 Mon Sep 17 00:00:00 2001 From: Sebastian Witte Date: Sat, 10 Oct 2020 19:50:10 +0200 Subject: [PATCH] Respect magit-display-buffer-noselect This fixes the behavior of e.g. magit-diff-show-or-scroll-down. When in magit-log-mode, said action should not move focus to the diff window because it would otherwise behave identical to pressing magit-show-commit. --- modules/tools/magit/autoload.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/tools/magit/autoload.el b/modules/tools/magit/autoload.el index 85c8d7e2c..881a58d4f 100644 --- a/modules/tools/magit/autoload.el +++ b/modules/tools/magit/autoload.el @@ -66,7 +66,8 @@ window that already exists in that direction. It will split otherwise." +magit-open-windows-in-direction)) (origin-window (selected-window))) (if-let (window (window-in-direction direction)) - (select-window window) + (unless magit-display-buffer-noselect + (select-window window)) (if-let (window (and (not (one-window-p)) (window-in-direction (pcase direction @@ -74,16 +75,19 @@ window that already exists in that direction. It will split otherwise." (`left 'right) ((or `up `above) 'down) ((or `down `below) 'up))))) - (select-window window) + (unless magit-display-buffer-noselect + (select-window window)) (let ((window (split-window nil nil direction))) - (when (memq direction '(right down below)) + (when (and (not magit-display-buffer-noselect) + (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))) + (unless magit-display-buffer-noselect + (switch-to-buffer buffer t t) + (selected-window)))) ;;