bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#4896: DocView: Continuous mode


From: Tassilo Horn
Subject: bug#4896: DocView: Continuous mode
Date: Mon, 23 Nov 2009 12:07:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

Juri Linkov <address@hidden> writes:

Hi Juri,

> 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'.

Looks good to me, except that I have the feeling that this whole "check
if scolling happened" thingy could be refactored into its own functions
and used from doc-view-scroll-up-or-next-page and
doc-view-next-line-or-next-page (and the other two).

> 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?

Bye,
Tassilo

> 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 ()





reply via email to

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