diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index e7978ca8..868b58c1 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -608,7 +608,7 @@ cdr element the To: prefix.") otherwise ; show the from address; prefixed with the appropriate `mu4e-headers-from-or-to-prefix'." (let ((addr (cdr-safe (car-safe (mu4e-message-field msg :from))))) - (if (and addr (mu4e-user-mail-address-p addr)) + (if (and addr (mu4e-personal-address-p addr)) (concat (cdr mu4e-headers-from-or-to-prefix) (mu4e~headers-contact-str (mu4e-message-field msg :to))) (concat (car mu4e-headers-from-or-to-prefix) diff --git a/mu4e/mu4e-message.el b/mu4e/mu4e-message.el index 19ad2860..e555fb80 100644 --- a/mu4e/mu4e-message.el +++ b/mu4e/mu4e-message.el @@ -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." (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. A part would look something like: diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index e8956fa1..7455bb7f 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -68,14 +68,15 @@ Evaluate to nil if ADDR matches any of the personal addresses. Uses (mu4e-personal-addresses) for the addresses with both the plain addresses and /regular expressions/." - (seq-find - (lambda (m) - (if (string-match "/\\(.*\\)/" m) - (let ((rx (match-string 1 m)) - (case-fold-search t)) - (if (string-match rx addr) t nil)) + (when addr + (seq-find + (lambda (m) + (if (string-match "/\\(.*\\)/" m) + (let ((rx (match-string 1 m)) + (case-fold-search t)) + (if (string-match rx addr) t nil)) (eq t (compare-strings addr nil nil m nil nil 'case-insensitive)))) - (mu4e-personal-addresses))) + (mu4e-personal-addresses)))) (define-obsolete-function-alias 'mu4e-user-mail-address-p 'mu4e-personal-address-p "1.5.5") diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index ff981775..d415d254 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -270,7 +270,7 @@ found." (:from-or-to (let* ((from (mu4e-message-field msg :from)) (from (and from (cdar from)))) - (if (mu4e-user-mail-address-p from) + (if (mu4e-personal-address-p from) (mu4e~view-construct-contacts-header msg :to) (mu4e~view-construct-contacts-header msg :from)))) ;; date diff --git a/mu4e/mu4e.texi b/mu4e/mu4e.texi index b4081371..f726911b 100644 --- a/mu4e/mu4e.texi +++ b/mu4e/mu4e.texi @@ -2766,8 +2766,7 @@ message. An example should clarify this: ((mu4e-message-contact-field-matches msg :to "mu-discuss@@googlegroups.com") "/mu") - ;; messages sent directly to me go to /archive - ;; also `mu4e-user-mail-address-p' can be used + ;; messages sent directly to some spefic address me go to /private ((mu4e-message-contact-field-matches msg :to "me@@example.com") "/private") ;; messages with football or soccer in the subject go to /football @@ -2775,9 +2774,7 @@ message. An example should clarify this: (mu4e-message-field msg :subject)) "/football") ;; messages sent by me go to the sent folder - ((find-if - (lambda (addr) - (mu4e-message-contact-field-matches msg :from addr)) + ((mu4e-message-sent-by-me msg (mu4e-personal-addresses)) mu4e-sent-folder) ;; everything else goes to /archive