1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-03 22:20:52 -08:00

Fix bug#52467 by adding a new custom variable 'display-comint-buffer-action'

* lisp/window.el (display-comint-buffer-action): New `defcustom`,
defaults to 'display-buffer-same-window' for backward compatibility.
* lisp/cmuscheme.el (run-scheme, switch-to-scheme): Pass
'display-comint-buffer-action' to 'pop-to-buffer' instead
of using 'pop-to-buffer-same-window'.
* lisp/eshell/eshell.el (eshell): Likewise.
* lisp/shell.el (shell): Likewise.
* lisp/org/ol-eshell.el (org-eshell-open): Likewise.
* lisp/progmodes/inf-lisp.el (inferior-lisp): Likewise.
* lisp/progmodes/project.el (project-shell, project-eshell): Likewise.
* lisp/textmodes/tex-mode.el (tex-display-shell, tex-compile-default)
(tex-recenter-output-buffer): Pass 'display-comint-buffer-action'
to 'pop-to-buffer'.
This commit is contained in:
Sam Steingold 2021-12-28 17:27:41 -05:00
parent 6e52becfbe
commit 18b680cfd1
8 changed files with 19 additions and 11 deletions

View file

@ -237,7 +237,7 @@ is run).
(inferior-scheme-mode)))
(setq scheme-program-name cmd)
(setq scheme-buffer "*scheme*")
(pop-to-buffer-same-window "*scheme*"))
(pop-to-buffer "*scheme*" display-comint-buffer-action))
(defun scheme-start-file (prog)
"Return the name of the start file corresponding to PROG.
@ -357,7 +357,7 @@ With argument, position cursor at end of buffer."
(interactive "P")
(if (or (and scheme-buffer (get-buffer scheme-buffer))
(scheme-interactively-start-process))
(pop-to-buffer-same-window scheme-buffer)
(pop-to-buffer scheme-buffer display-comint-buffer-action)
(error "No current process buffer. See variable `scheme-buffer'"))
(when eob-p
(push-mark)

View file

@ -260,7 +260,7 @@ information on Eshell, see Info node `(eshell)Top'."
(t
(get-buffer-create eshell-buffer-name)))))
(cl-assert (and buf (buffer-live-p buf)))
(pop-to-buffer-same-window buf)
(pop-to-buffer buf display-comint-buffer-action)
(unless (derived-mode-p 'eshell-mode)
(eshell-mode))
buf))

View file

@ -46,7 +46,7 @@ followed by a colon."
(eshell-buffer-name (car buffer-and-command))
(command (cadr buffer-and-command)))
(if (get-buffer eshell-buffer-name)
(pop-to-buffer-same-window eshell-buffer-name)
(pop-to-buffer eshell-buffer-name display-comint-buffer-action)
(eshell))
(goto-char (point-max))
(eshell-kill-input)

View file

@ -308,7 +308,7 @@ quoted using shell quote syntax.
"inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
(inferior-lisp-mode)))
(setq inferior-lisp-buffer "*inferior-lisp*")
(pop-to-buffer-same-window "*inferior-lisp*"))
(pop-to-buffer "*inferior-lisp*" display-comint-buffer-action))
;;;###autoload
(defalias 'run-lisp 'inferior-lisp)

View file

@ -1015,7 +1015,7 @@ if one already exists."
(default-project-shell-name (project-prefixed-buffer-name "shell"))
(shell-buffer (get-buffer default-project-shell-name)))
(if (and shell-buffer (not current-prefix-arg))
(pop-to-buffer-same-window shell-buffer)
(pop-to-buffer shell-buffer display-comint-buffer-action)
(shell (generate-new-buffer-name default-project-shell-name)))))
;;;###autoload
@ -1031,7 +1031,7 @@ if one already exists."
(eshell-buffer-name (project-prefixed-buffer-name "eshell"))
(eshell-buffer (get-buffer eshell-buffer-name)))
(if (and eshell-buffer (not current-prefix-arg))
(pop-to-buffer-same-window eshell-buffer)
(pop-to-buffer eshell-buffer display-comint-buffer-action)
(eshell t))))
;;;###autoload

View file

@ -758,7 +758,7 @@ Make the shell buffer the current buffer, and return it.
(current-buffer)))
;; The buffer's window must be correctly set when we call comint
;; (so that comint sets the COLUMNS env var properly).
(pop-to-buffer-same-window buffer)
(pop-to-buffer buffer)
(with-connection-local-variables
;; On remote hosts, the local `shell-file-name' might be useless.

View file

@ -2037,7 +2037,7 @@ In the tex shell buffer this command behaves like `comint-send-input'."
(defun tex-display-shell ()
"Make the TeX shell buffer visible in a window."
(display-buffer (tex-shell-buf))
(display-buffer (tex-shell-buf) display-comint-buffer-action)
(tex-recenter-output-buffer nil))
(defun tex-shell-sentinel (proc _msg)
@ -2441,7 +2441,7 @@ Only applies the FSPEC to the args part of FORMAT."
(if cmds (tex-format-cmd (caar cmds) fspec))))))
(defun tex-cmd-doc-view (file)
(pop-to-buffer (find-file-noselect file)))
(pop-to-buffer (find-file-noselect file) display-comint-buffer-action))
(defun tex-compile (dir cmd)
"Run a command CMD on current TeX buffer's file in DIR."
@ -2698,7 +2698,7 @@ line LINE of the window, or centered if LINE is nil."
(window))
(if (null tex-shell)
(message "No TeX output buffer")
(setq window (display-buffer tex-shell))
(setq window (display-buffer tex-shell display-comint-buffer-action))
(with-selected-window window
(bury-buffer tex-shell)
(goto-char (point-max))

View file

@ -7474,6 +7474,14 @@ ALIST. See `display-buffer' for details."
:version "24.1"
:group 'windows)
(defcustom display-comint-buffer-action 'display-buffer-same-window
"The action to display a comint buffer."
:type 'display-buffer--action-function-custom-type
:risky t
:version "29.1"
:group 'windows
:group 'comint)
(defconst display-buffer-fallback-action
'((display-buffer--maybe-same-window ;FIXME: why isn't this redundant?
display-buffer-reuse-window