Function: window-deletable-p

window-deletable-p is a byte-compiled function defined in window.el.gz.

Signature

(window-deletable-p &optional WINDOW)

Documentation

Return t if WINDOW can be safely deleted from its frame.

WINDOW must be a valid window and defaults to the selected one.

Return frame if WINDOW is the root window of its frame and that frame can be safely deleted.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
;;; Deleting windows.
(defun window-deletable-p (&optional window)
  "Return t if WINDOW can be safely deleted from its frame.
WINDOW must be a valid window and defaults to the selected one.

Return `frame' if WINDOW is the root window of its frame and that
frame can be safely deleted."
  (setq window (window-normalize-window window))

  (unless (or ignore-window-parameters
	      (eq (window-parameter window 'delete-window) t))
    ;; Handle atomicity.
    (when (window-parameter window 'window-atom)
      (setq window (window-atom-root window))))

  (let ((frame (window-frame window)))
    (cond
     ((frame-root-window-p window)
      ;; WINDOW's frame can be deleted only if there are other frames
      ;; on the same terminal, and it does not contain the active
      ;; minibuffer.
      (unless (or (eq frame (next-frame frame 0))
		  ;; We can delete our frame only if no other frame
		  ;; currently uses our minibuffer window.
		  (catch 'other
		    (dolist (other (frame-list))
		      (when (and (not (eq other frame))
				 (eq (window-frame (minibuffer-window other))
				     frame))
			(throw 'other t))))
		  (let ((minibuf (active-minibuffer-window)))
		    (and minibuf (eq frame (window-frame minibuf))
                         (not (eq (default-toplevel-value
                                    'minibuffer-follows-selected-frame)
                                  t)))))
	'frame))
     ((window-minibuffer-p window)
      ;; If WINDOW is the minibuffer window of a non-minibuffer-only
      ;; frame, it cannot be deleted separately.
      nil)
     ((or ignore-window-parameters
	  (not (eq window (window-main-window frame))))
      ;; Otherwise, WINDOW can be deleted unless it is the main window
      ;; of its frame.
      t))))