diff-apply-buffer: Operate on region, add prefix argument

* lisp/vc/diff-mode.el (diff-apply-buffer): Interactively,
operate on an active region.  Reverse-apply hunks with a prefix
argument, like C-u C-c C-a already does.
This commit is contained in:
Sean Whitton 2025-03-11 19:17:04 +08:00
parent 3b3170244d
commit 942bb22c9f

View file

@ -2193,12 +2193,18 @@ customize `diff-ask-before-revert-and-kill-hunk' to control that."
(defun diff-apply-buffer (&optional beg end reverse)
"Apply the diff in the entire diff buffer.
Interactively, if the region is active, apply all hunks that the region
overlaps; otherwise, apply all hunks.
With a prefix argument, reverse-apply the hunks.
If applying all hunks succeeds, save the changed buffers.
When called from Lisp with optional arguments, restrict the application
to hunks lying between BEG and END, and reverse-apply them when REVERSE is
non-nil. Returns nil if buffers were successfully modified and saved, or
the number of failed hunk applications otherwise."
(interactive)
to hunks lying between BEG and END, and reverse-apply them when REVERSE
is non-nil. Returns nil if buffers were successfully modified and
saved, or the number of failed hunk applications otherwise."
(interactive (list (use-region-beginning)
(use-region-end)
current-prefix-arg))
(let ((buffer-edits nil)
(failures 0)
(diff-refine nil))