It can sometimes be useful to rewrite the contact information that mu4e provides, for example to convert them to some standardized format, or to fix spelling errors. And sometimes, you may want to remove certain contacts altogether.
For this, mu4e provides
mu4e-contact-rewrite-function, which passes each
contact to a user-provided function, which is expected to return either the possibly rewritten
nil to remove the contact from the list - note that the latter can also
be achieved using
Each of the contacts are property-lists (’plists’), with properties
Let’s look at an example:
(defun my-rewrite-function (contact) (let ((name (or (plist-get contact :name) "")) (mail (plist-get contact :mail))) (cond ;; jonh smiht --> John Smith ((string= "jonh smiht" name) (plist-put contact :name "John C. Smith") contact) ;; remove evilspammer from the contacts list ((string= "firstname.lastname@example.org" mail) nil) ;; others stay as the are (t contact)))) (setq mu4e-contact-rewrite-function 'my-rewrite-function)
This function is called for each of your contacts.