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

From: Tino Calancha <[email-masked]>
Date: Fri, 13 Jan 2017 15:26:44 +0900 (JST)

On Fri, 13 Jan 2017, [email-masked] wrote:

> merge 25400 25105
> tags 25400 patch
> quit
>
> I merged the bugs, and dropped #25400 from the cc list, because I'm
> getting duplicate emails everytime.
Thank you.  Sorry for the duplicated e-mails :-(
> While I'm on a meta topic, sorry
> for being hasty with merging the original patch that changed diff
> movement like that.  I didn't fully grasp it, nor tested like I should
> have done.
No problem.  Indeed you are helping a lot with the bugs.  Thank you very 
much.
>> ;; then, second commit (0beb7d2968ab76878eb3be26f2d749977fdcaa2f)
>> ;; add my fix for Bug#17544.
>
> I think the commit summary could be a bit friendlier, otherwise it looks
> good to me.
Thanks.  I agree: if i read my own commit after some months, probably i 
will not fully understand it.
I propose following more verbose one:

Fix Bug#17544

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