Subject: Re: bug#17544: 24.3; [PATCH] Improved diff-mode navigation/manipulation

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 24 Feb 2016 13:33:03 +1100

Dima Kogan <[email-masked]> writes:

> Navigation and use of diff buffers had several annoying corner cases that this
> patch fixes. These corner cases were largely due to inconsistent treatment of
> file headers. Say you have a diff such as this:
>
>  --- aaa
>  +++ bbb
>  @@ -52,7 +52,7 @@
>  hunk1
>  @@ -74,7 +74,7 @@
>  hunk2
>  --- ccc
>  +++ ddd
>  @@ -608,6 +608,6 @@
>  hunk3
>  @@ -654,7 +654,7 @@
>  hunk4
>
> The file headers here are the '---' and '+++' lines. With the point on such a
> line, hunk operations would sometimes refer to the next hunk and sometimes to
> the previous hunk. Most of the time it would be the previous hunk, which is not
> what the user would expect. This patch consistently treats such headers as the
> next hunk. So with this patch, if the point is on the '--- ccc' line, the point
> is seen as referring to hunk3.
>
> Specific behaviors this fixes are:
>
> 1. It should be possible to place the point in the middle of a diff buffer, and
> press M-k repeatedly to kill hunks in the order they appear in the buffer. With
> the point on hunk1, M-k M-k would kill hunk1 then hunk2. With the point on
> hunk3, it would kill hunk3 then hunk4; this is fine. However, with the point on
> hunk2, it'd kill hunk2 then hunk1. This is fixed by this patch.
>
> 2. Similarly, it should be possible to apply hunks in order. Previously with the
> point at the start, C-c C-a would apply the hunk1, then move the point to the
> first @@ header, and thus C-c C-a would try to apply the same hunk again.

I think this makes sense, and the patch looks good to me.  Does it still
apply to the Emacs trunk?  Anybody got any objections to installing it?

It should also have an entry in NEWS, I think.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no