aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMiles Bader <[email protected]>2000-11-14 12:58:47 +0000
committerMiles Bader <[email protected]>2000-11-14 12:58:47 +0000
commit88f0a1eb891365a60559174f75ed2631070b00bf (patch)
tree7d8ad61b5581dd4d14e29810d649e8411a5c42b2 /lisp
parentae523e577e1f5acd897f1f9bee6aa1b5bb5f8081 (diff)
(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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/window.el71
2 files changed, 48 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1a5102d599..ff1cd40d3b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2000-11-14 Miles Bader <[email protected]>
+
+ * window.el (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.
+
2000-11-14 Kenichi Handa <[email protected]>
* window.el (fit-window-to-buffer): Don't check
@@ -57,6 +63,8 @@
* textmodes/fill.el (skip-line-prefix): New function.
(fill-region-as-paragraph, fill-region): Return the fill-prefix.
(fill-paragraph): Don't leave point inside the fill-prefix.
+ * textmodes/refill.el (refill-fill-paragraph-at): Don't leave
+ point inside the fill-prefix.
2000-11-13 Miles Bader <[email protected]>
diff --git a/lisp/window.el b/lisp/window.el
index 89dc9c6cbf..b6e5c1757d 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -445,19 +445,27 @@ header-line."
(when (null max-height)
(setq max-height (frame-height (window-frame window))))
- (let* ((window-height
+ (let* ((buf
+ ;; Buffer that is displayed in WINDOW
+ (window-buffer window))
+ (window-height
;; The current height of WINDOW
(window-height window))
- (text-height
+ (desired-height
;; The height necessary to show the buffer displayed by WINDOW
;; (`count-screen-lines' always works on the current buffer).
- ;; We add 1 for mode-line.
- (1+ (with-current-buffer (window-buffer window)
- (count-screen-lines))))
+ (with-current-buffer buf
+ (+ (count-screen-lines)
+ ;; For non-minibuffers, count the mode-line, if any
+ (if (and (not (window-minibuffer-p window))
+ mode-line-format)
+ 1 0)
+ ;; Count the header-line, if any
+ (if header-line-format 1 0))))
(delta
;; Calculate how much the window height has to change to show
- ;; text-height lines, constrained by MIN-HEIGHT and MAX-HEIGHT.
- (- (max (min text-height max-height)
+ ;; desired-height lines, constrained by MIN-HEIGHT and MAX-HEIGHT.
+ (- (max (min desired-height max-height)
(or min-height window-min-height))
window-height))
;; We do our own height checking, so avoid any restrictions due to
@@ -466,31 +474,32 @@ header-line."
;; Don't try to redisplay with the cursor at the end
;; on its own line--that would force a scroll and spoil things.
- (if (with-current-buffer (window-buffer window)
- (and (eobp) (bolp) (not (bobp))))
- (set-window-point window (1- (window-point window))))
+ (when (with-current-buffer buf
+ (and (eobp) (bolp) (not (bobp))))
+ (set-window-point window (1- (window-point window))))
- (unless (zerop delta)
- (if (eq window (selected-window))
- (enlarge-window delta)
- (save-selected-window
- (select-window window)
- (enlarge-window delta))))
-
- ;; Check if the last line is surely fully visible. If not,
- ;; enlarge the window.
- (let ((pos (with-current-buffer (window-buffer window)
- (save-excursion
- (goto-char (point-max))
- (if (and (bolp) (not (bobp)))
- (1- (point))
- (point))))))
- (set-window-vscroll window 0)
- (save-selected-window
- (select-window window)
- (while (and (< (window-height window) max-height)
- (not (pos-visible-in-window-p pos window t)))
- (enlarge-window 1))))))
+ (save-selected-window
+ (select-window window)
+
+ ;; Adjust WINDOW to the nominally correct size (which may actually
+ ;; be slightly off because of variable height text, etc).
+ (unless (zerop delta)
+ (enlarge-window delta))
+
+ ;; Check if the last line is surely fully visible. If not,
+ ;; enlarge the window.
+ (let ((end (with-current-buffer buf
+ (save-excursion
+ (goto-char (point-max))
+ (if (and (bolp) (not (bobp)))
+ (1- (point))
+ (point))))))
+ (set-window-vscroll window 0)
+ (while (and (< desired-height max-height)
+ (= desired-height (window-height window))
+ (not (pos-visible-in-window-p end window t)))
+ (enlarge-window 1)
+ (setq desired-height (1+ desired-height)))))))
(defun shrink-window-if-larger-than-buffer (&optional window)
"Shrink the WINDOW to be as small as possible to display its contents.