mu4e: Improve personal-address handling

Make mu4e-personal-address-p safe for being called with nil.

Upgrade code that used mu4e-user-mail-address-p to
mu4e-personal-address-p.

Update docs.

Add some more helpers to mu4e-message, and avoid some byte-compiler
warnings.
This commit is contained in:
Dirk-Jan C. Binnema
2020-10-19 22:39:25 +03:00
parent 6fc294102b
commit 4985f5c959
5 changed files with 30 additions and 14 deletions

View File

@ -31,6 +31,11 @@
(require 'flow-fill)
(require 'shr)
(declare-function mu4e-error "mu4e-utils")
(declare-function mu4e-warn "mu4e-utils")
(declare-function mu4e-personal-address-p "mu4e-utils")
(declare-function mu4e-make-temp-file "mu4e-utils")
(defvar mu4e~view-message)
(defvar shr-inhibit-images)
@ -287,6 +292,19 @@ cell that matched, or nil."
cell that matched, or nil."
(cl-find-if (lambda (cell) (mu4e-personal-address-p (cdr cell)))
(mu4e-message-field msg cfield)))
(defun mu4e-message-sent-by-me (msg)
"Is this message (to be) sent by me?
Checks if the from field matches user's personal addresses."
(mu4e-message-contact-field-matches-me msg :from))
(defun mu4e-message-personal-p (msg)
"Does message have user's personal address in any of the
contact fields?"
(cl-some
(lambda (field)
(mu4e-message-contact-field-matches-me msg field))
'(:from :to :cc :bcc)))
(defsubst mu4e-message-part-field (msgpart field)
"Get some FIELD from MSGPART.