unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions
@ 2024-08-29  6:03 Paul Nelson
  2024-08-31 10:32 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Nelson @ 2024-08-29  6:03 UTC (permalink / raw)
  To: 72866

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

This patch binds functions in Ediff that copy all changes from one
buffer to another, without having to manually go through each
difference.  Any feedback welcome.

Thanks, best,

Paul

[-- Attachment #2: 0001-Add-ediff-copy-all-X-to-Y-functions.patch --]
[-- Type: application/octet-stream, Size: 4629 bytes --]

From 1550af9b786cff03d37725c69b53c4b711a9f45c Mon Sep 17 00:00:00 2001
From: Paul Nelson <ultrono@gmail.com>
Date: Thu, 29 Aug 2024 07:50:27 +0200
Subject: [PATCH] Add ediff-copy-all-X-to-Y functions

* lisp/vc/ediff-util.el (ediff--copy-all):
(ediff-copy-all-A-to-B):
(ediff-copy-all-B-to-A):
(ediff-copy-all-A-to-C):
(ediff-copy-all-B-to-C):
(ediff-copy-all-C-to-A):
(ediff-copy-all-C-to-B): New functions.
(ediff-setup-keymap): Bind them.
---
 lisp/vc/ediff-util.el | 64 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el
index 597d8a5e643..b575eaeca75 100644
--- a/lisp/vc/ediff-util.el
+++ b/lisp/vc/ediff-util.el
@@ -159,6 +159,8 @@ ediff-setup-keymap
 	 ;; In merging, we allow only A->C and B->C copying.
 	 (define-key ediff-mode-map "a" #'ediff-copy-A-to-C)
 	 (define-key ediff-mode-map "b" #'ediff-copy-B-to-C)
+	 (define-key ediff-mode-map "C-c C-a" #'ediff-copy-all-A-to-C)
+	 (define-key ediff-mode-map "C-c C-b" #'ediff-copy-all-B-to-C)
 	 (define-key ediff-mode-map "r" #'ediff-restore-diff-in-merge-buffer)
 	 (define-key ediff-mode-map "s" #'ediff-shrink-window-C)
 	 (define-key ediff-mode-map "+" #'ediff-combine-diffs)
@@ -174,6 +176,12 @@ ediff-setup-keymap
 	 (define-key ediff-mode-map "c" nil)
 	 (define-key ediff-mode-map "ca" #'ediff-copy-C-to-A)
 	 (define-key ediff-mode-map "cb" #'ediff-copy-C-to-B)
+         (define-key ediff-mode-map "C-c C-a C-b" #'ediff-copy-all-A-to-B)
+         (define-key ediff-mode-map "C-c C-b C-a" #'ediff-copy-all-B-to-A)
+         (define-key ediff-mode-map "C-c C-a C-c" #'ediff-copy-all-A-to-C)
+         (define-key ediff-mode-map "C-c C-b C-c" #'ediff-copy-all-B-to-C)
+         (define-key ediff-mode-map "C-c C-c C-a" #'ediff-copy-all-C-to-A)
+         (define-key ediff-mode-map "C-c C-c C-b" #'ediff-copy-all-C-to-B)
 	 (define-key ediff-mode-map "ra" #'ediff-restore-diff)
 	 (define-key ediff-mode-map "rb" #'ediff-restore-diff)
 	 (define-key ediff-mode-map "rc" #'ediff-restore-diff)
@@ -181,6 +189,8 @@ ediff-setup-keymap
 	(t ; 2-way comparison
 	 (define-key ediff-mode-map "a"  #'ediff-copy-A-to-B)
 	 (define-key ediff-mode-map "b"  #'ediff-copy-B-to-A)
+         (define-key ediff-mode-map "C-c C-a" #'ediff-copy-all-A-to-B)
+         (define-key ediff-mode-map "C-c C-b" #'ediff-copy-all-B-to-A)
 	 (define-key ediff-mode-map "ra" #'ediff-restore-diff)
 	 (define-key ediff-mode-map "rb" #'ediff-restore-diff))
 	) ; cond
@@ -1952,6 +1962,60 @@ ediff-copy-C-to-A
   (interactive "P")
   (ediff-diff-to-diff arg "ca"))
 
+(defun ediff--copy-all (source dest)
+  "Copy all changes from SOURCE to DEST in Ediff.
+SOURCE and DEST should each be one of the symbols `A', `B', or `C'."
+  (ediff-barf-if-not-control-buffer)
+  (let ((valid-buffers '(A B C)))
+    (unless (and (memq source valid-buffers)
+                 (memq dest valid-buffers))
+      (error "Buffer arguments should be `A', `B', or `C'")))
+  (unless (eq source dest)
+    (let* ((copy-func-name (format "ediff-copy-%s-to-%s"
+                                   (symbol-name source)
+                                   (symbol-name dest)))
+           (copy-func (intern copy-func-name)))
+      (condition-case err
+          (let ((n 0))
+            (while (ediff-valid-difference-p n)
+              (ediff-jump-to-difference (1+ n))
+              (funcall copy-func nil)
+              (setq n (1+ n)))
+            (message "All changes copied from buffer %s to %s"
+                     (symbol-name source)
+                     (symbol-name dest)))
+        (error
+         (message "Error occurred while copying: %s" (error-message-string err)))))))
+
+(defun ediff-copy-all-A-to-B ()
+  "Copy all changes from buffer A to buffer B in Ediff."
+  (interactive)
+  (ediff--copy-all 'A 'B))
+
+(defun ediff-copy-all-B-to-A ()
+  "Copy all changes from buffer B to buffer A in Ediff."
+  (interactive)
+  (ediff--copy-all 'B 'A))
+
+(defun ediff-copy-all-A-to-C ()
+  "Copy all changes from buffer A to buffer C in Ediff."
+  (interactive)
+  (ediff--copy-all 'A 'C))
+
+(defun ediff-copy-all-B-to-C ()
+  "Copy all changes from buffer B to buffer C in Ediff."
+  (interactive)
+  (ediff--copy-all 'B 'C))
+
+(defun ediff-copy-all-C-to-A ()
+  "Copy all changes from buffer C to buffer A in Ediff."
+  (interactive)
+  (ediff--copy-all 'C 'A))
+
+(defun ediff-copy-all-C-to-B ()
+  "Copy all changes from buffer C to buffer B in Ediff."
+  (interactive)
+  (ediff--copy-all 'C 'B))
 
 
 ;; Copy diff N from FROM-BUF-TYPE (given as A, B or C) to TO-BUF-TYPE.
-- 
2.39.3 (Apple Git-145)


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions
  2024-08-29  6:03 bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions Paul Nelson
@ 2024-08-31 10:32 ` Eli Zaretskii
  2024-09-01  6:59   ` Paul Nelson
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-08-31 10:32 UTC (permalink / raw)
  To: Paul Nelson; +Cc: 72866

> From: Paul Nelson <ultrono@gmail.com>
> Date: Thu, 29 Aug 2024 08:03:01 +0200
> 
> This patch binds functions in Ediff that copy all changes from one
> buffer to another, without having to manually go through each
> difference.  Any feedback welcome.

Can you describe situation(s) where these commands will be useful?

I think all we need to install this is a suitable NEWS entry.

Thanks.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions
  2024-08-31 10:32 ` Eli Zaretskii
@ 2024-09-01  6:59   ` Paul Nelson
  2024-09-02 10:32     ` Robert Pluim
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Nelson @ 2024-09-01  6:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72866

[-- Attachment #1: Type: text/plain, Size: 1027 bytes --]

> > This patch binds functions in Ediff that copy all changes from one
> > buffer to another, without having to manually go through each
> > difference.  Any feedback welcome.
>
> Can you describe situation(s) where these commands will be useful?

I use Ediff to merge documents outside of git, like when
working with someone over email or using a computer program to
refactor code.  Sometimes all changes go one way, say from B to A.
The standard workflow then involves pressing "n" to review and "b" to
apply each change.  When the changes turn out to be mundane, this
leads to repetitive "n b" keystrokes.  The proposed patch allows a
more efficient process: rapidly review with "n", then apply all at
once using "C-c C-b".

>
> I think all we need to install this is a suitable NEWS entry.
>
> Thanks.

I've updated the patch with a NEWS entry (formatted to the best of my
ability), together with updates to the Ediff manual and the internal
help system.  Happy to revise further if I missed anything.

Thanks, best,

Paul

[-- Attachment #2: 0001-Add-ediff-copy-all-X-to-Y-functions.patch --]
[-- Type: application/x-patch, Size: 13921 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions
  2024-09-01  6:59   ` Paul Nelson
@ 2024-09-02 10:32     ` Robert Pluim
  2024-09-04  7:30       ` Paul Nelson
  0 siblings, 1 reply; 9+ messages in thread
From: Robert Pluim @ 2024-09-02 10:32 UTC (permalink / raw)
  To: Paul Nelson; +Cc: Eli Zaretskii, 72866

>>>>> On Sun, 1 Sep 2024 08:59:53 +0200, Paul Nelson <ultrono@gmail.com> said:

    >> > This patch binds functions in Ediff that copy all changes from one
    >> > buffer to another, without having to manually go through each
    >> > difference.  Any feedback welcome.
    >> 
    >> Can you describe situation(s) where these commands will be useful?

    Paul> I use Ediff to merge documents outside of git, like when
    Paul> working with someone over email or using a computer program to
    Paul> refactor code.  Sometimes all changes go one way, say from B to A.
    Paul> The standard workflow then involves pressing "n" to review and "b" to
    Paul> apply each change.  When the changes turn out to be mundane, this
    Paul> leads to repetitive "n b" keystrokes.  The proposed patch allows a
    Paul> more efficient process: rapidly review with "n", then apply all at
    Paul> once using "C-c C-b".

The functionality seems useful. I wonder if it makes more sense to
have them triggered by the prefix arg, eg "C-u b", "C-u a b",
etc. rather than having to keep Ctrl pressed.

Robert
-- 





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions
  2024-09-02 10:32     ` Robert Pluim
@ 2024-09-04  7:30       ` Paul Nelson
  2024-09-04 13:01         ` Robert Pluim
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Nelson @ 2024-09-04  7:30 UTC (permalink / raw)
  To: Robert Pluim; +Cc: Eli Zaretskii, 72866

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

Hi Robert,

> The functionality seems useful. I wonder if it makes more sense to
> have them triggered by the prefix arg, eg "C-u b", "C-u a b",
> etc. rather than having to keep Ctrl pressed.
>
> Robert
> --

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

Thanks, best,

Paul

[-- Attachment #2: 0001-Add-Ediff-feature-for-copying-all-differences.patch --]
[-- Type: application/octet-stream, Size: 5871 bytes --]

From 91ade3effdbf19b7d8793020a1c31a4ff791a58d Mon Sep 17 00:00:00 2001
From: Paul Nelson <ultrono@gmail.com>
Date: Wed, 4 Sep 2024 09:24:25 +0200
Subject: [PATCH] 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):
* etc/NEWS: (Lisp Changes in Emacs 31.1): Document the new
feature.
---
 doc/misc/ediff.texi   | 26 ++++++++++++++------------
 etc/NEWS              | 16 ++++++++++++++++
 lisp/vc/ediff-util.el | 29 +++++++++++++++++------------
 3 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/doc/misc/ediff.texi b/doc/misc/ediff.texi
index 749025c870b..6afb38e3fae 100644
--- a/doc/misc/ediff.texi
+++ b/doc/misc/ediff.texi
@@ -489,15 +489,16 @@ Quick Help Commands
 @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
+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
+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 +512,12 @@ Quick Help Commands
 
 @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
+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@.
diff --git a/etc/NEWS b/etc/NEWS
index f10f9ae4d65..a6db0c96288 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -121,6 +121,22 @@ A new ':authorizable t' parameter has been added to 'dbus-call-method'
 and 'dbus-call-method-asynchronously' to allow the user to interactively
 authorize the invoked D-Bus method (e.g., via polkit).
 
++++
+** 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.
+
 \f
 * Changes in Emacs 31.1 on Non-Free Operating Systems
 
diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el
index 597d8a5e643..c2cdf7d4e5e 100644
--- a/lisp/vc/ediff-util.el
+++ b/lisp/vc/ediff-util.el
@@ -1891,7 +1891,7 @@ ediff-diff-at-point
 (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.
+in the arg.  With prefix `C-u', 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,17 +1904,22 @@ ediff-diff-to-diff
   (interactive "P")
   (ediff-barf-if-not-control-buffer)
   (or keys (setq keys (this-command-keys)))
-  (if (eq arg '-) (setq arg -1)) ; translate neg arg to -1
-  (if (numberp arg) (ediff-jump-to-difference arg))
-
-  (let* ((char1 (aref keys 0))
-	 (char2 (aref keys 1))
-	 ediff-verbose-p)
-    (ediff-copy-diff ediff-current-difference
-		     (ediff-char-to-buftype char1)
-		     (ediff-char-to-buftype char2))
-    ;; recenter with rehighlighting, but no messages
-    (ediff-recenter)))
+  (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))
+    (let* ((char1 (aref keys 0))
+	   (char2 (aref keys 1))
+	   ediff-verbose-p)
+      (ediff-copy-diff ediff-current-difference
+		       (ediff-char-to-buftype char1)
+		       (ediff-char-to-buftype char2))
+      ;; recenter with rehighlighting, but no messages
+      (ediff-recenter))))
 
 (defun ediff-copy-A-to-B (arg)
   "Copy ARGth difference region from buffer A to B.
-- 
2.39.3 (Apple Git-145)


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions
  2024-09-04  7:30       ` Paul Nelson
@ 2024-09-04 13:01         ` Robert Pluim
  2024-09-04 13:10           ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Robert Pluim @ 2024-09-04 13:01 UTC (permalink / raw)
  To: Paul Nelson; +Cc: Eli Zaretskii, 72866

>>>>> On Wed, 4 Sep 2024 09:30:58 +0200, Paul Nelson <ultrono@gmail.com> 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 <ultrono@gmail.com>
    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>  \f
    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
'ultrono@gmail.com' in the git logs anywhere.

Robert
-- 





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions
  2024-09-04 13:01         ` Robert Pluim
@ 2024-09-04 13:10           ` Eli Zaretskii
  2024-09-04 13:20             ` Paul Nelson
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-09-04 13:10 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 72866, ultrono

> From: Robert Pluim <rpluim@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>,  72866@debbugs.gnu.org
> Date: Wed, 04 Sep 2024 15:01:23 +0200
> 
> Eli, does this change need a copyright assigment? I donʼt see
> 'ultrono@gmail.com' in the git logs anywhere.

Paul's assignment is on file, so we are okay in that department.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions
  2024-09-04 13:10           ` Eli Zaretskii
@ 2024-09-04 13:20             ` Paul Nelson
  2024-09-11  8:46               ` Robert Pluim
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Nelson @ 2024-09-04 13:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Robert Pluim, 72866

[-- Attachment #1: Type: text/plain, Size: 232 bytes --]

Thanks Robert, I've implemented your suggestions.

I hope someone will check that I've used "+++" correctly in NEWS,
affirming that I updated the documentation -- hopefully I didn't miss
anything.

Any other comments welcome.

Paul

[-- Attachment #2: 0001-Add-Ediff-feature-for-copying-all-differences.patch --]
[-- Type: application/octet-stream, Size: 5965 bytes --]

From 876574da884a1f0de595cce91469b37f8d886b55 Mon Sep 17 00:00:00 2001
From: Paul Nelson <ultrono@gmail.com>
Date: Wed, 4 Sep 2024 09:24:25 +0200
Subject: [PATCH] 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):
* etc/NEWS: (Changes in Specialized Modes and Packages in Emacs
31.1): Document the new feature.
---
 doc/misc/ediff.texi   | 27 +++++++++++++++------------
 etc/NEWS              | 18 ++++++++++++++++++
 lisp/vc/ediff-util.el | 32 +++++++++++++++++++-------------
 3 files changed, 52 insertions(+), 25 deletions(-)

diff --git a/doc/misc/ediff.texi b/doc/misc/ediff.texi
index 749025c870b..7a2dbe5571b 100644
--- a/doc/misc/ediff.texi
+++ b/doc/misc/ediff.texi
@@ -489,15 +489,17 @@ Quick Help Commands
 @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 @@ Quick Help Commands
 
 @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@.
diff --git a/etc/NEWS b/etc/NEWS
index f10f9ae4d65..5bba8e3578f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -106,6 +106,24 @@ This affects calls to 'warn', 'lwarn', 'display-warning', and
 In most cases, having it enabled leads to a large amount of false
 positives.
 
+** 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.
+
 \f
 * New Modes and Packages in Emacs 31.1
 
diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el
index 597d8a5e643..6038f3eae30 100644
--- a/lisp/vc/ediff-util.el
+++ b/lisp/vc/ediff-util.el
@@ -1890,8 +1890,8 @@ ediff-diff-at-point
 
 (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,17 +1904,23 @@ ediff-diff-to-diff
   (interactive "P")
   (ediff-barf-if-not-control-buffer)
   (or keys (setq keys (this-command-keys)))
-  (if (eq arg '-) (setq arg -1)) ; translate neg arg to -1
-  (if (numberp arg) (ediff-jump-to-difference arg))
-
-  (let* ((char1 (aref keys 0))
-	 (char2 (aref keys 1))
-	 ediff-verbose-p)
-    (ediff-copy-diff ediff-current-difference
-		     (ediff-char-to-buftype char1)
-		     (ediff-char-to-buftype char2))
-    ;; recenter with rehighlighting, but no messages
-    (ediff-recenter)))
+  (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))
+
+    (let* ((char1 (aref keys 0))
+	   (char2 (aref keys 1))
+	   ediff-verbose-p)
+      (ediff-copy-diff ediff-current-difference
+		       (ediff-char-to-buftype char1)
+		       (ediff-char-to-buftype char2))
+      ;; recenter with rehighlighting, but no messages
+      (ediff-recenter))))
 
 (defun ediff-copy-A-to-B (arg)
   "Copy ARGth difference region from buffer A to B.
-- 
2.39.3 (Apple Git-145)


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions
  2024-09-04 13:20             ` Paul Nelson
@ 2024-09-11  8:46               ` Robert Pluim
  0 siblings, 0 replies; 9+ messages in thread
From: Robert Pluim @ 2024-09-11  8:46 UTC (permalink / raw)
  To: Paul Nelson; +Cc: Eli Zaretskii, 72866

tags 72866 fixed
close 72866 31.1
quit

>>>>> On Wed, 4 Sep 2024 15:20:46 +0200, Paul Nelson <ultrono@gmail.com> said:

    Paul> Thanks Robert, I've implemented your suggestions.
    Paul> I hope someone will check that I've used "+++" correctly in NEWS,
    Paul> affirming that I updated the documentation -- hopefully I didn't miss
    Paul> anything.

Looks fine to me. I slightly adjusted your commit message and added
the bug number to it.

Closing.
Committed as 833158c0b78

Robert
-- 





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-09-11  8:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29  6:03 bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions Paul Nelson
2024-08-31 10:32 ` Eli Zaretskii
2024-09-01  6:59   ` Paul Nelson
2024-09-02 10:32     ` Robert Pluim
2024-09-04  7:30       ` Paul Nelson
2024-09-04 13:01         ` Robert Pluim
2024-09-04 13:10           ` Eli Zaretskii
2024-09-04 13:20             ` Paul Nelson
2024-09-11  8:46               ` Robert Pluim

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).