aboutsummaryrefslogtreecommitdiff
path: root/piem-notmuch.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-05-10 23:41:59 -0400
committerKyle Meyer <kyle@kyleam.com>2020-05-11 00:22:16 -0400
commitd55b7895a8829d4fd120295bfb6134b51bf87fe4 (patch)
treea1884d1e58e3a941c5190dfb54bd9c19b3457ff1 /piem-notmuch.el
parentbf7ac5923e205e298b38f50f01841cdaf30d6a60 (diff)
downloadpiem-d55b7895a8829d4fd120295bfb6134b51bf87fe4.tar.gz
piem: Extract "inbox from headers" logic from -notmuch
This will be used in the upcoming piem-gnus.el as well.
Diffstat (limited to 'piem-notmuch.el')
-rw-r--r--piem-notmuch.el25
1 files changed, 3 insertions, 22 deletions
diff --git a/piem-notmuch.el b/piem-notmuch.el
index ed5bd4b..96b8a05 100644
--- a/piem-notmuch.el
+++ b/piem-notmuch.el
@@ -26,7 +26,6 @@
;;; Code:
-(require 'message)
(require 'notmuch)
(require 'piem)
(require 'subr-x)
@@ -49,27 +48,9 @@
(defun piem-notmuch-get-inbox ()
"Return inbox name from a `notmuch-show-mode' buffer."
- (pcase-let ((`(,listid ,to ,cc)
- (when (derived-mode-p 'notmuch-show-mode)
- (piem-notmuch--with-current-message
- (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)))))))))
+ (when (derived-mode-p 'notmuch-show-mode)
+ (piem-notmuch--with-current-message
+ (piem-inbox-by-header-match))))
(defun piem-notmuch-get-mid ()
"Return the message ID of a `notmuch-show-mode' buffer."