diff options
Diffstat (limited to 'lisp/vc/vc.el')
-rw-r--r-- | lisp/vc/vc.el | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index fd59c95fc8b..adf57229986 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 |