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 @item a
@kindex a @kindex a
@emph{In comparison sessions:} @emph{In comparison sessions:}
Copies the current difference region (or the region specified as the prefix Copies the current difference region (or the region specified as the
to this command) from buffer A to buffer B@. numerical prefix to this command, or @emph{all} regions with @kbd{C-u}
Ediff saves the old contents of buffer B's region; it can prefix) from buffer A to buffer B@. Ediff saves the old contents of
be restored via the command @kbd{rb}, which see. buffer B's region; it can be restored via the command @kbd{rb}, which
see.
@emph{In merge sessions:} @emph{In merge sessions:}
Copies the current difference region (or the region specified as the prefix Copies the current difference region (or the region specified as the
to this command) from buffer A to the merge buffer. The old contents of numerical prefix to this command, or @emph{all} regions with @kbd{C-u}
this region in buffer C can be restored via the command @kbd{r}. 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 @item b
@kindex b @kindex b
@ -511,11 +513,12 @@ be reinstated via the command @kbd{ra} in comparison sessions and
@item ab @item ab
@kindex ab @kindex ab
Copies the current difference region (or the region specified as the prefix Copies the current difference region (or the region specified as the
to this command) from buffer A to buffer B@. This (and the next five) numerical prefix to this command, or @emph{all} regions with @kbd{C-u}
command is enabled only in sessions that compare three files prefix) from buffer A to buffer B@. This (and the next five) command is
simultaneously. The old region in buffer B is saved and can be restored enabled only in sessions that compare three files simultaneously. The
via the command @kbd{rb}. old region in buffer B is saved and can be restored via the command
@kbd{rb}.
@item ac @item ac
@kindex ac @kindex ac
Copies the difference region from buffer A to buffer C@. 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 argument, 'php-ts-mode-run-php-webserver' prompts for the config file as
well as for other connection parameters. 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 * 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) (defun ediff-diff-to-diff (arg &optional keys)
"Copy buffer-X'th difference region to buffer Y (X,Y are A, B, or C). "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 With numerical prefix argument ARG, copy the difference specified in the
in the arg. arg. With prefix `\\[universal-argument]', copy all differences.
Otherwise, copy the difference given by `ediff-current-difference'. Otherwise, copy the difference given by `ediff-current-difference'.
This command assumes it is bound to a 2-character key sequence, `ab', `ba', 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 `ac', etc., which is used to determine the types of buffers to be used for
@ -1904,17 +1904,23 @@ command keys."
(interactive "P") (interactive "P")
(ediff-barf-if-not-control-buffer) (ediff-barf-if-not-control-buffer)
(or keys (setq keys (this-command-keys))) (or keys (setq keys (this-command-keys)))
(if (eq arg '-) (setq arg -1)) ; translate neg arg to -1 (if (equal arg '(4))
(if (numberp arg) (ediff-jump-to-difference arg)) ;; 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))
(let* ((char1 (aref keys 0)) (let* ((char1 (aref keys 0))
(char2 (aref keys 1)) (char2 (aref keys 1))
ediff-verbose-p) ediff-verbose-p)
(ediff-copy-diff ediff-current-difference (ediff-copy-diff ediff-current-difference
(ediff-char-to-buftype char1) (ediff-char-to-buftype char1)
(ediff-char-to-buftype char2)) (ediff-char-to-buftype char2))
;; recenter with rehighlighting, but no messages ;; recenter with rehighlighting, but no messages
(ediff-recenter))) (ediff-recenter))))
(defun ediff-copy-A-to-B (arg) (defun ediff-copy-A-to-B (arg)
"Copy ARGth difference region from buffer A to B. "Copy ARGth difference region from buffer A to B.