-;;; window.el --- GNU Emacs window commands aside from those written in C.
+;;; window.el --- GNU Emacs window commands aside from those written in C
-;; Copyright (C) 1985, 1989, 1992, 1993, 1994, 2000
+;; Copyright (C) 1985, 1989, 1992, 1993, 1994, 2000, 2001
;; Free Software Foundation, Inc.
;; Maintainer: FSF
+;; Keywords: internal
;; This file is part of GNU Emacs.
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
-
;;; Commentary:
;; Window tree functions.
(cons walk-windows-current walk-windows-already-seen))
(funcall proc walk-windows-current)))))
-(defun some-window (predicate &optional minibuf all-frames default)
+(defun get-window-with-predicate (predicate &optional minibuf
+ all-frames default)
"Return a window satisfying PREDICATE.
This function cycles through all visible windows using `walk-windows',
minibuf all-frames)
default))
+(defalias 'some-window 'get-window-with-predicate)
+
(defun minibuffer-window-active-p (window)
"Return t if WINDOW (a minibuffer window) is now active."
(eq window (active-minibuffer-window)))
(defmacro save-selected-window (&rest body)
- "Execute BODY, then select the window that was selected before BODY."
+ "Execute BODY, then select the window that was selected before BODY.
+However, if that window has become dead, don't get an error,
+just refrain from switching to it."
`(let ((save-selected-window-window (selected-window)))
(unwind-protect
(progn ,@body)
- (select-window save-selected-window-window))))
+ (if (window-live-p save-selected-window-window)
+ (select-window save-selected-window-window)))))
\f
(defun count-windows (&optional minibuf)
"Return the number of visible windows.
(pos-visible-in-window-p (point-min) window)
(not (eq mini 'only))
(or (not mini)
- (< (nth 3 edges) (nth 1 (window-edges mini)))
- (> (nth 1 edges) (frame-parameter frame 'menu-bar-lines))))
+ (let ((mini-window (minibuffer-window frame)))
+ (or (null mini-window)
+ (not (eq frame (window-frame mini-window)))
+ (< (nth 3 edges)
+ (nth 1 (window-edges mini-window)))
+ (> (nth 1 edges)
+ (frame-parameter frame 'menu-bar-lines))))))
(fit-window-to-buffer window (window-height window)))))
(defun kill-buffer-and-window ()