Subject: Re: bug#74361: [PATCH] New option xref-navigation-display-window-action

From: Juri Linkov <[email-masked]>
Date: Mon, 25 Nov 2024 09:28:22 +0200

>> Do you mean that the users might want to shoot themselves in the foot
>> and remove '(category . comint)' from the default value of
>> display-comint-buffer-action?
>
> Yes, that's the scenario that bothers me.  Users could do that without
> understanding the subtleties of the issue.
>
>> Then indeed we need to move '(category . comint)' directly
>> to every display-buffer call that currently uses
>> display-comint-buffer-action.
>
> I think we should do that for Emacs 31, yes.

Ok, here is the patch for Emacs 31:

diff --git a/etc/NEWS b/etc/NEWS
index d7047d0923f..9c5b2db203e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -154,6 +154,12 @@ that the actual killing or burying of the buffer is done by the caller.
 With this option set, 'quit-restore-window' will delete its window more
 aggressively rather than switching to some other buffer in it.
 
+---
+*** The user option 'display-comint-buffer-action' has been removed.
+It has been obsolete since Emacs 30.1.  Use '(category . comint)' instead.
+Another user option 'display-tex-shell-buffer-action' has been removed too
+for which you can use '(category . tex-shell)'.
+
 ** Frames
 
 +++
diff --git a/lisp/cmuscheme.el b/lisp/cmuscheme.el
index d4316fb1175..b03cf1f1840 100644
--- a/lisp/cmuscheme.el
+++ b/lisp/cmuscheme.el
@@ -238,8 +238,8 @@ run-scheme
 	(inferior-scheme-mode)))
   (setq scheme-program-name cmd)
   (setq scheme-buffer "*scheme*")
-  (with-suppressed-warnings ((obsolete display-comint-buffer-action))
-    (pop-to-buffer "*scheme*" display-comint-buffer-action)))
+  (pop-to-buffer "*scheme*" (append display-buffer--same-window-action
+                                    '((category . comint)))))
 
 (defun scheme-start-file (prog)
   "Return the name of the start file corresponding to PROG.
@@ -359,8 +359,8 @@ switch-to-scheme
   (interactive "P")
   (if (or (and scheme-buffer (get-buffer scheme-buffer))
           (scheme-interactively-start-process))
-      (with-suppressed-warnings ((obsolete display-comint-buffer-action))
-        (pop-to-buffer scheme-buffer display-comint-buffer-action))
+      (pop-to-buffer scheme-buffer (append display-buffer--same-window-action
+                                           '((category . comint))))
     (error "No current process buffer.  See variable `scheme-buffer'"))
   (when eob-p
     (push-mark)
diff --git a/lisp/shell.el b/lisp/shell.el
index 6cfae470cd7..33d80061ada 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -953,8 +953,8 @@ shell
                  (current-buffer)))
   ;; The buffer's window must be correctly set when we call comint
   ;; (so that comint sets the COLUMNS env var properly).
-  (with-suppressed-warnings ((obsolete display-comint-buffer-action))
-    (pop-to-buffer buffer display-comint-buffer-action))
+  (pop-to-buffer buffer (append display-buffer--same-window-action
+                                '((category . comint))))
 
   (with-connection-local-variables
    (when file-name
diff --git a/lisp/window.el b/lisp/window.el
index c790118c5e0..e9d57652ec6 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -9115,35 +9115,6 @@ pop-to-buffer-same-window
 another window."
   (pop-to-buffer buffer display-buffer--same-window-action norecord))
 
-(defcustom display-comint-buffer-action
-  (append display-buffer--same-window-action '((category . comint)))
-  "`display-buffer' action for displaying comint buffers."
-  :type display-buffer--action-custom-type
-  :risky t
-  :version "29.1"
-  :group 'windows
-  :group 'comint)
-
-(make-obsolete-variable
- 'display-comint-buffer-action
- "use a `(category . comint)' condition in `display-buffer-alist'."
- "30.1")
-
-(defcustom display-tex-shell-buffer-action '(display-buffer-in-previous-window
-                                             (inhibit-same-window . t)
-                                             (category . tex-shell))
-  "`display-buffer' action for displaying TeX shell buffers."
-  :type display-buffer--action-custom-type
-  :risky t
-  :version "29.1"
-  :group 'windows
-  :group 'tex-run)
-
-(make-obsolete-variable
- 'display-tex-shell-buffer-action
- "use a `(category . tex-shell)' condition in `display-buffer-alist'."
- "30.1")
-
 (defun read-buffer-to-switch (prompt)
   "Read the name of a buffer to switch to, prompting with PROMPT.
 Return the name of the buffer as a string.
diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el
index fc08734d5f3..3def918bdd1 100644
--- a/lisp/eshell/eshell.el
+++ b/lisp/eshell/eshell.el
@@ -278,8 +278,8 @@ eshell
 		   (t
 		    (get-buffer-create eshell-buffer-name)))))
     (cl-assert (and buf (buffer-live-p buf)))
-    (with-suppressed-warnings ((obsolete display-comint-buffer-action))
-      (pop-to-buffer buf display-comint-buffer-action))
+    (pop-to-buffer buf (append display-buffer--same-window-action
+                               '((category . comint))))
     (unless (derived-mode-p 'eshell-mode)
       (eshell-mode))
     buf))
diff --git a/lisp/org/ol-eshell.el b/lisp/org/ol-eshell.el
index 595dd0ee0f8..e364a38c17d 100644
--- a/lisp/org/ol-eshell.el
+++ b/lisp/org/ol-eshell.el
@@ -51,9 +51,9 @@ org-eshell-open
     (if (get-buffer eshell-buffer-name)
         (pop-to-buffer
          eshell-buffer-name
-         (if (boundp 'display-comint-buffer-action) ; Emacs >= 29
+         (if (boundp 'display-comint-buffer-action) ; Emacs >= 29, <= 30
              display-comint-buffer-action
-           '(display-buffer-same-window (inhibit-same-window))))
+           '(display-buffer-same-window (inhibit-same-window) (category . comint))))
       (eshell))
     (goto-char (point-max))
     (eshell-kill-input)
diff --git a/lisp/progmodes/inf-lisp.el b/lisp/progmodes/inf-lisp.el
index 85fc6b930f5..b092b3b679c 100644
--- a/lisp/progmodes/inf-lisp.el
+++ b/lisp/progmodes/inf-lisp.el
@@ -308,8 +308,8 @@ inferior-lisp
 			   "inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
 	(inferior-lisp-mode)))
   (setq inferior-lisp-buffer "*inferior-lisp*")
-  (with-suppressed-warnings ((obsolete display-comint-buffer-action))
-    (pop-to-buffer "*inferior-lisp*" display-comint-buffer-action)))
+  (pop-to-buffer "*inferior-lisp*" (append display-buffer--same-window-action
+                                           '((category . comint)))))
 
 ;;;###autoload
 (defalias 'run-lisp 'inferior-lisp)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index cf1c94a6d20..94f70c9a854 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1376,7 +1376,8 @@ project-shell
          (shell-buffer (get-buffer default-project-shell-name)))
     (if (and shell-buffer (not current-prefix-arg))
         (if (comint-check-proc shell-buffer)
-            (pop-to-buffer shell-buffer (bound-and-true-p display-comint-buffer-action))
+            (pop-to-buffer shell-buffer (append display-buffer--same-window-action
+                                                '((category . comint))))
           (shell shell-buffer))
       (shell (generate-new-buffer-name default-project-shell-name)))))
 
@@ -1393,7 +1394,8 @@ project-eshell
          (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 eshell-buffer (bound-and-true-p display-comint-buffer-action))
+        (pop-to-buffer eshell-buffer (append display-buffer--same-window-action
+                                             '((category . comint))))
       (eshell t))))
 
 ;;;###autoload
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 8ba64100203..397a66582fa 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1435,8 +1435,9 @@ sh-shell-process
 (defun sh-show-shell ()
   "Pop the shell interaction buffer."
   (interactive)
-  (with-suppressed-warnings ((obsolete display-comint-buffer-action))
-    (pop-to-buffer (process-buffer (sh-shell-process t)) display-comint-buffer-action)))
+  (pop-to-buffer (process-buffer (sh-shell-process t))
+                 (append display-buffer--same-window-action
+                         '((category . comint)))))
 
 (defun sh-send-text (text)
   "Send TEXT to `sh-shell-process'."
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 9cb95f59da4..06a45112719 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -2092,8 +2092,9 @@ tex-feed-input
 
 (defun tex-display-shell ()
   "Make the TeX shell buffer visible in a window."
-  (with-suppressed-warnings ((obsolete display-tex-shell-buffer-action))
-    (display-buffer (tex-shell-buf) display-tex-shell-buffer-action))
+  (display-buffer (tex-shell-buf) '(display-buffer-in-previous-window
+                                    (inhibit-same-window . t)
+                                    (category . tex-shell)))
   (tex-recenter-output-buffer nil))
 
 (defun tex-shell-sentinel (proc _msg)
@@ -2753,8 +2754,9 @@ tex-recenter-output-buffer
     (if (null tex-shell)
 	(message "No TeX output buffer")
       (when-let* ((window
-                   (with-suppressed-warnings ((obsolete display-tex-shell-buffer-action))
-                     (display-buffer tex-shell display-tex-shell-buffer-action))))
+                   (display-buffer tex-shell '(display-buffer-in-previous-window
+                                               (inhibit-same-window . t)
+                                               (category . tex-shell)))))
         (with-selected-window window
 	  (bury-buffer tex-shell)
 	  (goto-char (point-max))