Subject: bug#337: vc-diff forget previous point

From: Stefan Monnier <[email-masked]>
Date: Tue, 03 Jun 2008 03:24:32 -0400

> With a file under version control, I do C-x v = (vc-diff) to walk
> through and resolve differences.  Since there are many, I re-issue
> vc-diff to see the remaining differences.  Unfortunately, vc-diff
> forgets the previous point in buffer *vc-diff* resetting point to 0.
> My expectation would be that the cursor remains where it has been (not
> the literal point but the corresponding part to the same source line).

> Maybe something similar to C-c C-c (diff-goto-source) but in the other
> direction would be useful in general.

Indeed.  Dan had a patch to do just that, but it was never applied and
it doesn't work any more, AFAICT.

I never applied his patch because it wasn't doing quite the right thing.
I think "The Right Thing" is to first look for the part of the diff that
refers to the current file (in case the diff includes several files),
and then within it, use a binary search with `diff-goto-source' to
figure out the position in the diff buffer that jumps closest to point.
This way, if point is within a part of the buffer where a hunk applies,
the function should be able to find the exact character position
corresponding to point, just like diff-goto-source does in the
other direction.

Patch welcome,

        Stefan