Try splitting the frame repeating some times the command C-x 3
.
Then try open the shell with M-x shell
.
It will open in a random window and not the one which you have typed the command from. Why?
The reason is that shell
uses pop-to-buffer
.
If you want to use the selected window try this in your config.
(add-to-list 'display-buffer-alist
`(,(rx bos "*shell*")
display-buffer-same-window
(reusable-frames . visible)))
The following works well in my GNU Emacs 25.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23) of 2017-12-09
(add-to-list 'display-buffer-alist
`(,(rx bos "*shell*")
display-buffer-same-window))
However, with the answer provided by @bertfred I get the error
(wrong-type-argument window-live-p nil)
EDIT:
Here is the content of the *Backtrace*
buffer after M-x shell
with @bertfred's suggested display-buffer-alist
:
Debugger entered--Lisp error: (wrong-type-argument window-live-p nil)
select-window(nil nil)
pop-to-buffer(#<buffer *shell*>)
shell(nil)
funcall-interactively(shell nil)
call-interactively(shell record nil)
command-execute(shell record)
execute-extended-command(nil "shell" "shell")
funcall-interactively(execute-extended-command nil "shell" "shell")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
emacs -Q
? If so, you should consider sending an M-x report-emacs-bug RET
. Either way, you can try debugging this yourself by typing M-x toggle-debug-on-error RET
before invoking the error.
emacs -Q
. However, I am hesitant to file this as a bug since I barely understand the inner workings of display-buffer-alist
.
toggle-debug-on-error
shine any light on what is causing the error? I cannot reproduce your error on any version of Emacs.
emacs -Q
, as you suggested. Does it say anything to you?
switch-to-buffer
in display-buffer-alist
, as its docstring (via that of display-buffer
) explains. Sorry for the confusion and wasting your time. I will edit bertfred's answer and you can remove the debugging information from yours.
pop-to-buffer
or trying to make it behave differently than it was designed.