branch: externals/gnorb
commit 0889540e82f39cc7d2ddc442c67416c1976e2258
Author: Eric Abrahamsen <[email protected]>
Commit: Eric Abrahamsen <[email protected]>
Refine matching of user email address
Fixes #23
* gnorb-org.el (gnorb-user-address-match-p): New function that does a
more careful job of checking whether an address matches the user's
address(es).
(gnorb-org-extract-mail-tracking): Use new function.
---
gnorb-org.el | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/gnorb-org.el b/gnorb-org.el
index 6602460..0f0c87a 100644
--- a/gnorb-org.el
+++ b/gnorb-org.el
@@ -208,6 +208,17 @@ See the docstring of `gnorb-org-handle-mail' for details."
(gnorb-collect-ids)))))
(gnorb-org-extract-mail-tracking assoc-msg-ids arg region))))
+(defun gnorb-user-address-match-p (addr)
+ "Return t if ADDR seems to match the user's email address."
+ (cond
+ ((stringp message-alternative-emails)
+ (string-match-p message-alternative-emails
+ addr))
+ ((functionp message-alternative-emails)
+ (funcall message-alternative-emails addr))
+ (user-mail-address
+ (string-match-p user-mail-address addr))))
+
(defun gnorb-org-extract-mail-tracking (assoc-msg-ids &optional arg region)
(let* ((all-links (gnorb-org-extract-links nil region))
@@ -221,10 +232,7 @@ See the docstring of `gnorb-org-handle-mail' for details."
(lambda (m)
(let ((from (car (gnus-registry-get-id-key m 'sender))))
(and from
- (null (or (string-match-p
- user-mail-address from)
- (string-match-p
- message-alternative-emails from))))))
+ (null (gnorb-user-address-match-p from)))))
assoc-msg-ids)
(lambda (r l)
(time-less-p