emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/image-mode.el,v


From: Tassilo Horn
Subject: [Emacs-diffs] Changes to emacs/lisp/image-mode.el,v
Date: Tue, 29 Jan 2008 13:49:06 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Tassilo Horn <tsdh>     08/01/29 13:49:06

Index: image-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/image-mode.el,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- image-mode.el       4 Jan 2008 03:12:43 -0000       1.31
+++ image-mode.el       29 Jan 2008 13:49:05 -0000      1.32
@@ -50,20 +50,35 @@
 
 ;;; Image scrolling functions
 
+(defvar image-mode-current-vscroll nil)
+(defvar image-mode-current-hscroll nil)
+
+(defun image-set-window-vscroll (window vscroll &optional pixels-p)
+  (setq image-mode-current-vscroll vscroll)
+  (set-window-vscroll window vscroll pixels-p))
+
+(defun image-set-window-hscroll (window ncol)
+  (setq image-mode-current-hscroll ncol)
+  (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))
+
 (defun image-forward-hscroll (&optional n)
   "Scroll image in current window to the left by N character widths.
 Stop if the right edge of the image is reached."
   (interactive "p")
   (cond ((= n 0) nil)
        ((< n 0)
-        (set-window-hscroll (selected-window)
+        (image-set-window-hscroll (selected-window)
                             (max 0 (+ (window-hscroll) n))))
        (t
         (let* ((image (get-char-property (point-min) 'display))
                (edges (window-inside-edges))
                (win-width (- (nth 2 edges) (nth 0 edges)))
                (img-width (ceiling (car (image-size image)))))
-          (set-window-hscroll (selected-window)
+          (image-set-window-hscroll (selected-window)
                               (min (max 0 (- img-width win-width))
                                    (+ n (window-hscroll))))))))
 
@@ -79,14 +94,14 @@
   (interactive "p")
   (cond ((= n 0) nil)
        ((< n 0)
-        (set-window-vscroll (selected-window)
+        (image-set-window-vscroll (selected-window)
                             (max 0 (+ (window-vscroll) n))))
        (t
         (let* ((image (get-char-property (point-min) 'display))
                (edges (window-inside-edges))
                (win-height (- (nth 3 edges) (nth 1 edges)))
                (img-height (ceiling (cdr (image-size image)))))
-          (set-window-vscroll (selected-window)
+          (image-set-window-vscroll (selected-window)
                               (min (max 0 (- img-height win-height))
                                    (+ n (window-vscroll))))))))
 
@@ -146,7 +161,7 @@
   (and arg
        (/= (setq arg (prefix-numeric-value arg)) 1)
        (image-next-line (- arg 1)))
-  (set-window-hscroll (selected-window) 0))
+  (image-set-window-hscroll (selected-window) 0))
 
 (defun image-eol (arg)
   "Scroll horizontally to the right edge of the image in the current window.
@@ -160,14 +175,14 @@
         (edges (window-inside-edges))
         (win-width (- (nth 2 edges) (nth 0 edges)))
         (img-width (ceiling (car (image-size image)))))
-    (set-window-hscroll (selected-window)
+    (image-set-window-hscroll (selected-window)
                        (max 0 (- img-width win-width)))))
 
 (defun image-bob ()
   "Scroll to the top-left corner of the image in the current window."
   (interactive)
-  (set-window-hscroll (selected-window) 0)
-  (set-window-vscroll (selected-window) 0))
+  (image-set-window-hscroll (selected-window) 0)
+  (image-set-window-vscroll (selected-window) 0))
 
 (defun image-eob ()
   "Scroll to the bottom-right corner of the image in the current window."
@@ -178,8 +193,8 @@
         (img-width (ceiling (car (image-size image))))
         (win-height (- (nth 3 edges) (nth 1 edges)))
         (img-height (ceiling (cdr (image-size image)))))
-    (set-window-hscroll (selected-window) (max 0 (- img-width win-width)))
-    (set-window-vscroll (selected-window) (max 0 (- img-height win-height)))))
+    (image-set-window-hscroll (selected-window) (max 0 (- img-width 
win-width)))
+    (image-set-window-vscroll (selected-window) (max 0 (- img-height 
win-height)))))
 
 ;;; Image Mode setup
 
@@ -224,6 +239,15 @@
   ;; Use our own bookmarking function for images.
   (set (make-local-variable 'bookmark-make-cell-function)
        '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)))
+  (add-hook 'window-configuration-change-hook
+           'image-reset-current-vhscroll nil t)
+
   (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
   (if (and (display-images-p)
           (not (get-char-property (point-min) 'display)))




reply via email to

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