Subject: Re: bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions

From: Robert Pluim <[email-masked]>
Date: Wed, 04 Sep 2024 15:01:23 +0200

>>>>> On Wed, 4 Sep 2024 09:30:58 +0200, Paul Nelson <[email-masked]> said:

    Paul> Many thanks for your suggestion.  I agree that this is a more elegant
    Paul> approach, which also admits a simpler implementation.  I've attached
    Paul> my revised patch.  Any further feedback welcome.

Minor comments below

    Paul> Thanks, best,

    Paul> Paul

    Paul> From 91ade3effdbf19b7d8793020a1c31a4ff791a58d Mon Sep 17 00:00:00 2001
    Paul> From: Paul Nelson <[email-masked]>
    Paul> Date: Wed, 4 Sep 2024 09:24:25 +0200
    Paul> Subject: [PATCH] Add Ediff feature for copying all differences

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

    Paul> * doc/misc/ediff.texi (Quick Help Commands):
    Paul> * etc/NEWS: (Lisp Changes in Emacs 31.1): Document the new
    Paul> feature.
    Paul> ---
    Paul>  doc/misc/ediff.texi   | 26 ++++++++++++++------------
    Paul>  etc/NEWS              | 16 ++++++++++++++++
    Paul>  lisp/vc/ediff-util.el | 29 +++++++++++++++++------------
    Paul>  3 files changed, 47 insertions(+), 24 deletions(-)

    Paul> diff --git a/doc/misc/ediff.texi b/doc/misc/ediff.texi
    Paul> index 749025c870b..6afb38e3fae 100644
    Paul> --- a/doc/misc/ediff.texi
    Paul> +++ b/doc/misc/ediff.texi
    Paul> @@ -489,15 +489,16 @@ Quick Help Commands
    Paul>  @item a
    Paul>  @kindex a
    Paul>  @emph{In comparison sessions:}
    Paul> -Copies the current difference region (or the region specified as the prefix
    Paul> -to this command) from buffer A to buffer B@.
    Paul> -Ediff saves the old contents of buffer B's region; it can
    Paul> -be restored via the command @kbd{rb}, which see.
    Paul> +Copies the current difference region (or the region specified as the
    Paul> +prefix to this command, or @emph{all} regions with @kbd{C-u} prefix)
    Paul> +from buffer A to buffer B@.  Ediff saves the old contents of buffer B's
    Paul> +region; it can be restored via the command @kbd{rb}, which see.

'numerical prefix' maybe? Although that part of the text is not new.

    Paul>  @emph{In merge sessions:}
    Paul> -Copies the current difference region (or the region specified as the prefix
    Paul> -to this command) from buffer A to the merge buffer.  The old contents of
    Paul> -this region in buffer C can be restored via the command @kbd{r}.
    Paul> +Copies the current difference region (or the region specified as the
    Paul> +prefix to this command, or @emph{all} regions with @kbd{C-u} prefix)
    Paul> +from buffer A to the merge buffer.  The old contents of this region in
    Paul> +buffer C can be restored via the command @kbd{r}.

Similarly here

    Paul>  @item b
    Paul>  @kindex b
    Paul> @@ -511,11 +512,12 @@ Quick Help Commands
 
    Paul>  @item ab
    Paul>  @kindex ab
    Paul> -Copies the current difference region (or the region specified as the prefix
    Paul> -to this command) from buffer A to buffer B@.  This (and the next five)
    Paul> -command is enabled only in sessions that compare three files
    Paul> -simultaneously.  The old region in buffer B is saved and can be restored
    Paul> -via the command @kbd{rb}.
    Paul> +Copies the current difference region (or the region specified as the
    Paul> +prefix to this command, or @emph{all} regions with @kbd{C-u} prefix)
    Paul> +from buffer A to buffer B@.  This (and the next five) command is enabled
    Paul> +only in sessions that compare three files simultaneously.  The old
    Paul> +region in buffer B is saved and can be restored via the command
    Paul> +@kbd{rb}.

and here.

    Paul>  @item ac
    Paul>  @kindex ac
    Paul>  Copies the difference region from buffer A to buffer C@.
    Paul> diff --git a/etc/NEWS b/etc/NEWS
    Paul> index f10f9ae4d65..a6db0c96288 100644
    Paul> --- a/etc/NEWS
    Paul> +++ b/etc/NEWS
    Paul> @@ -121,6 +121,22 @@ A new ':authorizable t' parameter has been added to 'dbus-call-method'
    Paul>  and 'dbus-call-method-asynchronously' to allow the user to interactively
    Paul>  authorize the invoked D-Bus method (e.g., via polkit).
 
    Paul> ++++
    Paul> +** Ediff's copy commands now apply to all changes with 'C-u' prefix.
    Paul> +The Ediff copy commands, bound to 'a', 'b', 'ab', etc., now copy all
    Paul> +changes when supplied with a universal prefix argument via 'C-u':
    Paul> +
    Paul> +- 'C-u a' copies all changes from buffer A to buffer B (in 2-way diff)
    Paul> +  or to buffer C (in 3-way diff or merge).
    Paul> +- 'C-u b' copies all changes from buffer B to buffer A (in 2-way diff)
    Paul> +  or to buffer C (in 3-way diff or merge).
    Paul> +- 'C-u a b' copies all changes from buffer A to buffer B.
    Paul> +- 'C-u b a' copies all changes from buffer B to buffer A.
    Paul> +- 'C-u a c' copies all changes from buffer A to buffer C.
    Paul> +- 'C-u b c' copies all changes from buffer B to buffer C.
    Paul> +- 'C-u c a' copies all changes from buffer C to buffer A.
    Paul> +- 'C-u c b' copies all changes from buffer C to buffer B.
    Paul> +

You should add an '** Ediff' section to 'Changes in Specialized Modes
and Packages in Emacs 31.1' and put this change there.

    Paul>  
    Paul>  * Changes in Emacs 31.1 on Non-Free Operating Systems
 
    Paul> diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el
    Paul> index 597d8a5e643..c2cdf7d4e5e 100644
    Paul> --- a/lisp/vc/ediff-util.el
    Paul> +++ b/lisp/vc/ediff-util.el
    Paul> @@ -1891,7 +1891,7 @@ ediff-diff-at-point
    Paul>  (defun ediff-diff-to-diff (arg &optional keys)
    Paul>    "Copy buffer-X'th difference region to buffer Y (X,Y are A, B, or C).
    Paul>  With numerical prefix argument ARG, copy the difference specified
    Paul> -in the arg.
    Paul> +in the arg.  With prefix `C-u', copy all differences.

In docstrings `C-u' is written `\\[universal-argument]' (not that Iʼve
ever been tempted to change it from `C-u' :-))

Eli, does this change need a copyright assigment? I donʼt see
[email-masked]' in the git logs anywhere.

Robert
--