From 8a45d6850597ffd90ecb8d3c1036b8117cb9c4cf Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Mon, 2 May 2022 12:55:47 +0100 Subject: [PATCH] el/dot-emacs.el: Override Magit buffer display logic. It's actually nearly right, except that it wants to cover existing Magit windows with commit log and that's a mistake. Implement a new version of `magit-display-buffer-traditional' which (a) uses a list of modes in a variable rather than hardcoding it, and (b) honours a designated window if there is one. --- el/dot-emacs.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index c7849f3..09b7708 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -5166,6 +5166,29 @@ there is sadness." (smerge-mode 1)))) (add-hook 'find-file-hook 'mdw-try-smerge t) +(defcustom mdw-magit-new-window-modes + '(magit-diff-mode + magit-log-mode + magit-process-mode + magit-revision-mode + magit-stash-mode + magit-status-mode) + "Magit modes which should cause a new window to be used." + :type '(repeat symbol)) + +(defun mdw-display-magit-buffer (buffer) + "Like `magit-display-buffer-traditional'. +But uses `mdw-magit-new-window-modes' for its list of modes +rather than baking the list into the function." + (display-buffer buffer + (if (and (not mdw-designated-window) + (derived-mode-p 'magit-mode) + (not (memq (with-current-buffer buffer major-mode) + mdw-magit-new-window-modes))) + '(display-buffer-same-window . nil) + nil))) +(setq magit-display-buffer-function 'mdw-display-magit-buffer) + ;;;-------------------------------------------------------------------------- ;;; GUD, and especially GDB. -- 2.11.0