This commit was generated by cvs2svn to compensate for changes in r1705,
[chise/xemacs-chise.git.1] / lisp / window.el
index 76d638f..4687c8a 100644 (file)
@@ -120,13 +120,19 @@ Otherwise, include frames only on the selected device."
 
 (defmacro save-selected-window (&rest body)
   "Execute BODY, then select the window that was selected before BODY."
-  (list 'let
-       '((save-selected-window-window (selected-window)))
-       (list 'unwind-protect
-             (cons 'progn body)
-             (list 'and ; XEmacs
-                   (list 'window-live-p 'save-selected-window-window)
-                   (list 'select-window 'save-selected-window-window)))))
+  `(let ((save-selected-window-window (selected-window)))
+     (unwind-protect
+        (progn ,@body)
+       (when (window-live-p save-selected-window-window)
+        (select-window save-selected-window-window)))))
+
+(defmacro with-selected-window (window &rest body)
+  "Execute forms in BODY with WINDOW as the selected window.
+The value returned is the value of the last form in BODY."
+  `(save-selected-window
+     (select-window ,window)
+     ,@body))
+
 \f
 (defun count-windows (&optional minibuf)
    "Return the number of visible windows.
@@ -286,24 +292,20 @@ or if the window is the only window of its frame."
              (if (and (not (eobp))
                       (eq ?\n (char-after (1- (point-max)))))
                  1 0)))
-         (mini (frame-property (window-frame window) 'minibuffer))
-         (edges (window-pixel-edges (selected-window))))
+         (mini (frame-property (window-frame window) 'minibuffer)))
       (if (and (< 1 (let ((frame (selected-frame)))
                      (select-frame (window-frame window))
                      (unwind-protect
                          (count-windows)
                        (select-frame frame))))
-              ;; check to make sure that we don't have horizontally
-              ;; split windows
-              (eq (frame-highest-window (window-frame window) 0)
-                  (frame-highest-window (window-frame window) -1))
+              ;; check to make sure that the window is the full width
+              ;; of the frame
+              (window-leftmost-p window)
+              (window-rightmost-p window)
+              ;; The whole buffer must be visible.
               (pos-visible-in-window-p (point-min) window)
-              (not (eq mini 'only))
-              (or (not mini) (eq mini t)
-                  (< (nth 3 edges)
-                     (nth 1 (window-pixel-edges mini)))
-                  (> (nth 1 edges)
-                     0)))
+              ;; The frame must not be minibuffer-only.
+              (not (eq mini 'only)))
          (progn
            (save-window-excursion
              (goto-char (point-min))
@@ -353,5 +355,4 @@ Any other non-nil value means search frames on all devices."
                   minibuf all-frames device)
     wins))
 
-
 ;;; window.el ends here