aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-06-05 21:31:25 -0400
committerKyle Meyer <kyle@kyleam.com>2020-06-06 15:10:51 -0400
commit91a1010c215306b81c6c1e92dfc59872b505d020 (patch)
tree6ec081531cf40b038f2cd9349c23838b5bd418d2
parentc034eed1b7729556a131705ff323030d227d8370 (diff)
downloadpiem-91a1010c215306b81c6c1e92dfc59872b505d020.tar.gz
Add piem-inbox-coderepo-maybe-read function
This logic will be used in another spot.
-rw-r--r--piem-b4.el10
-rw-r--r--piem.el12
2 files changed, 13 insertions, 9 deletions
diff --git a/piem-b4.el b/piem-b4.el
index 487b548..60f1368 100644
--- a/piem-b4.el
+++ b/piem-b4.el
@@ -110,15 +110,7 @@
(match-string 1 arg)))
args)))
(user-error "%s is incompatible with this command" badopt))
- (pcase-let* ((coderepo (or (piem-inbox-coderepo)
- (and (fboundp 'projectile-relevant-known-projects)
- (completing-read
- "Project: "
- (projectile-relevant-known-projects)))
- (and piem-use-magit
- (fboundp 'magit-read-repository)
- (magit-read-repository))
- (read-directory-name "Git repository: ")))
+ (pcase-let* ((coderepo (piem-inbox-coderepo-maybe-read))
(`(,cover ,mbox-file)
(piem-b4--get-am-files mid coderepo args))
(default-directory coderepo))
diff --git a/piem.el b/piem.el
index 7932347..800fb2c 100644
--- a/piem.el
+++ b/piem.el
@@ -236,6 +236,18 @@ the following information about the patch series:
(repo (plist-get (cdr (assoc p piem-inboxes)) :coderepo)))
(expand-file-name repo)))
+(defun piem-inbox-coderepo-maybe-read ()
+ "Like `piem-inbox-coderepo', but fall back to reading the repo."
+ (or (piem-inbox-coderepo)
+ (and (fboundp 'projectile-relevant-known-projects)
+ (completing-read
+ "Project: "
+ (projectile-relevant-known-projects)))
+ (and piem-use-magit
+ (fboundp 'magit-read-repository)
+ (magit-read-repository))
+ (read-directory-name "Git repository: ")))
+
(defun piem-mid ()
"Return the current buffer's message ID."
(run-hook-with-args-until-success 'piem-get-mid-functions))