Function: read-buffer-to-switch

read-buffer-to-switch is a byte-compiled function defined in window.el.gz.

Signature

(read-buffer-to-switch PROMPT)

Documentation

Read the name of a buffer to switch to, prompting with PROMPT.

Return the name of the buffer as a string.

This function is intended for the switch-to-buffer family of commands since these need to omit the name of the current buffer from the list of completions and default values.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(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.

This function is intended for the `switch-to-buffer' family of
commands since these need to omit the name of the current buffer
from the list of completions and default values."
  (let ((rbts-completion-table (internal-complete-buffer-except)))
    (minibuffer-with-setup-hook
        (lambda ()
          (setq-local minibuffer-completion-table rbts-completion-table)
          ;; Since rbts-completion-table is built dynamically, we
          ;; can't just add it to the default value of
          ;; icomplete-with-completion-tables, so we add it
          ;; here manually.
          (if (and (boundp 'icomplete-with-completion-tables)
                   (listp icomplete-with-completion-tables))
              (setq-local icomplete-with-completion-tables
                          (cons rbts-completion-table
                                icomplete-with-completion-tables))))
      (read-buffer prompt (other-buffer (current-buffer))
                   (confirm-nonexistent-file-or-buffer)))))