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

View File

@ -249,7 +249,7 @@ replace with."
(t "")))) (t ""))))
(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 match 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
@ -268,7 +268,11 @@ expressions, in which case any of those are tried for a match."
rx) rx)
;; 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))
;; 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))) (substring rx 1 -1) rx)))
(or (or
(and name (string-match rx name)) (and name (string-match rx name))
@ -280,12 +284,8 @@ of the of the contacts in field CFIELD (either :to, :from, :cc or
of the of the contacts in field CFIELD (either :to, :from, :cc or 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)
(cl-member-if
(lambda (addr)
(mu4e-personal-address-p (cdr cc-cell)))
(mu4e-message-field msg cfield))) (mu4e-message-field msg cfield)))
(defsubst mu4e-message-part-field (msgpart field) (defsubst mu4e-message-part-field (msgpart field)