From 8b775ab238a35bc507b1231d58df0c68aad992c0 Mon Sep 17 00:00:00 2001 From: djcb Date: Sun, 6 Apr 2014 17:51:12 +0100 Subject: [PATCH] * mu4e: update the contact-rewriting code a bit: - make the default nil rather than a dummy (identity) function, for speed - don't use 'canonical' but the 'rewrite' which is a bit more general --- mu4e/mu4e-utils.el | 22 +++++----------------- mu4e/mu4e-vars.el | 23 +++++++++++++++++++---- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index d8d55b1a..87d79cb3 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -604,20 +604,6 @@ process." (replace-regexp-in-string "\"" "\\\\\"" ph))) (t (format "\"%s\"" ph))))) -;;; names and mail-addresses can be mapped onto their canonical counterpart. -;;; use the customizeable function mu4e-canonical-contact-function to do that. -;;; below the identity function for mapping a contact onto the canonical one. -(defun mu4e-canonical-contact-identity (contact) - "This returns the name and the mail-address of a contact. -It's used as an identity function for converting contacts to their -canonical counterpart." - (let ((name (plist-get contact :name)) - (mail (plist-get contact :mail)) - ) - (list :name name :mail mail) - ) - ) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; start and stopping (defun mu4e~fill-contacts (contacts) @@ -642,9 +628,11 @@ This is used by the completion function in mu4e-compose." (< tstamp1 tstamp2) (< freq1 freq2))))))) (dolist (contact contacts) - (let* ((canonicalcontact (funcall mu4e-canonical-contact-function contact)) - (name (plist-get canonicalcontact :name)) - (mail (plist-get canonicalcontact :mail))) + (let* ((contact + (if mu4e-contact-rewrite-function + (funcall mu4e-contact-rewrite-function contact) contact)) + (name (plist-get contact :name)) + (mail (plist-get contact :mail))) (when mail (unless ;; ignore some address ('noreply' etc.) (and mu4e-compose-complete-ignore-address-regexp diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index 57056beb..2e9962b4 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -249,13 +249,28 @@ Set to nil to not have any time-based restriction." :type 'string :group 'mu4e-compose) -(defcustom mu4e-canonical-contact-function 'mu4e-canonical-contact-identity - "Function to be used for processing every contact and convert it to the -canonical counterpart, you may use this for correcting typo's, changed -names and adapting addresses or names to company policies." + +;;; names and mail-addresses can be mapped onto their canonical +;;; counterpart. use the customizeable function +;;; mu4e-canonical-contact-function to do that. below the identity +;;; function for mapping a contact onto the canonical one. +(defun mu4e-contact-identity (contact) + "This returns the name and the mail-address of a contact. +It's used as an identity function for converting contacts to their +canonical counterpart." + (let ((name (plist-get contact :name)) + (mail (plist-get contact :mail))) + (list :name name :mail mail))) + +(defcustom mu4e-contact-rewrite-function nil + "Function to be used for when processing contacts and rewrite +them, for example you may use this for correcting typo's, changed +names and adapting addresses or names to company policies. As as +example of this, see `mu4e-contact-identity'." :type 'function :group 'mu4e-compose) + (defcustom mu4e-compose-complete-ignore-address-regexp "no-?reply" "Ignore any e-mail addresses for completion if they match this regexp." :type 'string