X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-address.el;h=49e240236c7a439d87640c4fdd2b8102446298e9;hb=dc13fcbf8755506b2681ef3c44da98737ddab8e8;hp=498ef8ae4e9f86400952708ebf89a4eb531a89e6;hpb=89f78d38c1f7c9416e5bd9521dd694bb4f90572f;p=notmuch diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index 498ef8ae..49e24023 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -22,7 +22,9 @@ (require 'message) (require 'notmuch-parser) (require 'notmuch-lib) +(require 'notmuch-company) ;; +(declare-function company-manual-begin "company") (defcustom notmuch-address-command 'internal "The command which generates possible addresses. It must take a @@ -72,9 +74,21 @@ finished") (defun notmuch-address-message-insinuate () (message "calling notmuch-address-message-insinuate is no longer needed")) +(defcustom notmuch-address-use-company t + "If available, use company mode for address completion" + :type 'boolean + :group 'notmuch-send) + (defun notmuch-address-setup () - (let ((pair (cons notmuch-address-completion-headers-regexp - #'notmuch-address-expand-name))) + (let* ((use-company (and notmuch-address-use-company + (eq notmuch-address-command 'internal) + (require 'company nil t))) + (pair (cons notmuch-address-completion-headers-regexp + (if use-company + #'company-manual-begin + #'notmuch-address-expand-name)))) + (when use-company + (notmuch-company-setup)) (unless (memq pair message-completion-alist) (setq message-completion-alist (push pair message-completion-alist)))))