* mu4e: let mu4e-message-contact-field-matches accept lists of regexps to
match as well.
This commit is contained in:
@ -170,17 +170,24 @@ function prefers the text part, but this can be changed by setting
|
|||||||
(defun mu4e-message-contact-field-matches (msg cfield rx)
|
(defun mu4e-message-contact-field-matches (msg cfield rx)
|
||||||
"Checks whether any of the of the contacts in field
|
"Checks whether any of the of the contacts in field
|
||||||
CFIELD (either :to, :from, :cc or :bcc) of msg MSG matches (with
|
CFIELD (either :to, :from, :cc or :bcc) of msg MSG matches (with
|
||||||
their name or e-mail address) regular expressions RX. If there is a
|
their name or e-mail address) regular expressions RX. If there is a
|
||||||
|
match, return non-nil; otherwise return nil. RX can also be a list
|
||||||
|
of regular expressions, in which case any of those are tried for a
|
||||||
match."
|
match."
|
||||||
(unless (member cfield '(:to :from :bcc :cc))
|
(unless (member cfield '(:to :from :bcc :cc))
|
||||||
(mu4e-error "Not a contacts field (%S)" cfield))
|
(mu4e-error "Not a contacts field (%S)" cfield))
|
||||||
(when (find-if
|
(if (listp rx)
|
||||||
(lambda (ct)
|
;; if rx is a list, try each one of them for a match
|
||||||
(let ((name (car ct)) (email (cdr ct)))
|
(find-if
|
||||||
(or
|
(lambda (a-rx) (mu4e-message-contact-field-matches msg cfield a-rx))
|
||||||
(and name (string-match rx name))
|
rx)
|
||||||
(and email (string-match rx email)))))
|
;; not a list, check the rx
|
||||||
(mu4e-message-field msg cfield))
|
(find-if
|
||||||
|
(lambda (ct)
|
||||||
|
(let ((name (car ct)) (email (cdr ct)))
|
||||||
|
(or
|
||||||
|
(and name (string-match rx name))
|
||||||
|
(and email (string-match rx email)))))
|
||||||
(mu4e-message-field msg cfield))))
|
(mu4e-message-field msg cfield))))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user