]> git.eshelyaron.com Git - emacs.git/commitdiff
Implement DocView Continuous mode. (Bug#4896)
authorJuri Linkov <juri@jurta.org>
Mon, 23 Nov 2009 20:34:53 +0000 (20:34 +0000)
committerJuri Linkov <juri@jurta.org>
Mon, 23 Nov 2009 20:34:53 +0000 (20:34 +0000)
* doc-view.el (doc-view-continuous-mode): New defcustom.
(doc-view-mode-map): Bind C-n/<down> to `doc-view-next-line-or-next-page',
C-p/<up> to `doc-view-previous-line-or-previous-page'.
(doc-view-next-line-or-next-page)
(doc-view-previous-line-or-previous-page): New commands.

etc/NEWS
lisp/ChangeLog
lisp/doc-view.el

index 27f3b9868d838284730fa556fd6036e085aaa7df..51c3ee62a6018d36f53967d71ef8211e63e41d38 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -192,6 +192,11 @@ effective for buffers that have no associated file.  If you want to
 exempt buffers that do correspond to files, customize the value of
 `desktop-files-not-to-save' instead.
 
+** DocView
+
+*** When `doc-view-continuous-mode' is non-nil, scrolling a line
+on the page edge advances to the next/previous page.
+
 ** FIXME mail-user-agent change
 This probably affects a lot of documentation.
 
index 96573b7508e89b400bd62bfe2a5d3fdb03f94094..1ab6ac35ebcb12b81d020d1bb99ed01e151b514e 100644 (file)
@@ -1,3 +1,12 @@
+2009-11-23  Juri Linkov  <juri@jurta.org>
+
+       Implement DocView Continuous mode.  (Bug#4896)
+       * doc-view.el (doc-view-continuous-mode): New defcustom.
+       (doc-view-mode-map): Bind C-n/<down> to `doc-view-next-line-or-next-page',
+       C-p/<up> to `doc-view-previous-line-or-previous-page'.
+       (doc-view-next-line-or-next-page)
+       (doc-view-previous-line-or-previous-page): New commands.
+
 2009-11-23  Juri Linkov  <juri@jurta.org>
 
        Implement Isearch in comint input history.  (Bug#3746)
index 3ea4fcecfde67a41b9e02a332e505eaec0da2f61..afb2e48b145fe34d263461897002a1eb90e95a84 100644 (file)
@@ -222,6 +222,15 @@ has finished."
   :type 'integer
   :group 'doc-view)
 
+(defcustom doc-view-continuous-mode nil
+  "In Continuous mode reaching the page edge advances to 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,6 +295,10 @@ Can be `dvi', `pdf', or `ps'.")
     (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,6 +455,38 @@ Can be `dvi', `pdf', or `ps'.")
        (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 ()