[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master d0ea38b5fe 27/42: Have 'vc-prepare-patch' handle prefix arguments
From: |
Philip Kaludercic |
Subject: |
master d0ea38b5fe 27/42: Have 'vc-prepare-patch' handle prefix arguments. |
Date: |
Thu, 17 Nov 2022 14:56:23 -0500 (EST) |
branch: master
commit d0ea38b5fe0b34cd3833d451cc56dbaadc06d51d
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
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 | 18 ++++++++--------
lisp/vc/vc.el | 48 +++++++++++++++++++++++++++++--------------
2 files changed, 42 insertions(+), 24 deletions(-)
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index acef568e54..9d8d3ee5f4 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -750,20 +750,20 @@ prompt for the name of the package to rebuild."
(package-vc--unpack-1 pkg-desc (package-desc-dir pkg-desc)))
;;;###autoload
-(defun package-vc-prepare-patch (pkg subject revisions)
+(defun package-vc-prepare-patch (pkg-desc 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'."
+The function uses `vc-prepare-patch', passing SUBJECT and
+REVISIONS directly. PKG-DESC must be a package description.
+Interactively, prompt for PKG-DESC, SUBJECT, and REVISIONS. When
+invoked with a numerical prefix argument, use the last N
+revisions. When invoked interactively in a Log View buffer with
+marked revisions, use those."
(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 (package-maintainers pkg t)
+ (vc-prepare-patch-prompt-revisions)))
+ (vc-prepare-patch (package-maintainers pkg-desc t)
subject revisions))
(provide 'package-vc)
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index fd59c95fc8..adf5722998 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -3384,25 +3384,43 @@ If nil, no default will be used. This option may be
set locally."
(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.
-If `vc-prepare-patches-separately' is nil, SUBJECT will be used
-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."
+If `vc-prepare-patches-separately' is nil, use SUBJECT as the
+default subject for the message, or prompt a subject when invoked
+interactively. Otherwise compose a separate message for each
+revision, with SUBJECT derived from each revision subject.
+When invoked with a numerical prefix argument, use the last N
+revisions.
+When invoked interactively in a Log View buffer with
+marked revisions, use those these."
(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
- master a467afbd98 25/42: Mention package name when package is lacking VC data, (continued)
- master a467afbd98 25/42: Mention package name when package is lacking VC data, Philip Kaludercic, 2022/11/17
- master 7ab556b576 29/42: Improve robustness of 'package-vc-update', Philip Kaludercic, 2022/11/17
- master 3326337776 30/42: Avoid destructive manipulation of 'package-vc--archive-spec-alist', Philip Kaludercic, 2022/11/17
- master 32f51f17c4 33/42: Remove temporary .texi files if used to build documentation, Philip Kaludercic, 2022/11/17
- master 228c247e6f 34/42: Remove duplicate package descriptions after updating, Philip Kaludercic, 2022/11/17
- master 4bd7ae833f 36/42: Allow the direct installation of package specifications, Philip Kaludercic, 2022/11/17
- master 53c90abfa8 37/42: ; * lisp/emacs-lisp/package-vc.el: Update TODO, Philip Kaludercic, 2022/11/17
- master aadf07f5b8 05/42: Autoload 'package-vc-install-selected-packages', Philip Kaludercic, 2022/11/17
- master 9f4a433b27 12/42: Fix generation of documentation for source packages, Philip Kaludercic, 2022/11/17
- master aa56e50fe2 23/42: Raise 'wrong-type-argument' when installing package nil, Philip Kaludercic, 2022/11/17
- master d0ea38b5fe 27/42: Have 'vc-prepare-patch' handle prefix arguments.,
Philip Kaludercic <=
- master 2ed115fc3c 21/42: Fix indefinite loading of asynchronous downloads, Philip Kaludercic, 2022/11/17
- master a6cd44734d 18/42: Remove unused variable in 'package-vc--unpack', Philip Kaludercic, 2022/11/17
- master fd4da9151f 28/42: * lisp/vc/vc.el (vc-default-last-change): Use 'vc-call', Philip Kaludercic, 2022/11/17
- master c8e5069e6d 24/42: Add new command 'package-vc-update-all', Philip Kaludercic, 2022/11/17
- master 345bfd376e 31/42: Add missing elpa-package.eld to package test resources, Philip Kaludercic, 2022/11/17
- master 4aee4cde3a 26/42: Explain that 'package-vc-install' doesn't remove tarball packages, Philip Kaludercic, 2022/11/17
- master 11cb810356 32/42: Fix the behaviour of 'byte-compile-ignore-files', Philip Kaludercic, 2022/11/17
- master 874d8a418f 35/42: Only fetch elpa-packages.eld when necessary, Philip Kaludercic, 2022/11/17
- master 5b8f165f75 38/42: Fix issues related to 'package-vc-install-from-checkout', Philip Kaludercic, 2022/11/17
- master fb6d62f881 41/42: ; Clarify what a package specification is, Philip Kaludercic, 2022/11/17