changeset 88062:4ff20f6b1ec8

* image-mode.el (image-mode-current-vscroll) (image-mode-current-hscroll): Add doc strings. (image-set-window-vscroll, image-set-window-hscroll) (image-reset-current-vhscroll, image-mode): Adapt to i-m-current-[vh]scroll being an alist now.
author Tassilo Horn <tassilo@member.fsf.org>
date Tue, 29 Jan 2008 18:00:40 +0000
parents 9a83d6184f1f
children 656f1559e088
files lisp/image-mode.el
diffstat 1 files changed, 22 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/image-mode.el	Tue Jan 29 17:40:19 2008 +0000
+++ b/lisp/image-mode.el	Tue Jan 29 18:00:40 2008 +0000
@@ -50,20 +50,32 @@
 
 ;;; Image scrolling functions
 
-(defvar image-mode-current-vscroll nil)
-(defvar image-mode-current-hscroll nil)
+(defvar image-mode-current-vscroll nil
+  "An alist with elements (WINDOW . VSCROLL).")
+
+(defvar image-mode-current-hscroll nil
+  "An alist with elements (WINDOW . HSCROLL).")
 
 (defun image-set-window-vscroll (window vscroll &optional pixels-p)
-  (setq image-mode-current-vscroll vscroll)
+  (setq image-mode-current-vscroll
+	(append (list (cons window vscroll))
+		(delete (assoc window image-mode-current-vscroll)
+			image-mode-current-vscroll)))
   (set-window-vscroll window vscroll pixels-p))
 
 (defun image-set-window-hscroll (window ncol)
-  (setq image-mode-current-hscroll ncol)
+  (setq image-mode-current-hscroll
+	(append (list (cons window ncol))
+		(delete (assoc window image-mode-current-hscroll)
+			image-mode-current-hscroll)))
   (set-window-hscroll window ncol))
 
 (defun image-reset-current-vhscroll ()
-  (set-window-hscroll (selected-window) image-mode-current-hscroll)
-  (set-window-vscroll (selected-window) image-mode-current-vscroll))
+  (let ((win (selected-window)))
+    (when (assoc win image-mode-current-hscroll)
+      (set-window-hscroll win (cdr (assoc win image-mode-current-hscroll))))
+    (when (assoc win image-mode-current-vscroll)
+      (set-window-vscroll win (cdr (assoc win image-mode-current-vscroll))))))
 
 (defun image-forward-hscroll (&optional n)
   "Scroll image in current window to the left by N character widths.
@@ -241,10 +253,10 @@
        'image-bookmark-make-cell)
 
   ;; Keep track of [vh]scroll when switching buffers
-  (set (make-local-variable 'image-mode-current-hscroll)
-       (window-hscroll (selected-window)))
-  (set (make-local-variable 'image-mode-current-vscroll)
-       (window-vscroll (selected-window)))
+  (make-local-variable 'image-mode-current-hscroll)
+  (make-local-variable 'image-mode-current-vscroll)
+  (image-set-window-hscroll (selected-window) (window-hscroll))
+  (image-set-window-vscroll (selected-window) (window-vscroll))
   (add-hook 'window-configuration-change-hook
 	    'image-reset-current-vhscroll nil t)