Subject: bug#25105: M-p in diff-mode jumps too far

From: Tino Calancha <[email-masked]>
Date: Wed, 18 Jan 2017 15:11:16 +0900 (JST)

On Wed, 18 Jan 2017, Dmitry Gutov wrote:

> On 16.01.2017 09:26, Tino Calancha wrote:
>
>> OK, below is my draft for the second commit.
>> Please don't hesitate to send me comments to make it more clear or/and
>> fix some broken grammar.
>
> Here's a fresh idea. If we're not going to worry about (not) showing Dima's 
> commit message in the generated change log, maybe the new message should talk 
> about tweaking the code, and not retell the original message.
>
> Or the users will read it twice, basically. But only those users that read 
> change logs, of course.
OK, it's reasonable.
See my new draft for commit 0beb7d2968ab76878eb3be26f2d749977fdcaa2f
in branch scratch/calancha-revert-2c8a7e5:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Make diff-apply-hunk independent of point within a diff header

Make diff-apply-hunk and diff-hunk-kill independent of the point
position in a diff header (Bug#17544).
This change allows to apply hunks in order.  It also makes possible to
press M-k repeatedly to kill hunks in the order they appear in the buffer.

* lisp/vc/diff-mode.el (diff-file-junk-re):
Move definition before it's used.
(diff--at-diff-header-p): New predicate; return non-nil when point
is inside a hunk header, a file header, or within a line
matching diff-file-junk-re.
(diff-beginning-of-hunk): Use it.
Check if the point is inside a diff header, in the middle of a hunk,
or before the first hunk.
(diff-apply-hunk): Call diff-beginning-of-hunk with non-nil arg
before apply the hunk.
(diff-hunk-kill, diff-file-kill):
Call diff-beginning-of-hunk with non-nil arg after kill the hunks.
(diff-post-command-hook): Call diff-beginning-of-hunk with non-nil argument.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;