changeset 101909:b62aecf6b1db

(doc-view-scroll-up-or-next-page) (doc-view-scroll-down-or-previous-page, doc-view-goto-page): Reset the old hscroll value after switching pages.
author Tassilo Horn <tassilo@member.fsf.org>
date Mon, 09 Feb 2009 15:33:47 +0000
parents 2f90d8471cb7
children 3d527c23c151
files lisp/ChangeLog lisp/doc-view.el
diffstat 2 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Feb 09 07:52:54 2009 +0000
+++ b/lisp/ChangeLog	Mon Feb 09 15:33:47 2009 +0000
@@ -1,3 +1,9 @@
+2009-02-09  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* doc-view.el (doc-view-scroll-up-or-next-page)
+	(doc-view-scroll-down-or-previous-page, doc-view-goto-page): Reset
+	the old hscroll value after switching pages.
+
 2009-02-09  Glenn Morris  <rgm@gnu.org>
 
 	* calendar/calendar.el (diary-entry-marker, calendar-today-marker)
--- a/lisp/doc-view.el	Mon Feb 09 07:52:54 2009 +0000
+++ b/lisp/doc-view.el	Mon Feb 09 15:33:47 2009 +0000
@@ -346,7 +346,8 @@
 (defun doc-view-goto-page (page)
   "View the page given by PAGE."
   (interactive "nPage: ")
-  (let ((len (length doc-view-current-files)))
+  (let ((len (length doc-view-current-files))
+	(hscroll (window-hscroll)))
     (if (< page 1)
 	(setq page 1)
       (when (and (> page len)
@@ -379,6 +380,7 @@
     (let ((file (expand-file-name (format "page-%d.png" page)
                                   (doc-view-current-cache-dir))))
       (doc-view-insert-image file :pointer 'arrow)
+      (set-window-hscroll (selected-window) hscroll)
       (when (and (not (file-exists-p file))
                  doc-view-current-converter-processes)
         ;; The PNG file hasn't been generated yet.
@@ -418,22 +420,26 @@
 (defun doc-view-scroll-up-or-next-page ()
   "Scroll page up if possible, else goto next page."
   (interactive)
-  (when (= (window-vscroll) (image-scroll-up nil))
-    (let ((cur-page (doc-view-current-page)))
+  (let ((hscroll (window-hscroll))
+	(cur-page (doc-view-current-page)))
+    (when (= (window-vscroll) (image-scroll-up nil))
       (doc-view-next-page)
       (when (/= cur-page (doc-view-current-page))
 	(image-bob)
-	(image-bol 1)))))
+	(image-bol 1))
+      (set-window-hscroll (selected-window) hscroll))))
 
 (defun doc-view-scroll-down-or-previous-page ()
   "Scroll page down if possible, else goto previous page."
   (interactive)
-  (when (= (window-vscroll) (image-scroll-down nil))
-    (let ((cur-page (doc-view-current-page)))
+  (let ((hscroll (window-hscroll))
+	(cur-page (doc-view-current-page)))
+    (when (= (window-vscroll) (image-scroll-down nil))
       (doc-view-previous-page)
       (when (/= cur-page (doc-view-current-page))
 	(image-eob)
-	(image-bol 1)))))
+	(image-bol 1))
+      (set-window-hscroll (selected-window) hscroll))))
 
 ;;;; Utility Functions
 
@@ -1104,7 +1110,7 @@
 			      major-mode)))
       (kill-all-local-variables)
       (set (make-local-variable 'doc-view-previous-major-mode) prev-major-mode))
-    
+
     ;; Figure out the document type.
     (let ((name-types
 	   (when buffer-file-name
@@ -1128,7 +1134,7 @@
 			     name-types content-types))
 		    name-types content-types
 		    (error "Cannot determine the document type")))))
-    
+
     (doc-view-make-safe-dir doc-view-cache-directory)
     ;; Handle compressed files, remote files, files inside archives
     (set (make-local-variable 'doc-view-buffer-file-name)
@@ -1150,7 +1156,7 @@
 	  (t buffer-file-name)))
     (when (not (string= doc-view-buffer-file-name buffer-file-name))
       (write-region nil nil doc-view-buffer-file-name))
-    
+
     (add-hook 'change-major-mode-hook
 	      (lambda ()
 		(doc-view-kill-proc)
@@ -1158,14 +1164,14 @@
 	      nil t)
     (add-hook 'clone-indirect-buffer-hook 'doc-view-clone-buffer-hook nil t)
     (add-hook 'kill-buffer-hook 'doc-view-kill-proc nil t)
-    
+
     (remove-overlays (point-min) (point-max) 'doc-view t) ;Just in case.
     ;; Keep track of display info ([vh]scroll, page number, overlay,
     ;; ...)  for each window in which this document is shown.
     (add-hook 'image-mode-new-window-functions
 	      'doc-view-new-window-function nil t)
     (image-mode-setup-winprops)
-    
+
     (set (make-local-variable 'mode-line-position)
 	 '(" P" (:eval (number-to-string (doc-view-current-page)))
 	   "/" (:eval (number-to-string (length doc-view-current-files)))))