diff options
| -rw-r--r-- | lisp/window.el | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lisp/window.el b/lisp/window.el index 4ebe8b50e41..74edeb986da 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -145,6 +145,7 @@ No arg means split equally." | |||
| 145 | 145 | ||
| 146 | (defun shrink-window-if-larger-than-buffer (&optional window) | 146 | (defun shrink-window-if-larger-than-buffer (&optional window) |
| 147 | "Shrink the WINDOW to be as small as possible to display its contents. | 147 | "Shrink the WINDOW to be as small as possible to display its contents. |
| 148 | Do not shrink to less that `window-min-height' lines. | ||
| 148 | Do nothing if the buffer contains more lines than the present window height, | 149 | Do nothing if the buffer contains more lines than the present window height, |
| 149 | or if some of the window's contents are scrolled out of view, | 150 | or if some of the window's contents are scrolled out of view, |
| 150 | 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, |
| @@ -161,7 +162,6 @@ or if the window is the only window of its frame." | |||
| 161 | ;; unless point is after it. | 162 | ;; unless point is after it. |
| 162 | (and (not (eobp)) | 163 | (and (not (eobp)) |
| 163 | (eq ?\n (char-after (1- (point-max)))))) | 164 | (eq ?\n (char-after (1- (point-max)))))) |
| 164 | (window-min-height 0) | ||
| 165 | (buffer-read-only nil) | 165 | (buffer-read-only nil) |
| 166 | (modified (buffer-modified-p)) | 166 | (modified (buffer-modified-p)) |
| 167 | (buffer (current-buffer)) | 167 | (buffer (current-buffer)) |
| @@ -185,7 +185,10 @@ or if the window is the only window of its frame." | |||
| 185 | ;; defeat file locking... don't try this at home, kids! | 185 | ;; defeat file locking... don't try this at home, kids! |
| 186 | (setq buffer-file-name nil) | 186 | (setq buffer-file-name nil) |
| 187 | (insert ?\n) (setq n (1+ n))) | 187 | (insert ?\n) (setq n (1+ n))) |
| 188 | (if (> n 0) (shrink-window (1- n)))) | 188 | (if (> n 0) |
| 189 | (shrink-window (min (1- n) | ||
| 190 | (- (window-height) | ||
| 191 | window-min-height))))) | ||
| 189 | (delete-region (point-min) (point)) | 192 | (delete-region (point-min) (point)) |
| 190 | (set-buffer-modified-p modified) | 193 | (set-buffer-modified-p modified) |
| 191 | (goto-char p) | 194 | (goto-char p) |