From: Paul Nelson <ultrono@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Robert Pluim <rpluim@gmail.com>, 72866@debbugs.gnu.org
Subject: bug#72866: [PATCH] Add ediff-copy-all-X-to-Y functions
Date: Wed, 4 Sep 2024 15:20:46 +0200 [thread overview]
Message-ID: <CAOA-32OpTk32tVJ_jaLRq6d9131=BYsbWOAHurP82SZM4P8S0A@mail.gmail.com> (raw)
In-Reply-To: <86h6av5zu1.fsf@gnu.org>
[-- 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)
next prev parent reply other threads:[~2024-09-04 13:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-09-11 8:46 ` Robert Pluim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOA-32OpTk32tVJ_jaLRq6d9131=BYsbWOAHurP82SZM4P8S0A@mail.gmail.com' \
--to=ultrono@gmail.com \
--cc=72866@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=rpluim@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).