]> code.delx.au - gnu-emacs/blobdiff - lisp/window.el
(turn-off-xterm-mouse-tracking): Doc fix.
[gnu-emacs] / lisp / window.el
index e6a9918093010298409486fd3ac8f90ff74b1989..532a1cc0009026938fb4b6a4be6f04237a47f240 100644 (file)
@@ -1,9 +1,10 @@
-;;; 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.
 
@@ -22,7 +23,6 @@
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-
 ;;; Commentary:
 
 ;; Window tree functions.
@@ -84,7 +84,8 @@ Anything else means restrict to the selected frame."
              (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',
@@ -119,16 +120,21 @@ Anything else means restrict to the selected frame."
                  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.
@@ -472,8 +478,13 @@ Return non-nil if the window was shrunk."
             (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 ()