diff options
| author | Richard M. Stallman | 1994-09-22 20:00:48 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-09-22 20:00:48 +0000 |
| commit | cf1b1bf8c0b0f5a160ea0caf2f7f1c9e60e14639 (patch) | |
| tree | aaa68ed9544c90aae56138872d30c80682edd946 /lisp | |
| parent | 889bf3298713438c0bdd76554ccc68d17608ff68 (diff) | |
| download | emacs-cf1b1bf8c0b0f5a160ea0caf2f7f1c9e60e14639.tar.gz emacs-cf1b1bf8c0b0f5a160ea0caf2f7f1c9e60e14639.zip | |
(shrink-window-if-larger-than-buffer): Use WINDOW's frame
for all actions that operate on a frame. Set WINDOW to selected
window if it was nil.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/window.el | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/lisp/window.el b/lisp/window.el index 256dbcd43d4..eafded0572b 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -151,31 +151,37 @@ or if some of the window's contents are scrolled out of view, | |||
| 151 | or if the window is not the full width of the frame, | 151 | or if the window is not the full width of the frame, |
| 152 | or if the window is the only window of its frame." | 152 | or if the window is the only window of its frame." |
| 153 | (interactive) | 153 | (interactive) |
| 154 | (or window (setq window (selected-window))) | ||
| 154 | (save-excursion | 155 | (save-excursion |
| 155 | (set-buffer (window-buffer window)) | 156 | (set-buffer (window-buffer window)) |
| 156 | (let ((w (selected-window)) ;save-window-excursion can't win | 157 | (let* ((w (selected-window)) ;save-window-excursion can't win |
| 157 | (buffer-file-name buffer-file-name) | 158 | (buffer-file-name buffer-file-name) |
| 158 | (p (point)) | 159 | (p (point)) |
| 159 | (n 0) | 160 | (n 0) |
| 160 | (ignore-final-newline | 161 | (ignore-final-newline |
| 161 | ;; If buffer ends with a newline, ignore it when counting height | 162 | ;; If buffer ends with a newline, ignore it when counting height |
| 162 | ;; unless point is after it. | 163 | ;; unless point is after it. |
| 163 | (and (not (eobp)) | 164 | (and (not (eobp)) |
| 164 | (eq ?\n (char-after (1- (point-max)))))) | 165 | (eq ?\n (char-after (1- (point-max)))))) |
| 165 | (buffer-read-only nil) | 166 | (buffer-read-only nil) |
| 166 | (modified (buffer-modified-p)) | 167 | (modified (buffer-modified-p)) |
| 167 | (buffer (current-buffer)) | 168 | (buffer (current-buffer)) |
| 168 | (mini (cdr (assq 'minibuffer (frame-parameters)))) | 169 | (params (frame-parameters (window-frame window))) |
| 169 | (edges (window-edges (selected-window)))) | 170 | (mini (cdr (assq 'minibuffer params))) |
| 170 | (if (and (< 1 (count-windows)) | 171 | (edges (window-edges (selected-window)))) |
| 171 | (= (window-width) (frame-width)) | 172 | (if (and (< 1 (let ((frame (selected-frame))) |
| 173 | (select-frame (window-frame window)) | ||
| 174 | (unwind-protect | ||
| 175 | (count-windows) | ||
| 176 | (select-frame frame)))) | ||
| 177 | (= (window-width window) (frame-width (window-frame window))) | ||
| 172 | (pos-visible-in-window-p (point-min) window) | 178 | (pos-visible-in-window-p (point-min) window) |
| 173 | (not (eq mini 'only)) | 179 | (not (eq mini 'only)) |
| 174 | (or (not mini) | 180 | (or (not mini) |
| 175 | (< (nth 3 edges) | 181 | (< (nth 3 edges) |
| 176 | (nth 1 (window-edges mini))) | 182 | (nth 1 (window-edges mini))) |
| 177 | (> (nth 1 edges) | 183 | (> (nth 1 edges) |
| 178 | (cdr (assq 'menu-bar-lines (frame-parameters)))))) | 184 | (cdr (assq 'menu-bar-lines params))))) |
| 179 | (unwind-protect | 185 | (unwind-protect |
| 180 | (progn | 186 | (progn |
| 181 | (select-window (or window w)) | 187 | (select-window (or window w)) |