Subject: Re: bug#4368: 23.1; diff-hunk-kill -vs- final hunk in a file

From: Stefan Monnier <[email-masked]>
Date: Wed, 09 Sep 2009 10:49:29 -0400

Stefan> Can you show the content before the last M-k ?
> The appended is a sample diff.  I just grabbed a couple random hunks
> from the actual diff I was editing.  It was originally made by git.

> Put it in a file, then M-x diff-mode.
> M-n to go to the first @@.
> M-k.

> You will see that all the header info from lisp.h remains in the buffer.

> I don't think you even need the second file diff in there to see this, a
> single file will do.

Hmm... indeed it fails all the time.  Yet, I'm sure it used to work.
Anyway, the patch below seems to fix it.
Thanks,

        Stefan

Index: lisp/diff-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/diff-mode.el,v
retrieving revision 1.161
diff -u -r1.161 diff-mode.el
--- lisp/diff-mode.el	1 Sep 2009 07:24:18 -0000	1.161
+++ lisp/diff-mode.el	9 Sep 2009 14:47:45 -0000
@@ -546,7 +546,8 @@
   (interactive)
   (diff-beginning-of-hunk)
   (let* ((start (point))
-	 (nexthunk (when (re-search-forward diff-hunk-header-re nil t)
+         ;; Search the second match, since we're looking at the first.
+	 (nexthunk (when (re-search-forward diff-hunk-header-re nil t 2)
 		     (match-beginning 0)))
 	 (firsthunk (ignore-errors
 		      (goto-char start)