aboutsummaryrefslogtreecommitdiff
path: root/piem.el
diff options
context:
space:
mode:
Diffstat (limited to 'piem.el')
-rw-r--r--piem.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/piem.el b/piem.el
index 42646a0..f59f723 100644
--- a/piem.el
+++ b/piem.el
@@ -252,6 +252,9 @@ Functions should accept one argument, the message ID given to
;;;; Extractors
+(defun piem--ensure-trailing-slash (s)
+ (if (string-match-p ".+/\\'" s) s (concat s "/")))
+
(defvar piem-link-re
(rx "/" (group (one-or-more (not (any "/" "\n"))))
"/" (group (one-or-more (not (any "/" "\n"))))
@@ -301,6 +304,17 @@ intended to be used by libraries implementing a function for
(repo (plist-get (cdr (assoc p piem-inboxes)) :coderepo)))
(expand-file-name repo)))
+(defun piem-inbox-by-url-match (url)
+ "Return inbox based on matching URL against `:url'."
+ (setq url (piem--ensure-trailing-slash url))
+ (catch 'hit
+ (dolist (inbox piem-inboxes)
+ (when-let ((info (cdr inbox))
+ (p-url (plist-get info :url)))
+ (setq p-url (piem--ensure-trailing-slash p-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)))