emacs: address: move address-full-harvest-finished to a function

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.
This commit is contained in:
Mark Walters 2016-11-20 16:50:33 +00:00 committed by David Bremner
parent 3f5257cec2
commit df9736f20b
2 changed files with 8 additions and 4 deletions

View file

@ -37,7 +37,11 @@
(defvar notmuch-address-full-harvest-finished nil (defvar notmuch-address-full-harvest-finished nil
"t indicates that full completion address harvesting has been "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 (defcustom notmuch-address-command 'internal
"Determines how address completion candidates are generated. "Determines how address completion candidates are generated.
@ -170,7 +174,7 @@ elisp-based implementation or older implementation requiring
external commands." external commands."
(cond (cond
((eq notmuch-address-command 'internal) ((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 ;; First, run quick synchronous harvest based on what the user
;; entered so far ;; entered so far
(notmuch-address-harvest original t)) (notmuch-address-harvest original t))

View file

@ -41,7 +41,7 @@
(declare-function notmuch-address-harvest "notmuch-address") (declare-function notmuch-address-harvest "notmuch-address")
(declare-function notmuch-address-harvest-trigger "notmuch-address") (declare-function notmuch-address-harvest-trigger "notmuch-address")
(declare-function notmuch-address-matching "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-completion-headers-regexp)
;;;###autoload ;;;###autoload
@ -70,7 +70,7 @@
(line-beginning-position)) (line-beginning-position))
(setq notmuch-company-last-prefix (company-grab "[:,][ \t]*\\(.*\\)" 1 (point-at-bol))))) (setq notmuch-company-last-prefix (company-grab "[:,][ \t]*\\(.*\\)" 1 (point-at-bol)))))
(candidates (cond (candidates (cond
(notmuch-address-full-harvest-finished ((notmuch-address--harvest-ready)
;; Update harvested addressed from time to time ;; Update harvested addressed from time to time
(notmuch-address-harvest-trigger) (notmuch-address-harvest-trigger)
(notmuch-address-matching arg)) (notmuch-address-matching arg))