Add Ediff feature for copying all differences

* lisp/vc/ediff-util.el (ediff-diff-to-diff): With universal
prefix, copy all differences.

* doc/misc/ediff.texi (Quick Help Commands): Document the new feature.
* etc/NEWS: Announce the new feature.

(Bug#72866)
This commit is contained in:
Paul Nelson 2024-09-04 09:24:25 +02:00 committed by Robert Pluim
parent fc3a7f4529
commit 833158c0b7
3 changed files with 51 additions and 24 deletions

View file

@ -489,15 +489,17 @@ compares three files simultaneously).
@item a
@kindex a
@emph{In comparison sessions:}
Copies the current difference region (or the region specified as the prefix
to this command) from buffer A to buffer B@.
Ediff saves the old contents of buffer B's region; it can
be restored via the command @kbd{rb}, which see.
Copies the current difference region (or the region specified as the
numerical prefix to this command, or @emph{all} regions with @kbd{C-u}
prefix) from buffer A to buffer B@. Ediff saves the old contents of
buffer B's region; it can be restored via the command @kbd{rb}, which
see.
@emph{In merge sessions:}
Copies the current difference region (or the region specified as the prefix
to this command) from buffer A to the merge buffer. The old contents of
this region in buffer C can be restored via the command @kbd{r}.
Copies the current difference region (or the region specified as the
numerical prefix to this command, or @emph{all} regions with @kbd{C-u}
prefix) from buffer A to the merge buffer. The old contents of this
region in buffer C can be restored via the command @kbd{r}.
@item b
@kindex b
@ -511,11 +513,12 @@ be reinstated via the command @kbd{ra} in comparison sessions and
@item ab
@kindex ab
Copies the current difference region (or the region specified as the prefix
to this command) from buffer A to buffer B@. This (and the next five)
command is enabled only in sessions that compare three files
simultaneously. The old region in buffer B is saved and can be restored
via the command @kbd{rb}.
Copies the current difference region (or the region specified as the
numerical prefix to this command, or @emph{all} regions with @kbd{C-u}
prefix) from buffer A to buffer B@. This (and the next five) command is
enabled only in sessions that compare three files simultaneously. The
old region in buffer B is saved and can be restored via the command
@kbd{rb}.
@item ac
@kindex ac
Copies the difference region from buffer A to buffer C@.

View file

@ -298,6 +298,24 @@ the built-in Web server. Interactively, when invoked with a prefix
argument, 'php-ts-mode-run-php-webserver' prompts for the config file as
well as for other connection parameters.
** Ediff
+++
*** Ediff's copy commands now apply to all changes with 'C-u' prefix.
The Ediff copy commands, bound to 'a', 'b', 'ab', etc., now copy all
changes when supplied with a universal prefix argument via 'C-u':
- 'C-u a' copies all changes from buffer A to buffer B (in 2-way diff)
or to buffer C (in 3-way diff or merge).
- 'C-u b' copies all changes from buffer B to buffer A (in 2-way diff)
or to buffer C (in 3-way diff or merge).
- 'C-u a b' copies all changes from buffer A to buffer B.
- 'C-u b a' copies all changes from buffer B to buffer A.
- 'C-u a c' copies all changes from buffer A to buffer C.
- 'C-u b c' copies all changes from buffer B to buffer C.
- 'C-u c a' copies all changes from buffer C to buffer A.
- 'C-u c b' copies all changes from buffer C to buffer B.
* New Modes and Packages in Emacs 31.1

View file

@ -1890,8 +1890,8 @@ current point position in the specified buffer."
(defun ediff-diff-to-diff (arg &optional keys)
"Copy buffer-X'th difference region to buffer Y (X,Y are A, B, or C).
With numerical prefix argument ARG, copy the difference specified
in the arg.
With numerical prefix argument ARG, copy the difference specified in the
arg. With prefix `\\[universal-argument]', copy all differences.
Otherwise, copy the difference given by `ediff-current-difference'.
This command assumes it is bound to a 2-character key sequence, `ab', `ba',
`ac', etc., which is used to determine the types of buffers to be used for
@ -1904,6 +1904,12 @@ command keys."
(interactive "P")
(ediff-barf-if-not-control-buffer)
(or keys (setq keys (this-command-keys)))
(if (equal arg '(4))
;; copy all differences with `C-u' prefix
(let ((n 0))
(while (ediff-valid-difference-p n)
(ediff-diff-to-diff (1+ n) keys)
(setq n (1+ n))))
(if (eq arg '-) (setq arg -1)) ; translate neg arg to -1
(if (numberp arg) (ediff-jump-to-difference arg))
@ -1914,7 +1920,7 @@ command keys."
(ediff-char-to-buftype char1)
(ediff-char-to-buftype char2))
;; recenter with rehighlighting, but no messages
(ediff-recenter)))
(ediff-recenter))))
(defun ediff-copy-A-to-B (arg)
"Copy ARGth difference region from buffer A to B.