emacs-devel
[Top][All Lists]
Advanced

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

Allow controlling the effect of visibility on buffer switching


From: Thuna
Subject: Allow controlling the effect of visibility on buffer switching
Date: Wed, 26 Jan 2022 12:10:38 +0300

Currently `read-buffer-to-switch' defaults to non-visible buffers.  An
option to control this behavior could be introduced as follows (a
proof-of-concept, subject to change):

>From a4c2d922e2fc0cd48c95df9622d6f06541f38901 Mon Sep 17 00:00:00 2001
From: Thuna <thuna.cing@gmail.com>
Date: Wed, 26 Jan 2022 11:56:17 +0300
Subject: [PATCH] Allow controlling the effect of visibility on buffer
 switching

---
 lisp/window.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/window.el b/lisp/window.el
index 582600e1c6..ffc09486ef 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8575,6 +8575,12 @@ display-comint-buffer-action
   :group 'windows
   :group 'comint)
 
+(defcustom switch-to-buffer-ignore-visibility nil
+  "If nil, `read-buffer-to-switch' prefer buffers not visible as
+the default buffer to switch to."
+  :type 'boolean
+  :group 'windows)
+
 (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.
@@ -8595,7 +8601,9 @@ read-buffer-to-switch
               (setq-local icomplete-with-completion-tables
                           (cons rbts-completion-table
                                 icomplete-with-completion-tables))))
-      (read-buffer prompt (other-buffer (current-buffer))
+      (read-buffer prompt
+                   (other-buffer (current-buffer)
+                                 switch-to-buffer-ignore-visibility)
                    (confirm-nonexistent-file-or-buffer)))))
 
 (defun window-normalize-buffer-to-switch-to (buffer-or-name)
-- 
2.25.1

There are other functions that might need to have this change applied to
them as well, I imagine.

Autocompletion frameworks would also need to adapt; helm and ivy would
need to fix `helm-mode--read-buffer-to-switch' and `ivy-switch-buffer'
respectively.

reply via email to

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