diff options
| author | Philip Kaludercic | 2022-11-13 17:05:20 +0100 |
|---|---|---|
| committer | Philip Kaludercic | 2022-11-17 20:55:04 +0100 |
| commit | d0ea38b5fe0b34cd3833d451cc56dbaadc06d51d (patch) | |
| tree | 8ac0463a4c785e5ef578fdf883c63aa6d30b1f18 | |
| parent | 4aee4cde3aa3d9cdf4184af7c06f9ea7464c8824 (diff) | |
| download | emacs-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'.
| -rw-r--r-- | lisp/emacs-lisp/package-vc.el | 18 | ||||
| -rw-r--r-- | 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 acef568e549..9d8d3ee5f42 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." | |||
| 750 | (package-vc--unpack-1 pkg-desc (package-desc-dir pkg-desc))) | 750 | (package-vc--unpack-1 pkg-desc (package-desc-dir pkg-desc))) |
| 751 | 751 | ||
| 752 | ;;;###autoload | 752 | ;;;###autoload |
| 753 | (defun package-vc-prepare-patch (pkg subject revisions) | 753 | (defun package-vc-prepare-patch (pkg-desc subject revisions) |
| 754 | "Send patch for REVISIONS to maintainer of the package PKG using SUBJECT. | 754 | "Send patch for REVISIONS to maintainer of the package PKG using SUBJECT. |
| 755 | SUBJECT and REVISIONS are passed on to `vc-prepare-patch', which see. | 755 | The function uses `vc-prepare-patch', passing SUBJECT and |
| 756 | PKG must be a package description. | 756 | REVISIONS directly. PKG-DESC must be a package description. |
| 757 | Interactively, prompt for PKG, SUBJECT, and REVISIONS. However, | 757 | Interactively, prompt for PKG-DESC, SUBJECT, and REVISIONS. When |
| 758 | if the current buffer has marked commit log entries, REVISIONS | 758 | invoked with a numerical prefix argument, use the last N |
| 759 | are the tags of the marked entries, see `log-view-get-marked'." | 759 | revisions. When invoked interactively in a Log View buffer with |
| 760 | marked revisions, use those." | ||
| 760 | (interactive | 761 | (interactive |
| 761 | (list (package-vc--read-package-desc "Package to prepare a patch for: " t) | 762 | (list (package-vc--read-package-desc "Package to prepare a patch for: " t) |
| 762 | (and (not vc-prepare-patches-separately) | 763 | (and (not vc-prepare-patches-separately) |
| 763 | (read-string "Subject: " "[PATCH] " nil nil t)) | 764 | (read-string "Subject: " "[PATCH] " nil nil t)) |
| 764 | (or (log-view-get-marked) | 765 | (vc-prepare-patch-prompt-revisions))) |
| 765 | (vc-read-multiple-revisions "Revisions: ")))) | 766 | (vc-prepare-patch (package-maintainers pkg-desc t) |
| 766 | (vc-prepare-patch (package-maintainers pkg t) | ||
| 767 | subject revisions)) | 767 | subject revisions)) |
| 768 | 768 | ||
| 769 | (provide 'package-vc) | 769 | (provide 'package-vc) |
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. | ||
| 3389 | Prepare a default value, depending on the current context. With | ||
| 3390 | a numerical prefix argument, use the last N revisions as the | ||
| 3391 | default value. If the current buffer is a log-view buffer, use | ||
| 3392 | the marked commits. Otherwise fall back to the working revision | ||
| 3393 | of 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. |
| 3390 | If `vc-prepare-patches-separately' is nil, SUBJECT will be used | 3414 | If `vc-prepare-patches-separately' is nil, use SUBJECT as the |
| 3391 | as the default subject for the message (and it will be prompted | 3415 | default subject for the message, or prompt a subject when invoked |
| 3392 | for when called interactively). Otherwise a separate message | 3416 | interactively. Otherwise compose a separate message for each |
| 3393 | will be composed for each revision, with SUBJECT derived from the | 3417 | revision, with SUBJECT derived from each revision subject. |
| 3394 | invidividual commits. | 3418 | When invoked with a numerical prefix argument, use the last N |
| 3395 | 3419 | revisions. | |
| 3396 | When invoked interactively in a Log View buffer with marked | 3420 | When invoked interactively in a Log View buffer with |
| 3397 | revisions, those revisions will be used." | 3421 | marked 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 |