summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--piem.el78
1 files changed, 39 insertions, 39 deletions
diff --git a/piem.el b/piem.el
index 191b406..65310e4 100644
--- a/piem.el
+++ b/piem.el
@@ -101,45 +101,6 @@ how to create an mbox, it should return a function that takes no
arguments and inserts the mbox's contents in the current buffer."
:type 'hook)
-(defvar piem-link-re
- (rx "/" (group (one-or-more (not (any "/" "\n"))))
- "/" (group (one-or-more (not (any "/" "\n"))))
- "/" (group (zero-or-one
- (or "raw"
- "t.mbox.gz"
- (and (or "t" "T") "/#"
- (one-or-more (not (any "/" "\n")))))))
- string-end)
- "Regular expression matching public-inbox HTTP link.
-The first group is the inbox, the second is the message ID, and
-the rest is any trailing endpoint.")
-
-(defun piem-inbox-by-header-match ()
- "Return inbox based on matching message headers.
-This should be called from a buffer containing a message and is
-intended to be used by libraries implementing a function for
-`piem-get-mid-functions'."
- (pcase-let ((`(,listid ,to ,cc)
- (save-restriction
- (message-narrow-to-headers)
- (list (message-fetch-field "list-id")
- (message-fetch-field "to")
- (message-fetch-field "cc")))))
- (catch 'hit
- (dolist (inbox piem-inboxes)
- (let* ((info (cdr inbox))
- (p-listid (plist-get info :listid)))
- (when (and listid
- p-listid
- (string-match-p (concat "<" (regexp-quote p-listid) ">")
- listid))
- (throw 'hit (car inbox)))
- (when-let ((addr (plist-get info :address))
- (to (mapconcat #'identity (list to cc)
- " ")))
- (when (string-match-p (regexp-quote addr) to)
- (throw 'hit (car inbox)))))))))
-
(defcustom piem-git-executable
(or (and (boundp 'magit-git-executable) magit-git-executable)
"git")
@@ -263,6 +224,45 @@ Functions should accept one argument, the message ID given to
;;;; Extractors
+(defvar piem-link-re
+ (rx "/" (group (one-or-more (not (any "/" "\n"))))
+ "/" (group (one-or-more (not (any "/" "\n"))))
+ "/" (group (zero-or-one
+ (or "raw"
+ "t.mbox.gz"
+ (and (or "t" "T") "/#"
+ (one-or-more (not (any "/" "\n")))))))
+ string-end)
+ "Regular expression matching public-inbox HTTP link.
+The first group is the inbox, the second is the message ID, and
+the rest is any trailing endpoint.")
+
+(defun piem-inbox-by-header-match ()
+ "Return inbox based on matching message headers.
+This should be called from a buffer containing a message and is
+intended to be used by libraries implementing a function for
+`piem-get-mid-functions'."
+ (pcase-let ((`(,listid ,to ,cc)
+ (save-restriction
+ (message-narrow-to-headers)
+ (list (message-fetch-field "list-id")
+ (message-fetch-field "to")
+ (message-fetch-field "cc")))))
+ (catch 'hit
+ (dolist (inbox piem-inboxes)
+ (let* ((info (cdr inbox))
+ (p-listid (plist-get info :listid)))
+ (when (and listid
+ p-listid
+ (string-match-p (concat "<" (regexp-quote p-listid) ">")
+ listid))
+ (throw 'hit (car inbox)))
+ (when-let ((addr (plist-get info :address))
+ (to (mapconcat #'identity (list to cc)
+ " ")))
+ (when (string-match-p (regexp-quote addr) to)
+ (throw 'hit (car inbox)))))))))
+
(defun piem-inbox ()
"Return the current buffer's inbox."
(run-hook-with-args-until-success 'piem-get-inbox-functions))