From: Philip Kaludercic <philipk@posteo.net>
To: Sean Whitton <spwhitton@spwhitton.name>
Cc: 58383@debbugs.gnu.org
Subject: bug#58383: 29.0.50; Make it easier to invert vc-prepare-patches-separately
Date: Sun, 13 Nov 2022 16:06:58 +0000 [thread overview]
Message-ID: <87mt8uvnx9.fsf@posteo.net> (raw)
In-Reply-To: <87a64vvtyh.fsf@posteo.net> (Philip Kaludercic's message of "Sun, 13 Nov 2022 14:56:38 +0100")
[-- Attachment #1: Type: text/plain, Size: 118 bytes --]
Philip Kaludercic <philipk@posteo.net> writes:
> How does the following look like:
I have prepared a proper patch:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Have-vc-prepare-patch-handle-prefix-arguments.patch --]
[-- Type: text/x-diff, Size: 4768 bytes --]
From 724b85acd34e4e5dd6e8cb521eb03eda08ff105a Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Sun, 13 Nov 2022 17:05:20 +0100
Subject: [PATCH] Have 'vc-prepare-patch' handle prefix arguments.
* lisp/emacs-lisp/package-vc.el (package-vc-prepare-patch): Use
'vc-prepare-patch-prompt-revisions'.
* lisp/vc/vc.el (vc-prepare-patch-prompt-revisions): Extract common
function and handle prefix arguments.
(vc-prepare-patch): Pull logic out to
'vc-prepare-patch-prompt-revisions'.
---
lisp/emacs-lisp/package-vc.el | 14 ++++++------
lisp/vc/vc.el | 40 +++++++++++++++++++++++++----------
2 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index 664629d156..37ef35edad 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -733,17 +733,17 @@ package-vc-rebuild
;;;###autoload
(defun package-vc-prepare-patch (pkg subject revisions)
"Send patch for REVISIONS to maintainer of the package PKG using SUBJECT.
-SUBJECT and REVISIONS are passed on to `vc-prepare-patch', which see.
-PKG must be a package description.
-Interactively, prompt for PKG, SUBJECT, and REVISIONS. However,
-if the current buffer has marked commit log entries, REVISIONS
-are the tags of the marked entries, see `log-view-get-marked'."
+SUBJECT and REVISIONS are passed on to `vc-prepare-patch', which
+see. PKG must be a package description. Interactively, prompt
+for PKG, SUBJECT, and REVISIONS. When invoked with a numerical
+prefix argument, the last N revisions will be used. When invoked
+interactively in a Log View buffer with marked revisions, those
+revisions will be used."
(interactive
(list (package-vc--read-package-desc "Package to prepare a patch for: " t)
(and (not vc-prepare-patches-separately)
(read-string "Subject: " "[PATCH] " nil nil t))
- (or (log-view-get-marked)
- (vc-read-multiple-revisions "Revisions: "))))
+ (vc-prepare-patch-prompt-revisions)))
(vc-prepare-patch (package-maintainers pkg t)
subject revisions))
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 513fbb23fe..f49f5d3307 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -3384,6 +3384,30 @@ vc-default-prepare-patch
(vc-root-dir))))
:buffer (current-buffer)))))
+(defun vc-prepare-patch-prompt-revisions ()
+ "Prompt the user for a list revisions.
+Prepare a default value, depending on the current context. With
+a numerical prefix argument, use the last N revisions as the
+default value. If the current buffer is a log-view buffer, use
+the marked commits. Otherwise fall back to the working revision
+of the current file."
+ (vc-read-multiple-revisions
+ "Revisions: " nil nil nil
+ (or (and-let* ((arg current-prefix-arg)
+ (fs (vc-deduce-fileset t)))
+ (cl-loop with file = (caadr fs)
+ repeat (prefix-numeric-value arg)
+ for rev = (vc-working-revision file)
+ then (vc-call-backend
+ (car fs) 'previous-revision
+ file rev)
+ when rev collect it into revs
+ finally return (mapconcat #'identity revs ",")))
+ (and-let* ((revs (log-view-get-marked)))
+ (mapconcat #'identity revs ","))
+ (and-let* ((file (buffer-file-name)))
+ (vc-working-revision file)))))
+
;;;###autoload
(defun vc-prepare-patch (addressee subject revisions)
"Compose an Email sending patches for REVISIONS to ADDRESSEE.
@@ -3391,18 +3415,12 @@ vc-prepare-patch
as the default subject for the message (and it will be prompted
for when called interactively). Otherwise a separate message
will be composed for each revision, with SUBJECT derived from the
-invidividual commits.
-
-When invoked interactively in a Log View buffer with marked
-revisions, those revisions will be used."
+invidividual commits. When invoked with a numerical prefix
+argument, the last N revisions will be used. When invoked
+interactively in a Log View buffer with marked revisions, those
+revisions will be used."
(interactive
- (let ((revs (vc-read-multiple-revisions
- "Revisions: " nil nil nil
- (or (and-let* ((revs (log-view-get-marked)))
- (mapconcat #'identity revs ","))
- (and-let* ((file (buffer-file-name)))
- (vc-working-revision file)))))
- to)
+ (let ((revs (vc-prepare-patch-prompt-revisions)) to)
(require 'message)
(while (null (setq to (completing-read-multiple
(format-prompt
--
2.35.1
next prev parent reply other threads:[~2022-11-13 16:06 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-08 17:49 bug#58383: 29.0.50; Make it easier to invert vc-prepare-patches-separately Sean Whitton
2022-10-09 12:54 ` Philip Kaludercic
2022-11-04 22:21 ` Philip Kaludercic
2022-11-06 21:44 ` Sean Whitton
2022-11-06 21:49 ` Philip Kaludercic
2022-11-07 23:06 ` Sean Whitton
2022-11-08 20:31 ` Philip Kaludercic
2022-11-08 21:00 ` Sean Whitton
2022-11-09 8:28 ` Philip Kaludercic
2022-11-09 16:36 ` Sean Whitton
2022-11-09 17:46 ` Philip Kaludercic
2022-11-09 20:56 ` Sean Whitton
2022-11-10 20:14 ` Philip Kaludercic
2022-11-11 0:07 ` Sean Whitton
2022-11-11 6:32 ` Philip Kaludercic
2022-11-11 20:53 ` Sean Whitton
2022-11-13 13:56 ` Philip Kaludercic
2022-11-13 16:06 ` Philip Kaludercic [this message]
2022-11-13 16:35 ` Eli Zaretskii
2022-11-13 16:45 ` Philip Kaludercic
2022-11-13 16:52 ` Eli Zaretskii
2022-11-13 18:17 ` Philip Kaludercic
2022-11-14 12:41 ` Eli Zaretskii
2022-11-16 0:04 ` Sean Whitton
2022-11-16 7:50 ` Philip Kaludercic
2022-11-11 7:34 ` Eli Zaretskii
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=87mt8uvnx9.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=58383@debbugs.gnu.org \
--cc=spwhitton@spwhitton.name \
/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).