emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/lisp ChangeLog view.el


From: Chong Yidong
Subject: [Emacs-diffs] emacs/lisp ChangeLog view.el
Date: Tue, 26 May 2009 18:19:32 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Chong Yidong <cyd>      09/05/26 18:19:31

Modified files:
        lisp           : ChangeLog view.el 

Log message:
        * view.el (view-window-size): Use window-line-height to find window 
height.
        (view-page-size-default): Return nil if LINES is nil, 0, or larger
        than the window height.
        (view-scroll-lines): Handle nil value for DEFAULT arg (Bug#3361).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.15659&r2=1.15660
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/view.el?cvsroot=emacs&r1=1.102&r2=1.103

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.15659
retrieving revision 1.15660
diff -u -b -r1.15659 -r1.15660
--- ChangeLog   26 May 2009 14:37:51 -0000      1.15659
+++ ChangeLog   26 May 2009 18:19:27 -0000      1.15660
@@ -2,6 +2,10 @@
 
        * view.el (view-recenter): Allow recenter to compute window height
        normally.
+       (view-window-size): Use window-line-height to find window height.
+       (view-page-size-default): Return nil if LINES is nil, 0, or larger
+       than the window height.
+       (view-scroll-lines): Handle nil value for DEFAULT arg (Bug#3361).
 
 2009-05-26  Kenichi Handa  <address@hidden>
 

Index: view.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/view.el,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -b -r1.102 -r1.103
--- view.el     26 May 2009 14:37:55 -0000      1.102
+++ view.el     26 May 2009 18:19:31 -0000      1.103
@@ -740,8 +740,14 @@
 ;;; Some help routines.
 
 (defun view-window-size ()
-  ;; Window height excluding mode line.
-  (1- (window-height)))
+  ;; Return the height of the current window, excluding the mode line.
+  ;; Using `window-line-height' accounts for variable-height fonts.
+  (let ((h (window-line-height -1)))
+    (if h
+       (1+ (nth 1 h))
+      ;; This should not happen, but if `window-line-height' returns
+      ;; nil, fall back on `window-height'.
+      (1- (window-height)))))
 
 ;; (defun view-last-command (&optional who what)
 ;;  (setq view-last-command-entry this-command)
@@ -761,11 +767,13 @@
   (recenter '(1)))
 
 (defun view-page-size-default (lines)
-  ;; Get page size.
-  (let ((default (- (view-window-size) next-screen-context-lines)))
-    (if (or (null lines) (zerop (setq lines (prefix-numeric-value lines))))
-       default
-      (min (abs lines) default))))
+  ;; If LINES is nil, 0, or larger than `view-window-size', return nil.
+  ;; Otherwise, return LINES.
+  (and lines
+       (not (zerop (setq lines (prefix-numeric-value lines))))
+       (<= (abs lines)
+          (abs (- (view-window-size) next-screen-context-lines)))
+       (abs lines)))
 
 (defun view-set-half-page-size-default (lines)
   ;; Get and maybe set half page size.
@@ -825,30 +833,24 @@
 
 (defun view-scroll-lines (lines backward default maxdefault)
   ;; This function does the job for all the scrolling commands.
-  ;; Scroll forward LINES lines.  If BACKWARD is true scroll backwards.
-  ;; If LINES is negative scroll in the other direction.  If LINES is 0 or nil,
-  ;; scroll DEFAULT lines.  If MAXDEFAULT is true then scroll no more than a
-  ;; window full.
+  ;; Scroll forward LINES lines.  If BACKWARD is non-nil, scroll backwards.
+  ;; If LINES is negative scroll in the other direction.
+  ;; If LINES is 0 or nil, scroll DEFAULT lines (if DEFAULT is nil, scroll
+  ;; by one page). If MAXDEFAULT is non-nil, scroll no more than a window.
   (if (or (null lines) (zerop (setq lines (prefix-numeric-value lines))))
       (setq lines default))
-  (when (< lines 0)
-    (setq backward (not backward)) (setq lines (- lines)))
-  (setq default (view-page-size-default nil)) ; Max scrolled at a time.
-  (if maxdefault (setq lines (min lines default)))
-  (cond
-   (backward (scroll-down lines))
+  (when (and lines (< lines 0))
+    (setq backward (not backward) lines (- lines)))
+  (when (and maxdefault lines (> lines (view-window-size)))
+    (setq lines nil))
+  (cond (backward (scroll-down lines))
    ((view-really-at-end)
-    (if view-scroll-auto-exit (View-quit)
+        (if view-scroll-auto-exit
+            (View-quit)
       (ding)
       (view-end-message)))
-   (t (while (> lines default)
-       (scroll-up default)
-       (setq lines (- lines default))
-       (if (view-really-at-end) (setq lines 0)))
-      (scroll-up lines)
-      (if (view-really-at-end) (view-end-message))
-      (move-to-window-line -1)
-      (beginning-of-line))))
+       (t (scroll-up lines)
+          (if (view-really-at-end) (view-end-message)))))
 
 (defun view-really-at-end ()
   ;; Return true if buffer end visible.  Maybe revert buffer and test.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]