From 3d33e7c0483bb9ab8de3ffd6a0372c8d2a0bffa0 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 2 Nov 2019 12:33:25 -0700 Subject: make it possible to suppress prefixing to the branch name Signed-off-by: Sean Whitton --- mailscripts.el | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'mailscripts.el') diff --git a/mailscripts.el b/mailscripts.el index 09d213d..d4d7e95 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -54,43 +54,49 @@ If NO-OPEN, don't open the thread." (notmuch-refresh-this-buffer))) ;;;###autoload -(defun notmuch-extract-thread-patches (repo branch) +(defun notmuch-extract-thread-patches (repo branch &optional no-prefix) "Extract patch series in current thread to branch BRANCH in repo REPO. +A prefix arg suppresses the effects of +`mailscripts-extract-patches-branch-prefix'. + The target branch may or may not already exist. See notmuch-extract-patch(1) manpage for limitations: in particular, this Emacs Lisp function supports passing only entire threads to the notmuch-extract-patch(1) command." - (interactive "Dgit repo: \nsnew branch name: ") + (interactive "Dgit repo: \nsnew branch name: \nP") (let ((thread-id notmuch-show-thread-id) (default-directory (expand-file-name repo))) - (mailscripts--check-out-branch branch) + (mailscripts--check-out-branch branch no-prefix) (shell-command (format "notmuch-extract-patch %s | git am" (shell-quote-argument thread-id)) "*notmuch-apply-thread-series*"))) ;;;###autoload -(defun notmuch-extract-thread-patches-projectile () +(defun notmuch-extract-thread-patches-projectile (&optional no-prefix) "Like `notmuch-extract-thread-patches', but use projectile to choose the repo." - (interactive) + (interactive "P") (mailscripts--projectile-repo-and-branch 'notmuch-extract-thread-patches)) ;;;###autoload -(defun notmuch-extract-message-patches (repo branch) +(defun notmuch-extract-message-patches (repo branch &optional no-prefix) "Extract patches attached to current message to branch BRANCH in repo REPO. +A prefix arg suppresses the effects of +`mailscripts-extract-patches-branch-prefix'. + The target branch may or may not already exist. Patches are applied using git-am(1), so we only consider attachments with filenames which look like they were generated by git-format-patch(1)." - (interactive "Dgit repo: \nsnew branch name: ") + (interactive "Dgit repo: \nsnew branch name: \nP") (with-current-notmuch-show-message (let ((default-directory (expand-file-name repo)) (mm-handle (mm-dissect-buffer))) - (mailscripts--check-out-branch branch) + (mailscripts--check-out-branch branch no-prefix) (notmuch-foreach-mime-part (lambda (p) (let* ((disposition (mm-handle-disposition p)) @@ -101,16 +107,16 @@ git-format-patch(1)." mm-handle)))) ;;;###autoload -(defun notmuch-extract-message-patches-projectile () +(defun notmuch-extract-message-patches-projectile (&optional no-prefix) "Like `notmuch-extract-message-patches', but use projectile to choose the repo." - (interactive) + (interactive "P") (mailscripts--projectile-repo-and-branch 'notmuch-extract-message-patches)) -(defun mailscripts--check-out-branch (branch) +(defun mailscripts--check-out-branch (branch no-prefix) (call-process-shell-command (format "git checkout -b %s" (shell-quote-argument - (if mailscripts-extract-patches-branch-prefix + (if (and (not no-prefix) mailscripts-extract-patches-branch-prefix) (concat mailscripts-extract-patches-branch-prefix branch) branch))))) -- cgit v1.2.3