X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-company.el;h=3e12e7a9f729984899dc32e5cbf2cb1b8e930710;hb=42330234df20ff04ef018150f80b11ee9dad3e80;hp=b881d6dc9aa3f7a8c4f2b257507e8cdb397bec67;hpb=0cf457b73b4b666314d1a09ac3e31bd0fa2346a6;p=notmuch
diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el
index b881d6dc..3e12e7a9 100644
--- a/emacs/notmuch-company.el
+++ b/emacs/notmuch-company.el
@@ -16,7 +16,7 @@
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see .
+;; along with this program. If not, see .
;;; Commentary:
@@ -28,6 +28,7 @@
;;; Code:
(eval-when-compile (require 'cl))
+(require 'notmuch-lib)
(defvar notmuch-company-last-prefix nil)
(make-variable-buffer-local 'notmuch-company-last-prefix)
@@ -36,18 +37,26 @@
(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 ()
(company-mode)
(make-local-variable 'company-backends)
- (setq company-backends '(notmuch-company)))
+ (setq company-backends '(notmuch-company))
+ ;; Disable automatic company completion unless an internal
+ ;; completion method is configured. Company completion (using
+ ;; internal completion) can still be accessed via standard company
+ ;; functions, e.g., company-complete.
+ (unless (eq notmuch-address-command 'internal)
+ (notmuch-setq-local company-idle-delay nil)))
;;;###autoload
(defun notmuch-company (command &optional arg &rest _ignore)
@@ -63,7 +72,7 @@
(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))
@@ -72,7 +81,7 @@
(lambda (callback)
;; First run quick asynchronous harvest based on what the user entered so far
(notmuch-address-harvest
- (format "to:%s*" arg) nil
+ arg nil
(lambda (_proc _event)
(funcall callback (notmuch-address-matching arg))
;; Then start the (potentially long-running) full asynchronous harvest if necessary
@@ -80,6 +89,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))))