emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 18b680cfd1: Fix bug#52467 by adding a new custom variable 'displa


From: Sam Steingold
Subject: master 18b680cfd1: Fix bug#52467 by adding a new custom variable 'display-comint-buffer-action'
Date: Tue, 28 Dec 2021 17:30:09 -0500 (EST)

branch: master
commit 18b680cfd177e877991be2bd70ead628bbdc0aa0
Author: Sam Steingold <sdsg@amazon.com>
Commit: Sam Steingold <sdsg@amazon.com>

    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'.
---
 lisp/cmuscheme.el          | 4 ++--
 lisp/eshell/eshell.el      | 2 +-
 lisp/org/ol-eshell.el      | 2 +-
 lisp/progmodes/inf-lisp.el | 2 +-
 lisp/progmodes/project.el  | 4 ++--
 lisp/shell.el              | 2 +-
 lisp/textmodes/tex-mode.el | 6 +++---
 lisp/window.el             | 8 ++++++++
 8 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/lisp/cmuscheme.el b/lisp/cmuscheme.el
index 47113ad8c2..acc0888907 100644
--- a/lisp/cmuscheme.el
+++ b/lisp/cmuscheme.el
@@ -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)
diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el
index c66ad00072..47fdfa095f 100644
--- a/lisp/eshell/eshell.el
+++ b/lisp/eshell/eshell.el
@@ -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))
diff --git a/lisp/org/ol-eshell.el b/lisp/org/ol-eshell.el
index a7550e3769..b13f659b22 100644
--- a/lisp/org/ol-eshell.el
+++ b/lisp/org/ol-eshell.el
@@ -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)
diff --git a/lisp/progmodes/inf-lisp.el b/lisp/progmodes/inf-lisp.el
index e69a9ff394..2d2061e7cf 100644
--- a/lisp/progmodes/inf-lisp.el
+++ b/lisp/progmodes/inf-lisp.el
@@ -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)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 3b634471ac..62dba7b393 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -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
diff --git a/lisp/shell.el b/lisp/shell.el
index 370532ea46..1860e4691d 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -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.
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 5fba93c76e..0c112b2ecf 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -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))
diff --git a/lisp/window.el b/lisp/window.el
index aff99d36c5..d75dd9931b 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]