]> code.delx.au - gnu-emacs/blobdiff - lisp/window.el
(turn-off-xterm-mouse-tracking): Doc fix.
[gnu-emacs] / lisp / window.el
index daa517718661906bc95b5ab8f616071ec4385276..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.
@@ -143,7 +149,8 @@ even if it is inactive."
      count))
 
 (defun window-safely-shrinkable-p (&optional window)
-  "Non-nil if the WINDOW can be shrunk without shrinking other windows."
+  "Non-nil if the WINDOW can be shrunk without shrinking other windows.
+If WINDOW is nil or omitted, it defaults to the currently selected window."
   (save-selected-window
     (when window (select-window window))
     (or (and (not (eq window (frame-first-window)))
@@ -367,6 +374,7 @@ in some window."
 
 (defun fit-window-to-buffer (&optional window max-height min-height)
   "Make WINDOW the right size to display its contents exactly.
+If WINDOW is omitted or nil, it defaults to the selected window.
 If the optional argument MAX-HEIGHT is supplied, it is the maximum height
   the window is allowed to be, defaulting to the frame height.
 If the optional argument MIN-HEIGHT is supplied, it is the minimum
@@ -452,6 +460,7 @@ header-line."
 
 (defun shrink-window-if-larger-than-buffer (&optional window)
   "Shrink the WINDOW to be as small as possible to display its contents.
+If WINDOW is omitted or nil, it defaults to the selected window.
 Do not shrink to less than `window-min-height' lines.
 Do nothing if the buffer contains more lines than the present window height,
 or if some of the window's contents are scrolled out of view,
@@ -469,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 ()