bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Stefan Monnier
Subject: bug#34723: 27.0.50; customize and improve diff-mode recentering
Date: Wed, 13 Mar 2019 15:40:16 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

[ Author responsible for the call to recenter speaking ;-) ]

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

That's indeed the purpose.  When I move to the next hunk, I almost
always want to see that hunk, and that often requires some kind of
"recentering".

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

That's clearly undesirable, indeed.  I think it's a plain bug.

Basically when moving in one direction, diff-hunk-next/prev should never
scroll the buffer in the other direction.

> The current implementation seems a little too eager.

Sometimes it's also not eager enough (if the hunk is longer than half of
the screen, it shouldn't just recenter but it should likely scroll
further so that more than half of the screen shows the hunk).

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

Not sure what you mean.  I have scroll-conservatively set to 0.
How should I set it to get the recentering that I want?
As for scroll-margin, I don't like using it.  Also it would affect all
cursor movement rather than only diff-hunk-* and would force point
closer to the middle which is not what I want when the hunk is longer
than half the window.

In your original message you said:
> We found that this behavior does not respect scroll-related variables

Did that only refer to `scroll-conservatively`?  If not, could you
clarify which scroll-related variable setting is not respected,
and when?


        Stefan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]