X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-address.el;h=34793dbec99e235ae863ae63dbc6d79881ce3efb;hb=e81c71639e91d9a7f1fcda0f121c2ce8ed0cec63;hp=c6f5f11136093c8d857e236da4525d414cdf8225;hpb=2cf0ef3998a75a8e5bcd83f0a286d9660f1bdb0e;p=notmuch diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index c6f5f111..34793dbe 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -118,17 +118,30 @@ to know how address selection is made by default." :group 'notmuch-send) (defun notmuch-address-setup () - (let* ((use-company (and notmuch-address-use-company - (eq notmuch-address-command 'internal) + (let* ((setup-company (and notmuch-address-use-company (require 'company nil t))) (pair (cons notmuch-address-completion-headers-regexp #'notmuch-address-expand-name))) - (when use-company + (when setup-company (notmuch-company-setup)) (unless (memq pair message-completion-alist) (setq message-completion-alist (push pair message-completion-alist))))) +(defun notmuch-address-toggle-internal-completion () + "Toggle use of internal completion for current buffer. + +This overrides the global setting for address completion and +toggles the setting in this buffer." + (interactive) + (if (local-variable-p 'notmuch-address-command) + (kill-local-variable 'notmuch-address-command) + (notmuch-setq-local notmuch-address-command 'internal)) + (if (boundp 'company-idle-delay) + (if (local-variable-p 'company-idle-delay) + (kill-local-variable 'company-idle-delay) + (notmuch-setq-local company-idle-delay nil)))) + (defun notmuch-address-matching (substring) "Returns a list of completion candidates matching SUBSTRING. The candidates are taken from `notmuch-address-completions'."