[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 833158c0b78: Add Ediff feature for copying all differences
From: |
Robert Pluim |
Subject: |
master 833158c0b78: Add Ediff feature for copying all differences |
Date: |
Wed, 11 Sep 2024 04:46:10 -0400 (EDT) |
branch: master
commit 833158c0b78c6dbeacb169076a9899ba7bf45bff
Author: Paul Nelson <ultrono@gmail.com>
Commit: Robert Pluim <rpluim@gmail.com>
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)
---
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 ae107323d9c..5f5074b16b6 100644
--- a/doc/misc/ediff.texi
+++ b/doc/misc/ediff.texi
@@ -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@.
diff --git a/etc/NEWS b/etc/NEWS
index 8589931684f..1bdbe368846 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
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 @@ 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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 833158c0b78: Add Ediff feature for copying all differences,
Robert Pluim <=