Subject: Re: bug#73407: 31.0.50; Add diff-discard-hunk

From: Juri Linkov <[email-masked]>
Date: Tue, 24 Sep 2024 09:36:27 +0300

> These patches add a new command, diff-discard-hunk, inspired by some
> functionality from Magit.  It nicely complements a workflow based around
> committing with C-x v v from C-x v D.  I have been using it every day
> for a year or so, and I think others will find it useful, too.
>
> Posting for comments.  Thanks!

It was hard to understand how it's related to C-x v v.
But then I realized it saves time to do what currently is done with:
'C-c C-r' (diff-reverse-direction)
'C-c C-a' (diff-apply-hunk)
'k' (diff-hunk-kill).

> +(defcustom diff-display-after-apply-hunk t
> +  "Non-nil means `diff-apply-hunk' will display the buffer it just changed."
> +  :type 'boolean)
> +
> @@ -2024,7 +2028,8 @@ diff-apply-hunk
> -      (set-window-point (display-buffer buf) (+ (car pos) (cdr new)))
> +      (when diff-display-after-apply-hunk
> +        (set-window-point (display-buffer buf) (+ (car pos) (cdr new))))

Probably this change is not needed if 'diff-discard-hunk'
could avoid using 'diff-apply-hunk', and instead rely
on the algorithm from 'diff-apply-buffer'.  Also optional
region arguments 'beg' and 'end' could be added to
'diff-apply-buffer'.