mu4e: update mu4e-message-contact-field-matches for regexp addresses

This commit is contained in:
Dirk-Jan C. Binnema 2020-10-19 09:45:51 +03:00
parent ca97d8c026
commit e2f57e328a
1 changed files with 8 additions and 8 deletions

View File

@ -249,7 +249,7 @@ replace with."
(buffer-string))) (buffer-string)))
(defun mu4e-message-contact-field-matches (msg cfield rx) (defun mu4e-message-contact-field-matches (msg cfield rx)
"Does MSG's contact-field CFIELD matche rx? "Does MSG's contact-field CFIELD match rx?
Check if any of the of the CFIELD in MSG matches RX. I.e. Check if any of the of the CFIELD in MSG matches RX. I.e.
anything in field CFIELD (either :to, :from, :cc or :bcc, or a anything in field CFIELD (either :to, :from, :cc or :bcc, or a
list of those) of msg MSG matches (with their name or e-mail list of those) of msg MSG matches (with their name or e-mail
@ -268,7 +268,11 @@ expressions, in which case any of those are tried for a match."
;; not a list, check the rx ;; not a list, check the rx
(cl-find-if (cl-find-if
(lambda (ct) (lambda (ct)
(let ((name (car ct)) (email (cdr ct))) (let ((name (car ct)) (email (cdr ct))
;; the 'rx' may be some `/rx/` from mu4e-personal-addresses;
;; so let's detect and extract in that case.
(rx (if (string-match-p "^\\(.*\\)/$" rx)
(substring rx 1 -1) rx)))
(or (or
(and name (string-match rx name)) (and name (string-match rx name))
(and email (string-match rx email))))) (and email (string-match rx email)))))
@ -280,12 +284,8 @@ of the of the contacts in field CFIELD (either :to, :from, :cc or
:bcc) of msg MSG matches *me*, that is, any of the addresses for :bcc) of msg MSG matches *me*, that is, any of the addresses for
which `mu4e-personal-address-p' return t. Returns the contact which `mu4e-personal-address-p' return t. Returns the contact
cell that matched, or nil." cell that matched, or nil."
(cl-find-if (cl-find-if (lambda (cell) (mu4e-personal-address-p (cdr cell)))
(lambda (cc-cell) (mu4e-message-field msg cfield)))
(cl-member-if
(lambda (addr)
(mu4e-personal-address-p (cdr cc-cell)))
(mu4e-message-field msg cfield)))))
(defsubst mu4e-message-part-field (msgpart field) (defsubst mu4e-message-part-field (msgpart field)
"Get some FIELD from MSGPART. "Get some FIELD from MSGPART.