X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-company.el;h=ac998f9b4496d39f157923846329e9f301e32848;hp=5d75c1455933e0548cb44fe47b26d718c4656a14;hb=11ac932a4503872c19987b843d58513c4b9ef76f;hpb=a3e712fa86a1f6df02a8be9f620f33ed9189069d diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el index 5d75c145..ac998f9b 100644 --- a/emacs/notmuch-company.el +++ b/emacs/notmuch-company.el @@ -27,7 +27,8 @@ ;;; Code: -(eval-when-compile (require 'cl)) +(eval-when-compile (require 'cl-lib)) + (require 'notmuch-lib) (defvar notmuch-company-last-prefix nil) @@ -37,12 +38,14 @@ (declare-function company-mode "company") (declare-function company-manual-begin "company") (defvar company-backends) +(defvar company-idle-delay) (declare-function notmuch-address-harvest "notmuch-address") (declare-function notmuch-address-harvest-trigger "notmuch-address") (declare-function notmuch-address-matching "notmuch-address") -(defvar notmuch-address-full-harvest-finished) +(declare-function notmuch-address--harvest-ready "notmuch-address") (defvar notmuch-address-completion-headers-regexp) +(defvar notmuch-address-command) ;;;###autoload (defun notmuch-company-setup () @@ -63,14 +66,14 @@ (require 'company) (let ((case-fold-search t) (completion-ignore-case t)) - (case command + (cl-case command (interactive (company-begin-backend 'notmuch-company)) (prefix (and (derived-mode-p 'message-mode) (looking-back (concat notmuch-address-completion-headers-regexp ".*") (line-beginning-position)) (setq notmuch-company-last-prefix (company-grab "[:,][ \t]*\\(.*\\)" 1 (point-at-bol))))) (candidates (cond - (notmuch-address-full-harvest-finished + ((notmuch-address--harvest-ready) ;; Update harvested addressed from time to time (notmuch-address-harvest-trigger) (notmuch-address-matching arg)) @@ -87,6 +90,7 @@ (match (if (string-match notmuch-company-last-prefix arg) (match-end 0) 0)) + (post-completion (run-hook-with-args 'notmuch-address-post-completion-functions arg)) (no-cache t))))