unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Page navigation in doc-view.el
@ 2015-01-15 11:22 Vaidheeswaran
  2015-01-15 11:34 ` Alexis
  2015-01-15 14:54 ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Vaidheeswaran @ 2015-01-15 11:22 UTC (permalink / raw)
  To: emacs-devel


Context:

I am on a netbook with limited screenspace.  I am using doc-view for
`correcting' tesseracted documents.  The top window holds the scanned
pdf file and the bottom window holds the ascii text.  I have some
local changes that enables to ascii text pages to 'follow' the
corresponding pages in the doc-view.

Problem:

The 'p' and 'n' commands (also bound to C-x [ and and C-x ])navigate
to prev and next page resply.  BUT it leaves me not in the beginning
or end of the page but somewhere in the "middle" of the page.  (This
behaviour is very useful in some circumstances.  For example, in
inspecting footnotes.)

That said, I would have expected to the canonical behaviour of the
above commands to leave me at the beginning of page or end of page.
(i.e., above commands followed up with '<' and '>')

What do you think?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Page navigation in doc-view.el
  2015-01-15 11:22 Page navigation in doc-view.el Vaidheeswaran
@ 2015-01-15 11:34 ` Alexis
  2015-01-15 11:43   ` Vaidheeswaran
  2015-01-15 14:54 ` Stefan Monnier
  1 sibling, 1 reply; 7+ messages in thread
From: Alexis @ 2015-01-15 11:34 UTC (permalink / raw)
  To: emacs-devel


Vaidheeswaran writes:

> The 'p' and 'n' commands (also bound to C-x [ and and C-x ])navigate
> to prev and next page resply.  BUT it leaves me not in the beginning
> or end of the page but somewhere in the "middle" of the page.  (This
> behaviour is very useful in some circumstances.  For example, in
> inspecting footnotes.)
>
> That said, I would have expected to the canonical behaviour of the
> above commands to leave me at the beginning of page or end of page.
> (i.e., above commands followed up with '<' and '>')

This has been an issue for me also; i've addressed it via the following
advice:

    (defadvice doc-view-next-page (after doc-view-next-page-move-to-top activate)
      "After moving to next page, move to top of page."
      (image-set-window-vscroll 0))

    (defadvice doc-view-previous-page (after doc-view-previous-page-move-to-bottom activate)
      "After moving to previous page, move to bottom of page."
      (image-set-window-vscroll (+ 2 (/ (window-height) 2))))


Alexis.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Page navigation in doc-view.el
  2015-01-15 11:34 ` Alexis
@ 2015-01-15 11:43   ` Vaidheeswaran
  0 siblings, 0 replies; 7+ messages in thread
From: Vaidheeswaran @ 2015-01-15 11:43 UTC (permalink / raw)
  To: emacs-devel

On Thursday 15 January 2015 05:04 PM, Alexis wrote:
> This has been an issue for me also; i've addressed it via the following
> advice:
>
>      (defadvice doc-view-next-page (after doc-view-next-page-move-to-top activate)
>        "After moving to next page, move to top of page."
>        (image-set-window-vscroll 0))
>
>      (defadvice doc-view-previous-page (after doc-view-previous-page-move-to-bottom activate)
>        "After moving to previous page, move to bottom of page."
>        (image-set-window-vscroll (+ 2 (/ (window-height) 2))))


It took some time to identify `image-bob' and `image-eob'.  May be we 
can have a prefix arg. to the page navigation command: without prefix it 
will leave me at bob but with a prefix it will retain the "relative 
position".

I recommend that the current behaviour be fixed.  (It should be an easy 
fix!)





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Page navigation in doc-view.el
  2015-01-15 11:22 Page navigation in doc-view.el Vaidheeswaran
  2015-01-15 11:34 ` Alexis
@ 2015-01-15 14:54 ` Stefan Monnier
  2015-01-15 15:14   ` Vaidheeswaran C
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2015-01-15 14:54 UTC (permalink / raw)
  To: Vaidheeswaran; +Cc: emacs-devel

> The 'p' and 'n' commands (also bound to C-x [ and and C-x ])navigate
> to prev and next page resply.  BUT it leaves me not in the beginning
> or end of the page but somewhere in the "middle" of the page.  (This
> behaviour is very useful in some circumstances.  For example, in
> inspecting footnotes.)

Indeed, this is a feature, rather than a bug (it's even a feature that
I sorely miss in pretty much every other PDF viewer and one of the main
reasons why I tend to prefer Emacs to view PDF documents).

> That said, I would have expected to the canonical behaviour of the
> above commands to leave me at the beginning of page or end of page.
> (i.e., above commands followed up with '<' and '>')

> What do you think?

IIRC there's a variable doc-view-continuous to choose the behavior, tho
IIRC it affects SPC/DEL rather than n/p.


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Page navigation in doc-view.el
  2015-01-15 14:54 ` Stefan Monnier
@ 2015-01-15 15:14   ` Vaidheeswaran C
  2015-01-15 16:05     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Vaidheeswaran C @ 2015-01-15 15:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Thursday 15 January 2015 08:24 PM, Stefan Monnier wrote:
> IIRC there's a variable doc-view-continuous to choose the behavior, tho
> IIRC it affects SPC/DEL rather than n/p.
>    
It affects scrolling by window-fuls and possibly jump to next page.   I 
do use it.

What I want is C-x [, C-x ]  and M-g M-g  leave me at the beginning of 
the page (rather than somewhere in the middle).

There is some other user -- see right in this thread -- who misses the 
feature I am requesting.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Page navigation in doc-view.el
  2015-01-15 15:14   ` Vaidheeswaran C
@ 2015-01-15 16:05     ` Stefan Monnier
  2015-01-18  8:09       ` Vaidheeswaran
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2015-01-15 16:05 UTC (permalink / raw)
  To: Vaidheeswaran C; +Cc: emacs-devel

>> IIRC there's a variable doc-view-continuous to choose the behavior, tho
>> IIRC it affects SPC/DEL rather than n/p.
> It affects scrolling by window-fuls and possibly jump to next page.   I do
> use it.
> What I want is C-x [, C-x ]  and M-g M-g  leave me at the beginning of the
> page (rather than somewhere in the middle).
> There is some other user -- see right in this thread -- who misses the
> feature I am requesting.

I think it would make sense to make `n' jump to the beginning of the
next page (and `p' go to the bottom of the previous page) when
doc-view-continuous is non-nil.

For M-g M-g, maybe as well (again conditional on doc-view-continuous).

Of course, I also think that doc-view-continuous should ideally render
all the pages at the same time in the buffer (stacked vertically), so
you can scroll through them with the usual scrolling commands, but that
will take a good bit more work.


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Page navigation in doc-view.el
  2015-01-15 16:05     ` Stefan Monnier
@ 2015-01-18  8:09       ` Vaidheeswaran
  0 siblings, 0 replies; 7+ messages in thread
From: Vaidheeswaran @ 2015-01-18  8:09 UTC (permalink / raw)
  To: emacs-devel; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 677 bytes --]

On Thursday 15 January 2015 09:35 PM, Stefan Monnier wrote:
> I think it would make sense to make `n' jump to the beginning of the
> next page (and `p' go to the bottom of the previous page) when
> doc-view-continuous is non-nil.
>
> For M-g M-g, maybe as well (again conditional on doc-view-continuous).

I am attaching a patch.  Fyi, I have queued up an assignment request 
already and I am waiting for a response.

> Of course, I also think that doc-view-continuous should ideally render
> all the pages at the same time in the buffer (stacked vertically), so
> you can scroll through them with the usual scrolling commands, but that
> will take a good bit more work.

Ok.


[-- Attachment #2: 0001-Fix-page-navigation-when-doc-view-continuous-is-nil.patch --]
[-- Type: text/x-patch, Size: 1259 bytes --]

From f72775037ecb8ed9dadbe0775e969e90663dd86f Mon Sep 17 00:00:00 2001
From: Vaidheeswaran C <vaidheeswaran.chinnaraju@gmail.com>
Date: Sun, 18 Jan 2015 13:29:04 +0530
Subject: [PATCH] Fix page navigation when `doc-view-continuous' is nil.

---
 lisp/doc-view.el |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 0e63d37..21a0883 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -527,6 +527,7 @@ Typically \"page-%s.png\".")
                  (format doc-view--image-file-pattern page)
                  (doc-view--current-cache-dir))))
       (doc-view-insert-image file :pointer 'arrow)
+      (unless doc-view-continuous (image-bob))
       (when (and (not (file-exists-p file))
                  doc-view--current-converter-processes)
         ;; The PNG file hasn't been generated yet.
@@ -553,7 +554,8 @@ Typically \"page-%s.png\".")
 (defun doc-view-previous-page (&optional arg)
   "Browse ARG pages backward."
   (interactive "p")
-  (doc-view-goto-page (- (doc-view-current-page) (or arg 1))))
+  (doc-view-goto-page (- (doc-view-current-page) (or arg 1)))
+  (unless doc-view-continuous (image-eob)))
 
 (defun doc-view-first-page ()
   "View the first page."
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-18  8:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-15 11:22 Page navigation in doc-view.el Vaidheeswaran
2015-01-15 11:34 ` Alexis
2015-01-15 11:43   ` Vaidheeswaran
2015-01-15 14:54 ` Stefan Monnier
2015-01-15 15:14   ` Vaidheeswaran C
2015-01-15 16:05     ` Stefan Monnier
2015-01-18  8:09       ` Vaidheeswaran

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