aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/window.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/window.el')
-rw-r--r--lisp/window.el21
1 files changed, 7 insertions, 14 deletions
diff --git a/lisp/window.el b/lisp/window.el
index 5768436eaae..b4fd664a43c 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -397,20 +397,13 @@ lines than are actually needed in the case where some error may be present."
397 397
398(defun window-buffer-height (window) 398(defun window-buffer-height (window)
399 "Return the height (in screen lines) of the buffer that WINDOW is displaying." 399 "Return the height (in screen lines) of the buffer that WINDOW is displaying."
400 (save-excursion 400 (with-current-buffer (window-buffer window)
401 (set-buffer (window-buffer window)) 401 (max 1
402 (goto-char (point-min)) 402 (count-screen-lines (point-min) (point-max)
403 (let ((ignore-final-newline 403 ;; If buffer ends with a newline, ignore it when
404 ;; If buffer ends with a newline, ignore it when counting height 404 ;; counting height unless point is after it.
405 ;; unless point is after it. 405 (eobp)
406 (and (not (eobp)) (eq ?\n (char-after (1- (point-max))))))) 406 window))))
407 (+ 1 (nth 2 (compute-motion (point-min)
408 '(0 . 0)
409 (- (point-max) (if ignore-final-newline 1 0))
410 (cons 0 100000000)
411 nil
412 nil
413 window))))))
414 407
415(defun count-screen-lines (&optional beg end count-final-newline window) 408(defun count-screen-lines (&optional beg end count-final-newline window)
416 "Return the number of screen lines in the region. 409 "Return the number of screen lines in the region.