Function: with-current-buffer-window

with-current-buffer-window is a macro defined in window.el.gz.

Signature

(with-current-buffer-window BUFFER-OR-NAME ACTION QUIT-FUNCTION &rest BODY)

Documentation

Evaluate BODY with a buffer BUFFER-OR-NAME current and show that buffer.

This construct is like with-temp-buffer-window but unlike that, makes the buffer specified by BUFFER-OR-NAME current for running BODY.

View in manual

Probably introduced at or before Emacs version 28.1.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defmacro with-current-buffer-window (buffer-or-name action quit-function &rest body)
  "Evaluate BODY with a buffer BUFFER-OR-NAME current and show that buffer.
This construct is like `with-temp-buffer-window' but unlike that,
makes the buffer specified by BUFFER-OR-NAME current for running
BODY."
  (declare (debug t) (indent 3))
  (let ((buffer (make-symbol "buffer"))
	(window (make-symbol "window"))
	(value (make-symbol "value")))
    (macroexp-let2* nil ((vbuffer-or-name buffer-or-name)
			 (vaction action)
			 (vquit-function quit-function))
      `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name))
	      (standard-output ,buffer)
	      ,window ,value)
	 (with-current-buffer ,buffer
	   (setq ,value (progn ,@body))
	   (setq ,window (temp-buffer-window-show ,buffer ,vaction)))

	 (if (functionp ,vquit-function)
	     (funcall ,vquit-function ,window ,value)
	   ,value)))))