summaryrefslogtreecommitdiff
path: root/lisp/window.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2000-12-01 08:11:16 +0000
committerMiles Bader <miles@gnu.org>2000-12-01 08:11:16 +0000
commit417bf922a04f8b0d34e909fb1b691d70cbfebacd (patch)
tree6807e7b2787a64df8c08ef6b9f64422e22d80c92 /lisp/window.el
parentd6c1841d9b9a158f477352e69c7f63059000b11a (diff)
downloademacs-417bf922a04f8b0d34e909fb1b691d70cbfebacd.tar.gz
(fit-window-to-buffer): Handle non-nil `truncate-lines'.
Diffstat (limited to 'lisp/window.el')
-rw-r--r--lisp/window.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/window.el b/lisp/window.el
index 86cb45f92e5..60ebba7f1f0 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -508,9 +508,17 @@ header-line."
(let ((end (with-current-buffer buf
(save-excursion
(goto-char (point-max))
- (if (and (bolp) (not (bobp)))
- (1- (point))
- (point))))))
+ (when (and (bolp) (not (bobp)))
+ ;; Don't include final newline
+ (backward-char 1))
+ (when truncate-lines
+ ;; If line-wrapping is turned off, test the
+ ;; beginning of the last line for visibility
+ ;; instead of the end, as the end of the line
+ ;; could be invisible by virtue of extending past
+ ;; the edge of the window.
+ (forward-line 0))
+ (point)))))
(set-window-vscroll window 0)
(while (and (< desired-height max-height)
(= desired-height (window-height window))