diff options
author | Kyle Meyer <kyle@kyleam.com> | 2021-02-07 02:57:34 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2021-02-07 12:38:50 -0500 |
commit | e06a50377649da9af7a804ba225b400c87e11d40 (patch) | |
tree | 9c402d4410bcfd78bba12179ddd90dba5121e74b /piem.el | |
parent | 0a3de9e528c010e3f8ff113eaca28f10ad0528ca (diff) | |
download | piem-e06a50377649da9af7a804ba225b400c87e11d40.tar.gz |
piem: Add helper to construct message ID link
There are two spots that use (piem-inbox-get :url ...) and
piem-escape-mid to construct the public-inbox link, and there is about
to be another. Extract this shared logic.
Cc: Xinglu Chen <public@yoctocell.xyz>
Message-Id: <20210207075738.8752-2-kyle@kyleam.com>
Diffstat (limited to 'piem.el')
-rw-r--r-- | piem.el | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -444,7 +444,7 @@ buffer." nil)))) -;;;; Download helpers +;;;; Link handling (defconst piem--unreserved-chars (append url-unreserved-chars @@ -456,6 +456,20 @@ buffer." "Escape MID for use in path part of a public-inbox URL." (url-hexify-string mid piem--unreserved-chars)) +(defun piem-mid-url (mid &optional inbox) + "Return a public-inbox URL for MID. +The URL is determined by INBOX's entry in `piem-inboxes'. If +INBOX is nil, use the inbox returned by `piem-inbox'." + (concat + (piem--ensure-trailing-slash + (or (piem-inbox-get :url inbox) + (user-error "Couldn't find URL for %s" + (or inbox "current buffer")))) + (piem-escape-mid mid))) + + +;;;; Download helpers + (defvar piem--has-gunzip) (defun piem-check-gunzip () "Return non-nil if gunzip is available." @@ -550,10 +564,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-get :url) - (user-error - "Could not find inbox URL for current buffer")) - (piem-escape-mid mid) + (when-let ((url (concat (piem-mid-url mid) (if message-only "/raw" "/t.mbox.gz"))) (buffer (url-retrieve-synchronously url 'silent))) (unwind-protect |