From ba606bd09f499a6b621b0344454cf5ec9931b421 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Thu, 11 Jun 2020 23:50:48 -0400 Subject: Reposition two incorrectly placed things Neither of these belong in the "Options" section. --- piem.el | 78 ++++++++++++++++++++++++++++++++--------------------------------- 1 file 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)) -- cgit v1.2.3