12.4 Contact functions

It can sometimes be useful to discard or rewrite the contact information that mu4e provides, for example to fix spelling errors, or omit unwanted contacts.

To handle this, mu4e provides mu4e-contact-process-function, which, if defined, is applied to each contact. If the result is nil, the contact is discarded, otherwise the (modified or not) contact information is used.

Each contact is a full e-mail address as you would see in a contact-field of an e-mail message, e.g.,

"Foo Bar" <foo.bar@example.com>



An example mu4e-contact-process-function might look like:

(defun my-contact-processor (contact)
    ;; remove unwanted
    ((string-match-p "evilspammer@example.com" contact) nil)
    ((string-match-p "noreply" contact) nil)
    ;; jonh smiht --> John Smith
    ((string-match "jonh smiht" contact)
       (replace-regexp-in-string "jonh smiht" "John Smith" contact))
    (t contact)))

(setq mu4e-contact-process-function 'my-contact-processor)