diff options
author | Kyle Meyer <kyle@kyleam.com> | 2020-08-27 23:19:18 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2020-08-28 23:05:56 -0400 |
commit | 486b554144843b8e30d69ca9ea9f0b11aadfff20 (patch) | |
tree | b821e1e1bdfbdbb6c15ff0a4b0341eeaed8eff2d | |
parent | d200092f77fa8613db0bf58a5670fe91353e8b96 (diff) | |
download | piem-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.el | 2 | ||||
-rw-r--r-- | piem.el | 15 |
2 files changed, 8 insertions, 9 deletions
@@ -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 @@ -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 |