1

I have a little issue, not too big but a little annoying.

Suppose I open 3 windows in my Emacs GNU like this:

enter image description here

Once I position myself in any window (the largest one, in this screenshot) and press/type M-x shell, the sub shell opens in the next window, which is in this case the first one.

I wonder why this happens and how to fix it?

Billal Begueradj
  • 345
  • 1
  • 5
  • 18
  • 1
    The following link demonstrates how to make a shell buffer that does not display in any window by default, and then there are a variety of examples demonstrating how to display the shell buffer with built-in functions and there is also a custom function to display it wherever you want; e.g., above, below, left, right. https://emacs.stackexchange.com/a/28924/2287 – lawlist Jul 13 '18 at 14:53
  • (I wonder if this question might be a duplicate...) – Drew Jul 13 '18 at 18:00

1 Answers1

1

By default emacs will display the shell buffer in a different window from the selected one. You can override this by using display-buffer-alist to specify different actions based on the buffer name. In this case, setting it to

(setq display-buffer-alist '((".*\\*shell\\*.*" display-buffer-same-window (nil))))

will get you the behaviour you want, although it's probably better to do

M-x customize-variable RET display-buffer-alist RET

There are many options available for how windows are chosen, read

C-h f display-buffer

for the gory details.

Drew
  • 75,699
  • 9
  • 109
  • 225
rpluim
  • 4,605
  • 8
  • 22