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'.
This commit is contained in:
parent
4aee4cde3a
commit
d0ea38b5fe
2 changed files with 42 additions and 24 deletions
|
@ -750,20 +750,20 @@ prompt for the name of the package to rebuild."
|
||||||
(package-vc--unpack-1 pkg-desc (package-desc-dir pkg-desc)))
|
(package-vc--unpack-1 pkg-desc (package-desc-dir pkg-desc)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###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.
|
"Send patch for REVISIONS to maintainer of the package PKG using SUBJECT.
|
||||||
SUBJECT and REVISIONS are passed on to `vc-prepare-patch', which see.
|
The function uses `vc-prepare-patch', passing SUBJECT and
|
||||||
PKG must be a package description.
|
REVISIONS directly. PKG-DESC must be a package description.
|
||||||
Interactively, prompt for PKG, SUBJECT, and REVISIONS. However,
|
Interactively, prompt for PKG-DESC, SUBJECT, and REVISIONS. When
|
||||||
if the current buffer has marked commit log entries, REVISIONS
|
invoked with a numerical prefix argument, use the last N
|
||||||
are the tags of the marked entries, see `log-view-get-marked'."
|
revisions. When invoked interactively in a Log View buffer with
|
||||||
|
marked revisions, use those."
|
||||||
(interactive
|
(interactive
|
||||||
(list (package-vc--read-package-desc "Package to prepare a patch for: " t)
|
(list (package-vc--read-package-desc "Package to prepare a patch for: " t)
|
||||||
(and (not vc-prepare-patches-separately)
|
(and (not vc-prepare-patches-separately)
|
||||||
(read-string "Subject: " "[PATCH] " nil nil t))
|
(read-string "Subject: " "[PATCH] " nil nil t))
|
||||||
(or (log-view-get-marked)
|
(vc-prepare-patch-prompt-revisions)))
|
||||||
(vc-read-multiple-revisions "Revisions: "))))
|
(vc-prepare-patch (package-maintainers pkg-desc t)
|
||||||
(vc-prepare-patch (package-maintainers pkg t)
|
|
||||||
subject revisions))
|
subject revisions))
|
||||||
|
|
||||||
(provide 'package-vc)
|
(provide 'package-vc)
|
||||||
|
|
|
@ -3384,25 +3384,43 @@ If nil, no default will be used. This option may be set locally."
|
||||||
(vc-root-dir))))
|
(vc-root-dir))))
|
||||||
:buffer (current-buffer)))))
|
: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
|
;;;###autoload
|
||||||
(defun vc-prepare-patch (addressee subject revisions)
|
(defun vc-prepare-patch (addressee subject revisions)
|
||||||
"Compose an Email sending patches for REVISIONS to ADDRESSEE.
|
"Compose an Email sending patches for REVISIONS to ADDRESSEE.
|
||||||
If `vc-prepare-patches-separately' is nil, SUBJECT will be used
|
If `vc-prepare-patches-separately' is nil, use SUBJECT as the
|
||||||
as the default subject for the message (and it will be prompted
|
default subject for the message, or prompt a subject when invoked
|
||||||
for when called interactively). Otherwise a separate message
|
interactively. Otherwise compose a separate message for each
|
||||||
will be composed for each revision, with SUBJECT derived from the
|
revision, with SUBJECT derived from each revision subject.
|
||||||
invidividual commits.
|
When invoked with a numerical prefix argument, use the last N
|
||||||
|
revisions.
|
||||||
When invoked interactively in a Log View buffer with marked
|
When invoked interactively in a Log View buffer with
|
||||||
revisions, those revisions will be used."
|
marked revisions, use those these."
|
||||||
(interactive
|
(interactive
|
||||||
(let ((revs (vc-read-multiple-revisions
|
(let ((revs (vc-prepare-patch-prompt-revisions)) to)
|
||||||
"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)
|
|
||||||
(require 'message)
|
(require 'message)
|
||||||
(while (null (setq to (completing-read-multiple
|
(while (null (setq to (completing-read-multiple
|
||||||
(format-prompt
|
(format-prompt
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue