Subject: bug#2541: 23.0.91; doc-view: unexpected scrolling after returning to text mode

From: Tassilo Horn <[email-masked]>
Date: Tue, 11 Jan 2011 22:13:13 +0100

Markus Triska <[email-masked]> writes:

> Given p.ps from:
>
>    http://www.logic.at/prolog/p.ps
>
> when I do:
>
> 1)   $ emacs -Q p.ps
>
> 2)   M-: (setq doc-view-ghostscript-options (list "-dSAFER" "-dNOPAUSE" "-sDEVICE=png16m" "-dTextAlphaBits=4" "-dBATCH" "-dGraphicsAlphaBits=4" "-dQUIET" "-dEPSCrop")) RET
>
> 3)   C-u - 1 M-r C-c C-c C-v C-c C-c
>
> then (as expected) doc-view returns to text mode, and point is on the
> same position where it was before entering graphics mode. When I then
> press C-p repeatedly, instead of moving point to the previous line,
> the text is unexpectedly scrolled down without moving point.

I can reproduce that (even without step 2) using

  GNU Emacs 24.0.50.1 (x86_64-pc-linux-gnu) of 2011-01-11 on thinkpad

However, C-p is bound to `previous-line' as usual in that context.

After edebugging a bit, I found that the reasion is that in

--8<---------------cut here---------------start------------->8---
(defun line-move (arg &optional noerror to-end try-vscroll)
  (unless (and auto-window-vscroll try-vscroll
	       ;; Only vscroll for single line moves
	       (= (abs arg) 1)
	       ;; But don't vscroll in a keyboard macro.
	       (not defining-kbd-macro)
	       (not executing-kbd-macro)
	       (line-move-partial arg noerror to-end))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    (set-window-vscroll nil 0 t)
    (if line-move-visual
	(line-move-visual arg noerror)
      (line-move-1 arg noerror to-end))))
--8<---------------cut here---------------end--------------->8---

the underlined call scrolls one line and returns some integer in that
context.  That makes the and clause return non-nil, and so the unless
body is not executed.  I don't know this part of emacs, so I don't know
how to fix the issue...

But I don't think that has something to do with doc-view.

Bye,
Tassilo