[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: |
Mon, 23 Nov 2009 11:47:18 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) |
> > I think mouse-4/5 once where bound to
> > doc-view-scroll-down-or-previous-page and
> > doc-view-scroll-down-or-previous-page previously, so they scrolled or
> > switched pages back then. I don't know why this was changed. I guess,
> > because one "press" of mouse-4/5 scrolled a half page, which was a bit
> > unusual...
>
> I can't remember why it was changed either, but I for one would dislike
> it if scrolling the image with the wheel would suddenly switch to the
> next/previous page: when I scroll it's usually because I want to center
> the image differently.
>
> So I do think that we need 2 modes: a continuous mode and the current mode.
The following patch adds a new variable `doc-view-continuous-mode'
and uses it in two new commands `doc-view-next-line-or-next-page'
and `doc-view-previous-line-or-previous-page'. 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'.
Index: lisp/doc-view.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/doc-view.el,v
retrieving revision 1.88
diff -c -r1.88 doc-view.el
*** lisp/doc-view.el 17 Jul 2009 19:43:53 -0000 1.88
--- lisp/doc-view.el 23 Nov 2009 09:45:37 -0000
***************
*** 222,227 ****
--- 222,236 ----
:type 'integer
:group 'doc-view)
+ (defcustom doc-view-continuous-mode nil
+ "In Continuous mode reaching the page edge advances to the next/previous
page.
+ When non-nil, scrolling a line upward at the bottom edge of the page
+ moves to the next page, and scrolling a line downward at the top edge
+ of the page moves to the previous page."
+ :type 'boolean
+ :group 'doc-view
+ :version "23.2")
+
;;;; Internal Variables
(defun doc-view-new-window-function (winprops)
***************
*** 286,291 ****
--- 295,304 ----
(define-key map [remap backward-page] 'doc-view-previous-page)
(define-key map (kbd "SPC") 'doc-view-scroll-up-or-next-page)
(define-key map (kbd "DEL") 'doc-view-scroll-down-or-previous-page)
+ (define-key map (kbd "C-n") 'doc-view-next-line-or-next-page)
+ (define-key map (kbd "<down>") 'doc-view-next-line-or-next-page)
+ (define-key map (kbd "C-p")
'doc-view-previous-line-or-previous-page)
+ (define-key map (kbd "<up>")
'doc-view-previous-line-or-previous-page)
(define-key map (kbd "M-<") 'doc-view-first-page)
(define-key map (kbd "M->") 'doc-view-last-page)
(define-key map [remap goto-line] 'doc-view-goto-page)
***************
*** 442,447 ****
--- 455,492 ----
(image-bol 1))
(set-window-hscroll (selected-window) hscroll))))
+ (defun doc-view-next-line-or-next-page (&optional n)
+ "Scroll upward by N lines if possible, else goto next page.
+ When `doc-view-continuous-mode' is non-nil, scrolling a line upward at
+ the bottom edge of the page moves to the next page."
+ (interactive "p")
+ (if doc-view-continuous-mode
+ (let ((hscroll (window-hscroll))
+ (cur-page (doc-view-current-page)))
+ (when (= (window-vscroll) (image-next-line n))
+ (doc-view-next-page)
+ (when (/= cur-page (doc-view-current-page))
+ (image-bob)
+ (image-bol 1))
+ (set-window-hscroll (selected-window) hscroll)))
+ (image-next-line 1)))
+
+ (defun doc-view-previous-line-or-previous-page (&optional n)
+ "Scroll downward by N lines if possible, else goto previous page.
+ When `doc-view-continuous-mode' is non-nil, scrolling a line downward
+ at the top edge of the page moves to the previous page."
+ (interactive "p")
+ (if doc-view-continuous-mode
+ (let ((hscroll (window-hscroll))
+ (cur-page (doc-view-current-page)))
+ (when (= (window-vscroll) (image-previous-line n))
+ (doc-view-previous-page)
+ (when (/= cur-page (doc-view-current-page))
+ (image-eob)
+ (image-bol 1))
+ (set-window-hscroll (selected-window) hscroll)))
+ (image-previous-line n)))
+
;;;; Utility Functions
(defun doc-view-kill-proc ()
--
Juri Linkov
http://www.jurta.org/emacs/
- bug#4896: DocView: Continuous mode, Juri Linkov, 2009/11/10
- bug#4896: DocView: Continuous mode, Stefan Monnier, 2009/11/10
- bug#4896: DocView: Continuous mode, Juri Linkov, 2009/11/12
- bug#4896: DocView: Continuous mode, Tassilo Horn, 2009/11/12
- bug#4896: DocView: Continuous mode, Juri Linkov, 2009/11/12
- bug#4896: DocView: Continuous mode, Tassilo Horn, 2009/11/12
- bug#4896: DocView: Continuous mode, Stefan Monnier, 2009/11/12
- bug#4896: DocView: Continuous mode, Tassilo Horn, 2009/11/12
- bug#4896: DocView: Continuous mode,
Juri Linkov <=
- bug#4896: DocView: Continuous mode, Tassilo Horn, 2009/11/23
- bug#4896: DocView: Continuous mode, Juri Linkov, 2009/11/23
- bug#4896: DocView: Continuous mode, Juri Linkov, 2009/11/24
- bug#4896: DocView: Continuous mode, Stefan Monnier, 2009/11/24
- bug#4896: DocView: Continuous mode, Juri Linkov, 2009/11/25
- bug#4896: DocView: Continuous mode, Juri Linkov, 2009/11/28
- Message not available
- bug#4896: DocView: Continuous mode, Tassilo Horn, 2009/11/29
- bug#4896: DocView: Continuous mode, Juri Linkov, 2009/11/29
- bug#4896: DocView: Continuous mode, Tassilo Horn, 2009/11/29
- bug#4896: DocView: Continuous mode, Juri Linkov, 2009/11/29