You can customize variable display-buffer-alist
to fine-tune how Emacs handle creating a new window.
Read its documentation C-h v display-buffer-alist
or the info node on this topic at (elisp) Choosing Window if you had some spare time.
Here is also a good youtube video on this topic from Protesilaos, Emacs: window rules and parameters (`display-buffer-alist' and extras)
I want Emacs to always create a new buffer for its warnings or messages (and other similar buffers)
Put this somewhere in your configuration file,
(setq display-buffer-alist ;; Setting window rules
("\\*messages.*" ;; For buffer with a name beginning with "*messages",
(display-buffer-in-side-window) ;; Display it in side window
(window-width . 0.25) ;; Side window takes up 1/4th of the screen
(side . right) ;; On the right side of the screen, please
)
("\\*warnings.*" ;; For buffer with a name beginning with "*warnings",
(display-buffer-in-side-window) ;; Display it in side window
(window-width . 0.25) ;; Side window takes up 1/4th of the screen
(side . right) ;; On the right side of the screen, please
)
;; Add more if you want ....
)
Remove the comment if it's too much, this makes Emacs consistent you no longer have to think of where to look for the buffer anymore, if it pops up, Emacs will
always put it on the right side of the screen.
(Using "screen" loosely here, it's technically called a "frame".