aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--piem-b4.el2
-rw-r--r--piem-elfeed.el2
-rw-r--r--piem-eww.el2
-rw-r--r--piem.el16
-rw-r--r--tests/piem-tests.el6
5 files changed, 17 insertions, 11 deletions
diff --git a/piem-b4.el b/piem-b4.el
index cd19ebb..8a381c6 100644
--- a/piem-b4.el
+++ b/piem-b4.el
@@ -73,7 +73,7 @@ This is intended to be used for debugging purposes.")
;; b4's configuration.
(unless local-mbox-p
(when-let ((url (and (equal mid (piem-mid))
- (piem-inbox-get :url))))
+ (piem-inbox-url))))
(ignore-errors
(piem-with-url-contents
(concat url (piem-escape-mid mid) "/t.mbox.gz")
diff --git a/piem-elfeed.el b/piem-elfeed.el
index ce9c75c..eef61e8 100644
--- a/piem-elfeed.el
+++ b/piem-elfeed.el
@@ -44,7 +44,7 @@
(defun piem-elfeed-get-mid ()
"Return the message ID of an `elfeed-show-mode' buffer."
(when-let ((inbox (piem-elfeed-get-inbox))
- (inbox-url (piem-inbox-get :url inbox))
+ (inbox-url (piem-inbox-url inbox))
(link (elfeed-entry-link elfeed-show-entry)))
(and (string-match (piem-message-link-re inbox-url) link)
(url-unhex-string (match-string 1 link)))))
diff --git a/piem-eww.el b/piem-eww.el
index 01a9f9d..5769060 100644
--- a/piem-eww.el
+++ b/piem-eww.el
@@ -43,7 +43,7 @@
(defun piem-eww-get-mid ()
"Return the message ID of an EWW buffer."
(when-let ((inbox (piem-eww-get-inbox))
- (inbox-url (piem-inbox-get :url inbox))
+ (inbox-url (piem-inbox-url inbox))
(url (plist-get eww-data :url)))
(and (string-match (piem-message-link-re inbox-url) url)
(url-unhex-string (match-string 1 url)))))
diff --git a/piem.el b/piem.el
index a933a6c..568e91b 100644
--- a/piem.el
+++ b/piem.el
@@ -80,7 +80,7 @@ list that supports the following properties:
repository, with the first value in this list offered as
the default.
:url
- A URL hosting HTTPS archives. This value must end with a slash.
+ A URL hosting HTTPS archives.
:maildir
A Maildir directory to inject messages into.
@@ -522,6 +522,13 @@ returned by `piem-inbox'."
(when-let ((p (or inbox (piem-inbox))))
(plist-get (cdr (assoc p (piem-merged-inboxes))) key)))
+(defun piem-inbox-url (&optional inbox)
+ "Return URL associated with INBOX.
+If INBOX is nil, use the inbox returned by `piem-inbox'."
+ (when-let ((inbox (or inbox (piem-inbox)))
+ (url (piem-inbox-get :url inbox)))
+ (piem--ensure-trailing-slash url)))
+
(defun piem-inbox-coderepo (&optional inbox)
"Return the code repository of current buffer's inbox."
(when-let ((inbox (or inbox (piem-inbox)))
@@ -665,10 +672,9 @@ The URL for INBOX may be defined in `piem-inboxes' or
public-inbox's configuration. 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"))))
+ (or (piem-inbox-url inbox)
+ (user-error "Couldn't find URL for %s"
+ (or inbox "current buffer")))
(piem-escape-mid mid)))
;;;###autoload
diff --git a/tests/piem-tests.el b/tests/piem-tests.el
index 7f9f30f..b612b96 100644
--- a/tests/piem-tests.el
+++ b/tests/piem-tests.el
@@ -74,7 +74,7 @@
(piem-merged-inboxes))))
(let ((piem-get-inboxes-from-config nil)
(piem-inboxes '(("inbox" :url "inbox-url"))))
- (should (equal (piem-inbox-get :url "inbox") "inbox-url"))))
+ (should (equal (piem-inbox-url "inbox") "inbox-url/"))))
(ert-deftest piem-merged-inboxes:from-config ()
(piem-clear-merged-inboxes)
@@ -83,8 +83,8 @@
(piem-tests-with-pi-config piem-tests-sample-pi-config
(should (equal (piem-inbox-get :address "foo")
"foo@example.com"))
- (should (equal (piem-inbox-get :url "foo")
- "https://example.com/foo"))
+ (should (equal (piem-inbox-url "foo")
+ "https://example.com/foo/"))
(should (equal (piem-inbox-coderepo "foo")
"/code/foo/")))
(piem-tests-with-pi-config ""