From 688c8783810c4c2da44d9fe41ace36021391f289 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 15 Nov 2020 01:15:17 -0500 Subject: am: Allow flipping worktree creation with prefix argument I tend to use a few dedicated worktrees for projects and am not interested in creating a worktree for each patch series I apply. However, I can imagine wanting to create one every now and then. Make it possible by adding a prefix argument to piem-am and piem-b4-am-from-mid that flips the meaning of piem-am-create-worktree. Message-Id: <20201115061518.22191-6-kyle@kyleam.com> --- piem-b4.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'piem-b4.el') diff --git a/piem-b4.el b/piem-b4.el index 27ecf19..172236f 100644 --- a/piem-b4.el +++ b/piem-b4.el @@ -130,15 +130,21 @@ list of arguments specified via ARGS." (append args (list mid)))) ;;;###autoload -(defun piem-b4-am-from-mid (mid &optional args) +(defun piem-b4-am-from-mid (mid &optional args toggle-worktree) "Get the thread for MID, extract an am-ready mbox, and apply it. + Try to get a thread for the Message-Id MID with `piem-mid-to-thread-functions', falling back to letting b4 download it. After calling `b4 am' with ARGS to prepare an -am-ready mbox, feed the result to `git am'." +am-ready mbox, feed the result to `git am'. + +When prefix argument TOGGLE-WORKTREE is non-nil, invert the +meaning of `piem-am-create-worktree'. With the default value, +this triggers the creation of a new worktree." (interactive (list (or (piem-mid) (read-string "Message ID: ")) - (transient-args 'piem-b4-am))) + (transient-args 'piem-b4-am) + current-prefix-arg)) (when-let ((badopt (cl-some (lambda (arg) (and (string-match @@ -158,7 +164,8 @@ am-ready mbox, feed the result to `git am'." (with-temp-buffer (insert-file-contents (or cover mbox-file)) (piem-extract-mbox-info)) - coderepo) + coderepo + toggle-worktree) (when clean-fn (funcall clean-fn))))) -- cgit v1.2.3