Emacs mu4e: auto-complete mail addresses

I love auto-complete package. I wish it was more commonly used by other emacs packages. But luckily auto-complete is very easy to use(*). Below is a small snippet to use auto-complete mode for completing mail addresses when writing an e-mail with mu4e.

(defvar ac-source-contacts
  '((candidates . mu4e~contacts-for-completion)
    (prefix . "^\\(?:To\\|CC\\|BCC\\): \\(?:.*, *\\)?\\(.*\\)")))

(add-hook 'mu4e-compose-mode-hook
          (lambda()
            (setq ac-sources '(ac-source-contacts))
            (auto-complete-mode)))

(*) provided that you already have a nice list of candidates to choose from : )

Update 3/01/2015: `company-mode` which provides a completion mechanism very similar to `auto-complete` mode works with mu4e out of the box. You don’t have to configure anything. Install and enable. Although there is a graphical glitch, I find its completion better.

Leave a Reply

Your email address will not be published.