Subject: Re: bug#52467: 29.0.50; Use pop-to-buffer for shell

From: <[email-masked]>
Date: Mon, 27 Dec 2021 10:32:13 +0100

Sam Steingold <[email-masked]> writes:

> I think predictability if not the only or even main concern.
>
> The current behavior is _not_ user-customizable, which is a major
> problem for me. I hardly ever want the same buffer displayed _twice_,
> especially the *shell* buffer.
>
> Whatever default behavior you want (and for me it's definitely
> reuse-window) should be implemented using a new user variable
> `shell-display-buffer-action' that would be used by `shell',
> `project-shell', `eshell', &c.

It is user configurable through 'display-buffer-alist, see my other
reply to this thread. To prevent creation of duplicate windows showing
the same shell buffer, do

   (add-to-list 'display-buffer-alist
                '("\\`\\*shell\\*" display-buffer-reuse-window))

For old behaviour of popping up a new shell window, do

   (add-to-list 'display-buffer-alist
                '("\\`\\*shell\\*"
                  (display-buffer-reuse-window display-buffer-pop-up-window)))

The same can be done for eshell, terminal and most other buffers
displayed with 'display-buffer-same-window'.

> This is not a major change, so I propose that we close this bug by
> adding `shell-display-buffer-action' (I can do that), and continue the
> discussion of the best default on emacs-devel.

I'm personally against adding such an user option.

If it were added for M-x shell, eshell and term, the same reasoning
could be used to add it for M-x run-scheme, dired, dunnet and all the
other places using 'pop-to-buffer-same-window'. This would add up to a
lot of variables for little benefit since we can already customize
window pop-up behaviour of all these commands with
'display-buffer-alist'.

> Thank you.