aboutsummaryrefslogtreecommitdiff
path: root/piem-b4.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-11-15 01:15:17 -0500
committerKyle Meyer <kyle@kyleam.com>2020-11-15 17:12:25 -0500
commit688c8783810c4c2da44d9fe41ace36021391f289 (patch)
tree1c37985ae5805fcc9553efc89337d5c6aa577637 /piem-b4.el
parent251f9a264b3d0b5a4f4a976bf18b505c769b7e04 (diff)
downloadpiem-688c8783810c4c2da44d9fe41ace36021391f289.tar.gz
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>
Diffstat (limited to 'piem-b4.el')
-rw-r--r--piem-b4.el15
1 files changed, 11 insertions, 4 deletions
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)))))