Function: quit-windows-on

quit-windows-on is an interactive and byte-compiled function defined in window.el.gz.

Signature

(quit-windows-on &optional BUFFER-OR-NAME KILL FRAME)

Documentation

Quit all windows showing BUFFER-OR-NAME.

BUFFER-OR-NAME may be a buffer or the name of an existing buffer and defaults to the current buffer. Optional argument KILL non-nil means to kill BUFFER-OR-NAME. KILL nil means to bury BUFFER-OR-NAME. Optional argument FRAME is handled as by delete-windows-on.

This function calls quit-restore-window on all candidate windows showing BUFFER-OR-NAME. In addition, it removes the buffer denoted by BUFFER-OR-NAME from all window-local buffer lists and removes any quit-restore or quit-restore-prev parameters mentioning it.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun quit-windows-on (&optional buffer-or-name kill frame)
  "Quit all windows showing BUFFER-OR-NAME.
BUFFER-OR-NAME may be a buffer or the name of an existing buffer
and defaults to the current buffer.  Optional argument KILL
non-nil means to kill BUFFER-OR-NAME.  KILL nil means to bury
BUFFER-OR-NAME.  Optional argument FRAME is handled as by
`delete-windows-on'.

This function calls `quit-restore-window' on all candidate windows
showing BUFFER-OR-NAME.  In addition, it removes the buffer denoted by
BUFFER-OR-NAME from all window-local buffer lists and removes any
`quit-restore' or `quit-restore-prev' parameters mentioning it."
  (interactive "bQuit windows on (buffer):\nP")
  (let ((buffer (window-normalize-buffer buffer-or-name))
	;; Handle the "inverted" meaning of the FRAME argument wrt other
	;; `window-list' based function.
	(frames (cond ((not frame) t) ((eq frame t) nil) (t frame))))
    (dolist (window (window-list-1 nil nil frames))
      (when (eq (window-buffer window) buffer)
	(with-current-buffer buffer
	  (run-hooks 'quit-window-hook))
	(quit-restore-window
	 window (if kill 'killing 'burying)))

      (when (window-live-p window)
	;; Unrecord BUFFER in this window.
	(unrecord-window-buffer window buffer t)))

    ;; Deal with BUFFER-OR-NAME.
    (cond
     ((not (buffer-live-p buffer)))
     (kill (kill-buffer buffer))
     (t (bury-buffer-internal buffer)))))