Subject: bug#70819: [PATCH v2] Make clone-indirect-buffer-other-window use other window (bug#70819)

From: Richard Sent <[email-masked]>
Date: Mon, 27 May 2024 11:32:00 -0400

Previously, depending on the settings in display-buffer-alist,
clone-indirect-buffer-other-window would display the cloned buffer in
the original window, behaving identically to clone-indirect-buffer with
a non-nil display-flag. This behavior was inconsistent with other-window
commands which always used another window.

Now, clone-indirect-buffer-other-window uses
switch-to-buffer-other-window. This means it uses the same logic as
other-window commands like find-file-other-window and info-other-window.

display-flag was kept for API stability and functional compatibility
reasons.

* lisp/simple.el: (clone-indirect-buffer-other-window): Use
switch-to-buffer-other-window.
---
Updated according to feedback from Martin.

 lisp/simple.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index deab52c4201..cf206252c1e 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -10658,8 +10658,10 @@ clone-indirect-buffer-other-window
      (list (if current-prefix-arg
 	       (read-buffer "Name of indirect buffer: " (current-buffer)))
 	   t)))
-  (let ((pop-up-windows t))
-    (clone-indirect-buffer newname display-flag norecord)))
+  ;; For compatibility, don't display the buffer if display-flag is nil.
+  (let ((buffer (clone-indirect-buffer newname nil norecord)))
+    (when display-flag
+      (switch-to-buffer-other-window buffer norecord))))
 
 
 ;;; Handling of Backspace and Delete keys.
-- 
2.41.0