Subject: bug#34723: 27.0.50; customize and improve diff-mode recentering

From: [email-masked] (Charles A. Roelli)
Date: Thu, 07 Mar 2019 20:49:54 +0100

> Date: Wed, 06 Mar 2019 18:06:14 +0200
> From: Eli Zaretskii <[email-masked]>
> 
> Why does it call 'recenter'?  It must have a reason, doesn't it?  Does
> the history of that code gives a clue?

The doc of easy-mmode-define-navigation says:

  BASE-next also tries to make sure that the whole entry is visible by
  searching for its end (by calling ENDFUN if provided or by looking for
  the next entry) and recentering if necessary.

There are cases where recentering does "make sure that the whole entry
is visible", but as we saw in the first post of this report, there is
at least one case where recentering makes less useful context visible.
The current implementation seems a little too eager.  I'd like to fix
that, and at least allow to toggle the auto-recentering.

> Note that without recentering, if you just move point to some location
> in the diffs, when scroll-conservatively > 100, point will wind up
> either on the last screen line of the window or its first screen line,
> depending on whether you move forward or back in the buffer.  The
> latter might be okay, but the former will most probably hide most of
> the hunk, which might be the reason for recentering (I'm just guessing
> here).

Yes, I think you are right.  Maybe diff-mode could have just set
scroll-conservatively (or scroll-margin) in a buffer-local variable to
get this auto-recentering behavior, although that would also step on
user customizations.