emacs: address: move address-full-harvest-finished to a function
authorMark Walters <markwalters1009@gmail.com>
Sun, 20 Nov 2016 16:50:33 +0000 (16:50 +0000)
committerDavid Bremner <david@tethera.net>
Sat, 28 Jan 2017 02:07:43 +0000 (22:07 -0400)
This makes the code access notmuch-address-full-harvest-finished via a
helper function, notmuch-address--harvest-ready. Later we will use
this to check whether we can load the harvest instead of regenerating
it.

emacs/notmuch-address.el
emacs/notmuch-company.el

index b3c56cfaad9dc212b990559171c1df2499b39722..2eaca7958bb2736de3e21abe0e04a5946f95ab96 100644 (file)
 
 (defvar notmuch-address-full-harvest-finished nil
   "t indicates that full completion address harvesting has been
-finished")
+finished. Use notmuch-address--harvest-ready to access.")
+
+(defun notmuch-address--harvest-ready ()
+  "Return t if there is a full address hash available."
+  notmuch-address-full-harvest-finished)
 
 (defcustom notmuch-address-command 'internal
   "Determines how address completion candidates are generated.
@@ -170,7 +174,7 @@ elisp-based implementation or older implementation requiring
 external commands."
   (cond
    ((eq notmuch-address-command 'internal)
-    (when (not notmuch-address-full-harvest-finished)
+    (unless (notmuch-address--harvest-ready)
       ;; First, run quick synchronous harvest based on what the user
       ;; entered so far
       (notmuch-address-harvest original t))
index ebe2c0846e1b2108f520023e3198970d7e43410e..dca6471beac1998338ca5a85843e1847bcefa996 100644 (file)
@@ -41,7 +41,7 @@
 (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)
 
 ;;;###autoload
@@ -70,7 +70,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))