diff options
| author | Kenichi Handa | 2000-11-14 11:46:01 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-11-14 11:46:01 +0000 |
| commit | 87eb48b95ed802f40a382ed06f14d2ac69d94782 (patch) | |
| tree | 1ff318680bc1289befb0666d5610641336719e0b | |
| parent | cd9a000ca8034962a6309c48fa8827062ed73a13 (diff) | |
| download | emacs-87eb48b95ed802f40a382ed06f14d2ac69d94782.tar.gz emacs-87eb48b95ed802f40a382ed06f14d2ac69d94782.zip | |
(fit-window-to-buffer): Don't check
window-text-height. Assure that the last line is fully visible.
| -rw-r--r-- | lisp/window.el | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lisp/window.el b/lisp/window.el index 92451fb9cd8..89dc9c6cbfe 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -448,19 +448,16 @@ header-line." | |||
| 448 | (let* ((window-height | 448 | (let* ((window-height |
| 449 | ;; The current height of WINDOW | 449 | ;; The current height of WINDOW |
| 450 | (window-height window)) | 450 | (window-height window)) |
| 451 | (extra | ||
| 452 | ;; The amount by which the text height differs from the window | ||
| 453 | ;; height. | ||
| 454 | (- window-height (window-text-height window))) | ||
| 455 | (text-height | 451 | (text-height |
| 456 | ;; The height necessary to show the buffer displayed by WINDOW | 452 | ;; The height necessary to show the buffer displayed by WINDOW |
| 457 | ;; (`count-screen-lines' always works on the current buffer). | 453 | ;; (`count-screen-lines' always works on the current buffer). |
| 458 | (with-current-buffer (window-buffer window) | 454 | ;; We add 1 for mode-line. |
| 459 | (count-screen-lines))) | 455 | (1+ (with-current-buffer (window-buffer window) |
| 456 | (count-screen-lines)))) | ||
| 460 | (delta | 457 | (delta |
| 461 | ;; Calculate how much the window height has to change to show | 458 | ;; Calculate how much the window height has to change to show |
| 462 | ;; text-height lines, constrained by MIN-HEIGHT and MAX-HEIGHT. | 459 | ;; text-height lines, constrained by MIN-HEIGHT and MAX-HEIGHT. |
| 463 | (- (max (min (+ text-height extra) max-height) | 460 | (- (max (min text-height max-height) |
| 464 | (or min-height window-min-height)) | 461 | (or min-height window-min-height)) |
| 465 | window-height)) | 462 | window-height)) |
| 466 | ;; We do our own height checking, so avoid any restrictions due to | 463 | ;; We do our own height checking, so avoid any restrictions due to |
| @@ -478,7 +475,22 @@ header-line." | |||
| 478 | (enlarge-window delta) | 475 | (enlarge-window delta) |
| 479 | (save-selected-window | 476 | (save-selected-window |
| 480 | (select-window window) | 477 | (select-window window) |
| 481 | (enlarge-window delta)))))) | 478 | (enlarge-window delta)))) |
| 479 | |||
| 480 | ;; Check if the last line is surely fully visible. If not, | ||
| 481 | ;; enlarge the window. | ||
| 482 | (let ((pos (with-current-buffer (window-buffer window) | ||
| 483 | (save-excursion | ||
| 484 | (goto-char (point-max)) | ||
| 485 | (if (and (bolp) (not (bobp))) | ||
| 486 | (1- (point)) | ||
| 487 | (point)))))) | ||
| 488 | (set-window-vscroll window 0) | ||
| 489 | (save-selected-window | ||
| 490 | (select-window window) | ||
| 491 | (while (and (< (window-height window) max-height) | ||
| 492 | (not (pos-visible-in-window-p pos window t))) | ||
| 493 | (enlarge-window 1)))))) | ||
| 482 | 494 | ||
| 483 | (defun shrink-window-if-larger-than-buffer (&optional window) | 495 | (defun shrink-window-if-larger-than-buffer (&optional window) |
| 484 | "Shrink the WINDOW to be as small as possible to display its contents. | 496 | "Shrink the WINDOW to be as small as possible to display its contents. |