[Top][All Lists]

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

bug#4896: DocView: Continuous mode

From: Juri Linkov
Subject: bug#4896: DocView: Continuous mode
Date: Tue, 24 Nov 2009 19:08:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu)

>>> However, I still have no idea how make the mouse-wheel to jump to the
>>> next/previous page depending on the value of
>>> `doc-view-continuous-mode'.
>> Can't you simply bind mouse-4/5 to the two new functions?
> mwheel.el provides many useful settings like `mouse-wheel-scroll-amount'
> that we should respect in DocView.

`mwheel-scroll' relies on `scroll-up' and `scroll-down' to do its job with
the specified values of `mouse-wheel-scroll-amount'.  It would be good
if it was able to use doc-view scrolling.

Below is a proof of concept, not the final patch.  It provides the
correct behavior of the mouse wheel scrolling in continuous mode.

Any ideas how to specify doc-view scrolling functions for mwheel.el
in doc-view continuous mode?

Index: lisp/mwheel.el
RCS file: /sources/emacs/emacs/lisp/mwheel.el,v
retrieving revision 1.56
diff -u -r1.56 mwheel.el
--- lisp/mwheel.el      12 Sep 2009 19:03:52 -0000      1.56
+++ lisp/mwheel.el      24 Nov 2009 17:07:28 -0000
@@ -206,7 +206,10 @@
        (let ((button (mwheel-event-button event)))
          (cond ((eq button mouse-wheel-down-event)
-                 (condition-case nil (scroll-down amt)
+                 (condition-case nil
+                    (if (eq major-mode 'doc-view-mode)
+                        (doc-view-scroll-down-or-previous-page amt)
+                      (scroll-down amt))
                    ;; Make sure we do indeed scroll to the beginning of
                    ;; the buffer.
@@ -221,7 +224,10 @@
                       ;; to only affect scroll-down.  --Stef
                       (set-window-start (selected-window) (point-min))))))
                ((eq button mouse-wheel-up-event)
-                 (condition-case nil (scroll-up amt)
+                 (condition-case nil
+                    (if (eq major-mode 'doc-view-mode)
+                        (doc-view-scroll-up-or-next-page amt)
+                      (scroll-up amt))
                    ;; Make sure we do indeed scroll to the end of the buffer.
                    (end-of-buffer (while t (scroll-up)))))
                (t (error "Bad binding in mwheel-scroll"))))

Index: lisp/doc-view.el
RCS file: /sources/emacs/emacs/lisp/doc-view.el,v
retrieving revision 1.90
diff -u -r1.90 doc-view.el
--- lisp/doc-view.el    24 Nov 2009 07:47:49 -0000      1.90
+++ lisp/doc-view.el    24 Nov 2009 17:07:00 -0000
@@ -431,24 +431,24 @@
   (doc-view-goto-page (length doc-view-current-files)))
-(defun doc-view-scroll-up-or-next-page ()
+(defun doc-view-scroll-up-or-next-page (&optional n)
   "Scroll page up if possible, else goto next page."
-  (interactive)
+  (interactive "^P")
   (let ((hscroll (window-hscroll))
        (cur-page (doc-view-current-page)))
-    (when (= (window-vscroll) (image-scroll-up nil))
+    (when (= (window-vscroll) (image-scroll-up n))
       (when (/= cur-page (doc-view-current-page))
        (image-bol 1))
       (set-window-hscroll (selected-window) hscroll))))
-(defun doc-view-scroll-down-or-previous-page ()
+(defun doc-view-scroll-down-or-previous-page (&optional n)
   "Scroll page down if possible, else goto previous page."
-  (interactive)
+  (interactive "^P")
   (let ((hscroll (window-hscroll))
        (cur-page (doc-view-current-page)))
-    (when (= (window-vscroll) (image-scroll-down nil))
+    (when (= (window-vscroll) (image-scroll-down n))
       (when (/= cur-page (doc-view-current-page))

Juri Linkov

reply via email to

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