It is possible to configure how a buffer opens (in the same frame/window or a different frame/window) using
display-buffer-alist. Refer to the references below to learn more about this variable.
We need to tell emacs to always open buffers ending with
COMMIT_EDITMSG in a window but not in the same (
*magit ..*) window.
Add the following snippet to the
(require 'magit) to specify this action.
'(".*COMMIT_EDITMSG". ((display-buffer-pop-up-window) .
((inhibit-same-window . t)))))
Breakdown of the solution
display-buffer-alist is an
alist that calls a
FUNCTION (or a list of functions) with
ALIST parameters when a
CONDITION is true. The
display-buffer-alist can be represented as,
'(CONDITION . (FUNCTION . ALIST))
CONDITION is that the buffer name ends with
COMMIT_EDITMSG and that is represented by
FUNCTION to call is
display-buffer-pop-up-window as we want to create a window for this buffer. Instead of specifying the function by itself it's put in as a list of a single function
(display-buffer-pop-up-window)so that more functions can be easily added to the list if needed in future.
(inhibit-same-window . t) as we don't want this buffer to open in the same window.