changeset 61038:f7f0c6eb075b

(window-buffer-height): Use count-screen-lines.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 28 Mar 2005 14:52:02 +0000
parents 758ff54158e2
children acd9df2cf3e5
files lisp/ChangeLog lisp/window.el
diffstat 2 files changed, 9 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Mar 28 14:36:25 2005 +0000
+++ b/lisp/ChangeLog	Mon Mar 28 14:52:02 2005 +0000
@@ -1,5 +1,7 @@
 2005-03-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* window.el (window-buffer-height): Use count-screen-lines.
+
 	* progmodes/python.el (python-preoutput-leftover): New var.
 	(python-preoutput-filter): Use it.
 	(python-send-receive): Loop until all the result has been received.
--- a/lisp/window.el	Mon Mar 28 14:36:25 2005 +0000
+++ b/lisp/window.el	Mon Mar 28 14:52:02 2005 +0000
@@ -397,20 +397,13 @@
 
 (defun window-buffer-height (window)
   "Return the height (in screen lines) of the buffer that WINDOW is displaying."
-  (save-excursion
-    (set-buffer (window-buffer window))
-    (goto-char (point-min))
-    (let ((ignore-final-newline
-           ;; If buffer ends with a newline, ignore it when counting height
-           ;; unless point is after it.
-           (and (not (eobp)) (eq ?\n (char-after (1- (point-max)))))))
-      (+ 1 (nth 2 (compute-motion (point-min)
-                                  '(0 . 0)
-                                  (- (point-max) (if ignore-final-newline 1 0))
-                                  (cons 0 100000000)
-                                  nil
-                                  nil
-                                  window))))))
+  (with-current-buffer (window-buffer window)
+    (max 1
+	 (count-screen-lines (point-min) (point-max)
+			     ;; If buffer ends with a newline, ignore it when
+			     ;; counting height unless point is after it.
+			     (eobp)
+			     window))))
 
 (defun count-screen-lines (&optional beg end count-final-newline window)
   "Return the number of screen lines in the region.