diff options
| author | Karl Heuer | 1998-06-01 21:49:43 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-06-01 21:49:43 +0000 |
| commit | b70b2dd2c0fbd821a749740db5b672efa4d91816 (patch) | |
| tree | bb9397f02071842f324d86e1e980abaa5331a55c /lisp | |
| parent | 5f7493ac6950f30813753002286c45f097cc8ff8 (diff) | |
| download | emacs-b70b2dd2c0fbd821a749740db5b672efa4d91816.tar.gz emacs-b70b2dd2c0fbd821a749740db5b672efa4d91816.zip | |
(shrink-window-if-larger-than-buffer):
Switch to the specified window and its buffer at the outset.
(count-windows): Doc fix.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/window.el | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/lisp/window.el b/lisp/window.el index 433ba731ea1..1f272364e6c 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -88,7 +88,9 @@ Anything else means restrict to the selected frame." | |||
| 88 | 88 | ||
| 89 | (defun count-windows (&optional minibuf) | 89 | (defun count-windows (&optional minibuf) |
| 90 | "Returns the number of visible windows. | 90 | "Returns the number of visible windows. |
| 91 | Optional arg MINIBUF non-nil means count the minibuffer | 91 | This counts the windows in the selected frame and (if the minibuffer is |
| 92 | to be counted) its minibuffer frame (if that's not the same frame). | ||
| 93 | The optional arg MINIBUF non-nil means count the minibuffer | ||
| 92 | even if it is inactive." | 94 | even if it is inactive." |
| 93 | (let ((count 0)) | 95 | (let ((count 0)) |
| 94 | (walk-windows (function (lambda (w) | 96 | (walk-windows (function (lambda (w) |
| @@ -241,33 +243,32 @@ or if some of the window's contents are scrolled out of view, | |||
| 241 | or if the window is not the full width of the frame, | 243 | or if the window is not the full width of the frame, |
| 242 | or if the window is the only window of its frame." | 244 | or if the window is the only window of its frame." |
| 243 | (interactive) | 245 | (interactive) |
| 244 | (or window (setq window (selected-window))) | 246 | (save-selected-window |
| 245 | (let* ((ignore-final-newline | 247 | (if window |
| 246 | ;; If buffer ends with a newline, ignore it when counting height | 248 | (select-window window) |
| 247 | ;; unless point is after it. | 249 | (setq window (selected-window))) |
| 248 | (and (not (eobp)) | 250 | (save-excursion |
| 249 | (eq ?\n (char-after (1- (point-max)))))) | 251 | (set-buffer (window-buffer window)) |
| 250 | (params (frame-parameters (window-frame window))) | 252 | (goto-char (point-min)) |
| 251 | (mini (cdr (assq 'minibuffer params))) | 253 | (let* ((ignore-final-newline |
| 252 | (edges (window-edges (selected-window))) | 254 | ;; If buffer ends with a newline, ignore it when counting height |
| 253 | text-height) | 255 | ;; unless point is after it. |
| 254 | (if (and (< 1 (save-selected-window | 256 | (and (not (eobp)) |
| 255 | (select-window window) | 257 | (eq ?\n (char-after (1- (point-max)))))) |
| 256 | (count-windows))) | 258 | (params (frame-parameters)) |
| 257 | (= (window-width window) (frame-width (window-frame window))) | 259 | (mini (cdr (assq 'minibuffer params))) |
| 258 | (pos-visible-in-window-p (point-min) window) | 260 | (edges (window-edges)) |
| 259 | (not (eq mini 'only)) | 261 | text-height) |
| 260 | (or (not mini) | 262 | (if (and (< 1 (count-windows)) |
| 261 | (< (nth 3 edges) | 263 | (= (window-width) (frame-width)) |
| 262 | (nth 1 (window-edges mini))) | 264 | (pos-visible-in-window-p (point-min) window) |
| 263 | (> (nth 1 edges) | 265 | (not (eq mini 'only)) |
| 264 | (cdr (assq 'menu-bar-lines params))))) | 266 | (or (not mini) |
| 265 | (save-selected-window | 267 | (< (nth 3 edges) |
| 266 | (select-window window) | 268 | (nth 1 (window-edges mini))) |
| 267 | (let (result height) | 269 | (> (nth 1 edges) |
| 268 | (save-excursion | 270 | (cdr (assq 'menu-bar-lines params))))) |
| 269 | (set-buffer (window-buffer window)) | 271 | (let (result height) |
| 270 | (goto-char (point-min)) | ||
| 271 | (setq result | 272 | (setq result |
| 272 | (compute-motion (point-min) '(0 . 0) | 273 | (compute-motion (point-min) '(0 . 0) |
| 273 | (- (point-max) | 274 | (- (point-max) |