diff options
| author | Miles Bader | 2000-11-14 12:58:47 +0000 |
|---|---|---|
| committer | Miles Bader | 2000-11-14 12:58:47 +0000 |
| commit | 88f0a1eb891365a60559174f75ed2631070b00bf (patch) | |
| tree | 7d8ad61b5581dd4d14e29810d649e8411a5c42b2 | |
| parent | ae523e577e1f5acd897f1f9bee6aa1b5bb5f8081 (diff) | |
| download | emacs-88f0a1eb891365a60559174f75ed2631070b00bf.tar.gz emacs-88f0a1eb891365a60559174f75ed2631070b00bf.zip | |
(fit-window-to-buffer): Handle windows without mode-lines.
Handle header-lines. Don't loop forever if we can't enlarge the
window anymore. Simplify a bit.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/window.el | 71 |
2 files changed, 48 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1a5102d5998..ff1cd40d3bf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2000-11-14 Miles Bader <miles@gnu.org> | ||
| 2 | |||
| 3 | * window.el (fit-window-to-buffer): Handle windows without mode-lines. | ||
| 4 | Handle header-lines. Don't loop forever if we can't enlarge the | ||
| 5 | window anymore. Simplify a bit. | ||
| 6 | |||
| 1 | 2000-11-14 Kenichi Handa <handa@etl.go.jp> | 7 | 2000-11-14 Kenichi Handa <handa@etl.go.jp> |
| 2 | 8 | ||
| 3 | * window.el (fit-window-to-buffer): Don't check | 9 | * window.el (fit-window-to-buffer): Don't check |
| @@ -57,6 +63,8 @@ | |||
| 57 | * textmodes/fill.el (skip-line-prefix): New function. | 63 | * textmodes/fill.el (skip-line-prefix): New function. |
| 58 | (fill-region-as-paragraph, fill-region): Return the fill-prefix. | 64 | (fill-region-as-paragraph, fill-region): Return the fill-prefix. |
| 59 | (fill-paragraph): Don't leave point inside the fill-prefix. | 65 | (fill-paragraph): Don't leave point inside the fill-prefix. |
| 66 | * textmodes/refill.el (refill-fill-paragraph-at): Don't leave | ||
| 67 | point inside the fill-prefix. | ||
| 60 | 68 | ||
| 61 | 2000-11-13 Miles Bader <miles@lsi.nec.co.jp> | 69 | 2000-11-13 Miles Bader <miles@lsi.nec.co.jp> |
| 62 | 70 | ||
diff --git a/lisp/window.el b/lisp/window.el index 89dc9c6cbfe..b6e5c1757d2 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -445,19 +445,27 @@ header-line." | |||
| 445 | (when (null max-height) | 445 | (when (null max-height) |
| 446 | (setq max-height (frame-height (window-frame window)))) | 446 | (setq max-height (frame-height (window-frame window)))) |
| 447 | 447 | ||
| 448 | (let* ((window-height | 448 | (let* ((buf |
| 449 | ;; Buffer that is displayed in WINDOW | ||
| 450 | (window-buffer window)) | ||
| 451 | (window-height | ||
| 449 | ;; The current height of WINDOW | 452 | ;; The current height of WINDOW |
| 450 | (window-height window)) | 453 | (window-height window)) |
| 451 | (text-height | 454 | (desired-height |
| 452 | ;; The height necessary to show the buffer displayed by WINDOW | 455 | ;; The height necessary to show the buffer displayed by WINDOW |
| 453 | ;; (`count-screen-lines' always works on the current buffer). | 456 | ;; (`count-screen-lines' always works on the current buffer). |
| 454 | ;; We add 1 for mode-line. | 457 | (with-current-buffer buf |
| 455 | (1+ (with-current-buffer (window-buffer window) | 458 | (+ (count-screen-lines) |
| 456 | (count-screen-lines)))) | 459 | ;; For non-minibuffers, count the mode-line, if any |
| 460 | (if (and (not (window-minibuffer-p window)) | ||
| 461 | mode-line-format) | ||
| 462 | 1 0) | ||
| 463 | ;; Count the header-line, if any | ||
| 464 | (if header-line-format 1 0)))) | ||
| 457 | (delta | 465 | (delta |
| 458 | ;; Calculate how much the window height has to change to show | 466 | ;; Calculate how much the window height has to change to show |
| 459 | ;; text-height lines, constrained by MIN-HEIGHT and MAX-HEIGHT. | 467 | ;; desired-height lines, constrained by MIN-HEIGHT and MAX-HEIGHT. |
| 460 | (- (max (min text-height max-height) | 468 | (- (max (min desired-height max-height) |
| 461 | (or min-height window-min-height)) | 469 | (or min-height window-min-height)) |
| 462 | window-height)) | 470 | window-height)) |
| 463 | ;; We do our own height checking, so avoid any restrictions due to | 471 | ;; We do our own height checking, so avoid any restrictions due to |
| @@ -466,31 +474,32 @@ header-line." | |||
| 466 | 474 | ||
| 467 | ;; Don't try to redisplay with the cursor at the end | 475 | ;; Don't try to redisplay with the cursor at the end |
| 468 | ;; on its own line--that would force a scroll and spoil things. | 476 | ;; on its own line--that would force a scroll and spoil things. |
| 469 | (if (with-current-buffer (window-buffer window) | 477 | (when (with-current-buffer buf |
| 470 | (and (eobp) (bolp) (not (bobp)))) | 478 | (and (eobp) (bolp) (not (bobp)))) |
| 471 | (set-window-point window (1- (window-point window)))) | 479 | (set-window-point window (1- (window-point window)))) |
| 472 | 480 | ||
| 473 | (unless (zerop delta) | 481 | (save-selected-window |
| 474 | (if (eq window (selected-window)) | 482 | (select-window window) |
| 475 | (enlarge-window delta) | 483 | |
| 476 | (save-selected-window | 484 | ;; Adjust WINDOW to the nominally correct size (which may actually |
| 477 | (select-window window) | 485 | ;; be slightly off because of variable height text, etc). |
| 478 | (enlarge-window delta)))) | 486 | (unless (zerop delta) |
| 479 | 487 | (enlarge-window delta)) | |
| 480 | ;; Check if the last line is surely fully visible. If not, | 488 | |
| 481 | ;; enlarge the window. | 489 | ;; Check if the last line is surely fully visible. If not, |
| 482 | (let ((pos (with-current-buffer (window-buffer window) | 490 | ;; enlarge the window. |
| 483 | (save-excursion | 491 | (let ((end (with-current-buffer buf |
| 484 | (goto-char (point-max)) | 492 | (save-excursion |
| 485 | (if (and (bolp) (not (bobp))) | 493 | (goto-char (point-max)) |
| 486 | (1- (point)) | 494 | (if (and (bolp) (not (bobp))) |
| 487 | (point)))))) | 495 | (1- (point)) |
| 488 | (set-window-vscroll window 0) | 496 | (point)))))) |
| 489 | (save-selected-window | 497 | (set-window-vscroll window 0) |
| 490 | (select-window window) | 498 | (while (and (< desired-height max-height) |
| 491 | (while (and (< (window-height window) max-height) | 499 | (= desired-height (window-height window)) |
| 492 | (not (pos-visible-in-window-p pos window t))) | 500 | (not (pos-visible-in-window-p end window t))) |
| 493 | (enlarge-window 1)))))) | 501 | (enlarge-window 1) |
| 502 | (setq desired-height (1+ desired-height))))))) | ||
| 494 | 503 | ||
| 495 | (defun shrink-window-if-larger-than-buffer (&optional window) | 504 | (defun shrink-window-if-larger-than-buffer (&optional window) |
| 496 | "Shrink the WINDOW to be as small as possible to display its contents. | 505 | "Shrink the WINDOW to be as small as possible to display its contents. |