aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/vc
diff options
context:
space:
mode:
authorPhilip Kaludercic2022-11-13 17:05:20 +0100
committerPhilip Kaludercic2022-11-17 20:55:04 +0100
commitd0ea38b5fe0b34cd3833d451cc56dbaadc06d51d (patch)
tree8ac0463a4c785e5ef578fdf883c63aa6d30b1f18 /lisp/vc
parent4aee4cde3aa3d9cdf4184af7c06f9ea7464c8824 (diff)
downloademacs-d0ea38b5fe0b34cd3833d451cc56dbaadc06d51d.tar.gz
emacs-d0ea38b5fe0b34cd3833d451cc56dbaadc06d51d.zip
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'.
Diffstat (limited to 'lisp/vc')
-rw-r--r--lisp/vc/vc.el48
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."
3384 (vc-root-dir)))) 3384 (vc-root-dir))))
3385 :buffer (current-buffer))))) 3385 :buffer (current-buffer)))))
3386 3386
3387(defun vc-prepare-patch-prompt-revisions ()
3388 "Prompt the user for a list revisions.
3389Prepare a default value, depending on the current context. With
3390a numerical prefix argument, use the last N revisions as the
3391default value. If the current buffer is a log-view buffer, use
3392the marked commits. Otherwise fall back to the working revision
3393of the current file."
3394 (vc-read-multiple-revisions
3395 "Revisions: " nil nil nil
3396 (or (and-let* ((arg current-prefix-arg)
3397 (fs (vc-deduce-fileset t)))
3398 (cl-loop with file = (caadr fs)
3399 repeat (prefix-numeric-value arg)
3400 for rev = (vc-working-revision file)
3401 then (vc-call-backend
3402 (car fs) 'previous-revision
3403 file rev)
3404 when rev collect it into revs
3405 finally return (mapconcat #'identity revs ",")))
3406 (and-let* ((revs (log-view-get-marked)))
3407 (mapconcat #'identity revs ","))
3408 (and-let* ((file (buffer-file-name)))
3409 (vc-working-revision file)))))
3410
3387;;;###autoload 3411;;;###autoload
3388(defun vc-prepare-patch (addressee subject revisions) 3412(defun vc-prepare-patch (addressee subject revisions)
3389 "Compose an Email sending patches for REVISIONS to ADDRESSEE. 3413 "Compose an Email sending patches for REVISIONS to ADDRESSEE.
3390If `vc-prepare-patches-separately' is nil, SUBJECT will be used 3414If `vc-prepare-patches-separately' is nil, use SUBJECT as the
3391as the default subject for the message (and it will be prompted 3415default subject for the message, or prompt a subject when invoked
3392for when called interactively). Otherwise a separate message 3416interactively. Otherwise compose a separate message for each
3393will be composed for each revision, with SUBJECT derived from the 3417revision, with SUBJECT derived from each revision subject.
3394invidividual commits. 3418When invoked with a numerical prefix argument, use the last N
3395 3419revisions.
3396When invoked interactively in a Log View buffer with marked 3420When invoked interactively in a Log View buffer with
3397revisions, those revisions will be used." 3421marked revisions, use those these."
3398 (interactive 3422 (interactive
3399 (let ((revs (vc-read-multiple-revisions 3423 (let ((revs (vc-prepare-patch-prompt-revisions)) to)
3400 "Revisions: " nil nil nil
3401 (or (and-let* ((revs (log-view-get-marked)))
3402 (mapconcat #'identity revs ","))
3403 (and-let* ((file (buffer-file-name)))
3404 (vc-working-revision file)))))
3405 to)
3406 (require 'message) 3424 (require 'message)
3407 (while (null (setq to (completing-read-multiple 3425 (while (null (setq to (completing-read-multiple
3408 (format-prompt 3426 (format-prompt