397 |
|
|
398 |
(defun window-buffer-height (window) |
(defun window-buffer-height (window) |
399 |
"Return the height (in screen lines) of the buffer that WINDOW is displaying." |
"Return the height (in screen lines) of the buffer that WINDOW is displaying." |
400 |
(save-excursion |
(with-current-buffer (window-buffer window) |
401 |
(set-buffer (window-buffer window)) |
(max 1 |
402 |
(goto-char (point-min)) |
(count-screen-lines (point-min) (point-max) |
403 |
(let ((ignore-final-newline |
;; If buffer ends with a newline, ignore it when |
404 |
;; If buffer ends with a newline, ignore it when counting height |
;; counting height unless point is after it. |
405 |
;; unless point is after it. |
(eobp) |
406 |
(and (not (eobp)) (eq ?\n (char-after (1- (point-max))))))) |
window)))) |
|
(+ 1 (nth 2 (compute-motion (point-min) |
|
|
'(0 . 0) |
|
|
(- (point-max) (if ignore-final-newline 1 0)) |
|
|
(cons 0 100000000) |
|
|
nil |
|
|
nil |
|
|
window)))))) |
|
407 |
|
|
408 |
(defun count-screen-lines (&optional beg end count-final-newline window) |
(defun count-screen-lines (&optional beg end count-final-newline window) |
409 |
"Return the number of screen lines in the region. |
"Return the number of screen lines in the region. |