]> git.eshelyaron.com Git - emacs.git/commitdiff
Add Ediff feature for copying all differences
authorPaul Nelson <ultrono@gmail.com>
Wed, 4 Sep 2024 07:24:25 +0000 (09:24 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 14 Sep 2024 20:24:19 +0000 (22:24 +0200)
* 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)

(cherry picked from commit 833158c0b78c6dbeacb169076a9899ba7bf45bff)

doc/misc/ediff.texi
etc/NEWS
lisp/vc/ediff-util.el

index ae107323d9c5299d9369cc4b9bf7dadf031d3dd0..5f5074b16b6272e692cb371f5e54a8da9a4da172 100644 (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@.
index 44cbb4e74742afc47924cf5b118c426fd9143a61..6f881651e00b7199c91741052aa70eaa50ed9668 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -252,6 +252,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.
+
 \f
 * New Modes and Packages in Emacs 31.1
 
index 1071705b393cd39745272318a6310a8b38d24e51..5bd0281e94768a323d78dd88b19117f7e1d04daf 100644 (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,17 +1904,23 @@ command keys."
   (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.