1

Current behavior:

  • Emacs replaces one of my buffers with *warnings* or *messages* if I have multiple buffers open.
  • However Emacs creates a new buffer and displays *warnings* or *messages* if I have exactly one buffer open.

I want this to be the default behavior on my Emacs, that is, irrespective of how many buffers I may have open, I want Emacs to always create a new buffer for its *warnings* or *messages* (and other similar buffers).

Further I want my Emacs to figure out the following on it's own when creating new buffers:

  1. Tall buffers should always split vertically
  2. Wide buffers should always split horizontally

How do I accomplish this behavior with my Emacs?

Drew
  • 75,699
  • 9
  • 109
  • 225
Inspired_Blue
  • 278
  • 2
  • 12

2 Answers2

1

You can customize the variables split-height-threshold and split-width-threshold to adjust how windows are split. Likely when you already have multiple windows, they are already smaller than split-height-threshold so it opts not to split any of them again.

db48x
  • 15,741
  • 1
  • 19
  • 23
1

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".

C11g
  • 333
  • 1
  • 7