\f
* Lisp Changes in Emacs 30.1
+---
+** New variable 'read-buffer-to-switch-current-buffer'.
+'read-buffer-to-switch' let-binds this variable to the current buffer
+from which you are switching. You can check for this variable in your
+'read-buffer-function' to determine if the caller intends to switch to
+the buffer that this function reads.
+
** New function 'merge-ordered-lists'.
Mostly used internally to do a kind of topological sort of
inheritance hierarchies.
(minibuffer-maybe-quote-filename val))))
val))))
+(defun buffers-except-current-if-switching (string pred action)
+ "Perform completion ACTION of STRING subject to PRED.
+
+This is similar to `internal-complete-buffer', except that this
+function excludes `read-buffer-to-switch-current-buffer' when it
+is not nil."
+ (let* ((except (when read-buffer-to-switch-current-buffer
+ (buffer-name read-buffer-to-switch-current-buffer)))
+ (predicate
+ (if except
+ (lambda (name)
+ (and (or (not pred) (funcall pred name))
+ (not (equal except (car (ensure-list name))))))
+ pred)))
+ (internal-complete-buffer string predicate action)))
+
(defun internal-complete-buffer-except (&optional buffer)
"Perform completion on all buffers excluding BUFFER.
BUFFER nil or omitted means use the current buffer.
:group 'windows
:group 'tex-run)
+(defvar read-buffer-to-switch-current-buffer nil
+ "Buffer that `read-buffer-to-switch' ignores as a completion candidate.
+
+`read-buffer-to-switch' let-binds this variable to the current
+buffer when you invoke that function. When
+`read-buffer-to-switch' is not executing, this variable is nil.")
+
(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."
- (read-buffer prompt (other-buffer (current-buffer))
- (confirm-nonexistent-file-or-buffer)))
+ (let ((read-buffer-to-switch-current-buffer (current-buffer)))
+ (read-buffer prompt (other-buffer (current-buffer))
+ (confirm-nonexistent-file-or-buffer))))
(defun window-normalize-buffer-to-switch-to (buffer-or-name)
"Normalize BUFFER-OR-NAME argument of buffer switching functions.
CONSP (def) ? XCAR (def) : def);
}
- result = Fcompleting_read (prompt, intern ("internal-complete-buffer"),
+ result = Fcompleting_read (prompt, intern ("buffers-except-current-if-switching"),
predicate, require_match, Qnil,
Qbuffer_name_history, def, Qnil);
}