unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: 4896@emacsbugs.donarmstrong.com, Tassilo Horn <tassilo@member.fsf.org>
Subject: bug#4896: DocView: Continuous mode
Date: Mon, 23 Nov 2009 11:47:18 +0200	[thread overview]
Message-ID: <87r5rpindl.fsf@mail.jurta.org> (raw)
In-Reply-To: <jwv8webhhm8.fsf-monnier+emacsbugreports@gnu.org> (Stefan Monnier's message of "Thu, 12 Nov 2009 10:49:57 -0500")

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





  parent reply	other threads:[~2009-11-23  9:47 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-10  7:45 bug#4896: DocView: Continuous mode Juri Linkov
2009-11-10 18:03 ` Stefan Monnier
2009-11-12  9:57   ` Juri Linkov
2009-11-12 11:04     ` Tassilo Horn
2009-11-12 11:14       ` Juri Linkov
2009-11-12 13:10         ` Tassilo Horn
2009-11-12 15:49           ` Stefan Monnier
2009-11-12 16:01             ` Tassilo Horn
2009-11-23  9:47             ` Juri Linkov [this message]
2009-11-23 11:07               ` Tassilo Horn
2009-11-23 20:43                 ` Juri Linkov
2009-11-24 17:08                   ` Juri Linkov
2009-11-24 19:48                     ` Stefan Monnier
2009-11-25 17:28                       ` Juri Linkov
2009-11-28 22:52                 ` Juri Linkov
     [not found]                 ` <mailman.11748.1259452054.2239.bug-gnu-emacs@gnu.org>
2009-11-29  9:27                   ` Tassilo Horn
2009-11-29 16:05                     ` Juri Linkov
2009-11-29 19:11                       ` Tassilo Horn
2009-11-29 22:05                         ` Juri Linkov
2009-11-30  7:32                           ` Tassilo Horn
2009-11-30 12:04                             ` Juri Linkov
2009-11-30 13:36                               ` Tassilo Horn
2009-11-30 16:17                                 ` Juri Linkov
2009-11-24 17:06           ` Juri Linkov
2009-11-23  9:52       ` Juri Linkov
2009-11-23 11:03         ` Tassilo Horn
2009-11-23 21:36           ` Stefan Monnier
2009-11-24 17:06           ` Juri Linkov
2009-12-16  9:23             ` Juri Linkov
2010-02-01 23:30               ` bug#4896: Doc-view-mode with View-mode Juri Linkov
2010-02-02  2:45                 ` Stefan Monnier
2010-02-02 22:49                   ` Juri Linkov
2010-02-03  2:36                     ` Stefan Monnier
2010-02-04  0:01                       ` Juri Linkov
2010-02-04 15:43                         ` Stefan Monnier
2010-02-04 19:45                           ` Juri Linkov
2010-02-04 22:35                             ` Stefan Monnier
2022-04-28 12:08 ` bug#4896: DocView: Continuous mode Lars Ingebrigtsen
2022-04-28 17:35   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r5rpindl.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=4896@emacsbugs.donarmstrong.com \
    --cc=monnier@IRO.UMontreal.CA \
    --cc=tassilo@member.fsf.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).