discussion and development of piem
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: piem@inbox.kyleam.com
Subject: [PATCH 2/4] Add accessor for piem-inboxes
Date: Thu, 27 Aug 2020 23:19:18 -0400	[thread overview]
Message-ID: <20200828031920.7515-3-kyle@kyleam.com> (raw)
In-Reply-To: <20200828031920.7515-1-kyle@kyleam.com>

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.
 piem-b4.el |  2 +-
 piem.el    | 15 +++++++--------
 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 @@ (defun piem-b4--get-am-files (mid coderepo args)
     ;; 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
diff --git a/piem.el b/piem.el
index f59f723..6102b0f 100644
--- a/piem.el
+++ b/piem.el
@@ -298,10 +298,14 @@ (defun piem-inbox ()
   "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 @@ (defun piem-inbox-by-url-match (url)
         (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 @@ (defun piem-inject-thread-into-maildir (mid &optional message-only)
      "`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)
                                "Could not find inbox URL for current buffer"))

  parent reply	other threads:[~2020-08-28  3:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28  3:19 [PATCH 0/4] eww, elfeed: Improve inbox and message ID detection Kyle Meyer
2020-08-28  3:19 ` [PATCH 1/4] elfeed, eww: Don't assume inbox name in piem-inboxes and URL match Kyle Meyer
2020-08-28  3:19 ` Kyle Meyer [this message]
2020-08-28  3:19 ` [PATCH 3/4] piem-inbox-{codrepo,get}: Allow caller to specify inbox Kyle Meyer
2020-08-28  3:19 ` [PATCH 4/4] elfeed, eww: Be stricter about the returned message ID Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://git.kyleam.com/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200828031920.7515-3-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).