]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-company.el
emacs: Shorten long lines
[notmuch] / emacs / notmuch-company.el
index ebe2c0846e1b2108f520023e3198970d7e43410e..c1f3594e513ad55ff2ace05d90ae9eaf6a6956fe 100644 (file)
@@ -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)
 (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 ()
   (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)))))
+                  (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))
                   (t
                    (cons :async
                          (lambda (callback)
-                           ;; First run quick asynchronous harvest based on what the user entered so far
+                           ;; First run quick asynchronous harvest
+                           ;; based on what the user entered so far
                            (notmuch-address-harvest
                             arg nil
                             (lambda (_proc _event)
                               (funcall callback (notmuch-address-matching arg))
-                              ;; Then start the (potentially long-running) full asynchronous harvest if necessary
+                              ;; Then start the (potentially long-running)
+                              ;; full asynchronous harvest if necessary
                               (notmuch-address-harvest-trigger))))))))
       (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))
+      (post-completion
+       (run-hook-with-args 'notmuch-address-post-completion-functions arg))
       (no-cache t))))