aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-08-27 23:19:18 -0400
committerKyle Meyer <kyle@kyleam.com>2020-08-28 23:05:56 -0400
commit486b554144843b8e30d69ca9ea9f0b11aadfff20 (patch)
treeb821e1e1bdfbdbb6c15ff0a4b0341eeaed8eff2d
parentd200092f77fa8613db0bf58a5670fe91353e8b96 (diff)
downloadpiem-486b554144843b8e30d69ca9ea9f0b11aadfff20.tar.gz
Add accessor for piem-inboxes
There's no need to have a function like piem-inbox-url for every key. Drop piem-inbox-url, but keep piem-inbox-coderepo around because it does a bit of extra processing on top. Message-Id: <20200828031920.7515-3-kyle@kyleam.com>
-rw-r--r--piem-b4.el2
-rw-r--r--piem.el15
2 files changed, 8 insertions, 9 deletions
diff --git a/piem-b4.el b/piem-b4.el
index 6de0d2b..f5aa777 100644
--- a/piem-b4.el
+++ b/piem-b4.el
@@ -63,7 +63,7 @@
;; try to download it from a URL at `piem-inboxes'. Finally, fall
;; back to b4's configuration.
(unless local-mbox-p
- (when-let ((url (piem-inbox-url))
+ (when-let ((url (piem-inbox-get :url))
(mid (piem-mid))
(buffer (condition-case nil
(piem-download-and-decompress
diff --git a/piem.el b/piem.el
index f59f723..6102b0f 100644
--- a/piem.el
+++ b/piem.el
@@ -298,10 +298,14 @@ intended to be used by libraries implementing a function for
"Return the current buffer's inbox."
(run-hook-with-args-until-success 'piem-get-inbox-functions))
+(defun piem-inbox-get (key)
+ "Get info KEY for the inbox entry in `piem-inboxes'."
+ (when-let ((p (piem-inbox)))
+ (plist-get (cdr (assoc p piem-inboxes)) key)))
+
(defun piem-inbox-coderepo ()
"Return the code repository of current buffer's inbox."
- (when-let ((p (piem-inbox))
- (repo (plist-get (cdr (assoc p piem-inboxes)) :coderepo)))
+ (when-let ((repo (piem-inbox-get :coderepo)))
(expand-file-name repo)))
(defun piem-inbox-by-url-match (url)
@@ -315,11 +319,6 @@ intended to be used by libraries implementing a function for
(when (string-match-p (regexp-quote p-url) url)
(throw 'hit (car inbox)))))))
-(defun piem-inbox-url ()
- "Return the URL of current buffer's inbox."
- (when-let ((p (piem-inbox)))
- (plist-get (cdr (assoc p piem-inboxes)) :url)))
-
(defun piem-inbox-coderepo-maybe-read ()
"Like `piem-inbox-coderepo', but fall back to reading the repo."
(let ((inbox
@@ -495,7 +494,7 @@ This function depends on :url being configured for entries in
"`piem-maildir-directory' does not look like a Maildir directory"))
((not (or message-only (piem-check-gunzip)))
(user-error "gunzip executable not found")))
- (when-let ((url (concat (or (piem-inbox-url)
+ (when-let ((url (concat (or (piem-inbox-get :url)
(user-error
"Could not find inbox URL for current buffer"))
mid