[PATCH] Fix clash of company mode and async harvest
authorMark Walters <markwalters1009@gmail.com>
Sun, 25 Oct 2015 09:16:58 +0000 (09:16 +0000)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:49:55 +0000 (14:49 -0700)
a0/743f6f0a71459561efd41ab7c73081503fe134 [new file with mode: 0644]

diff --git a/a0/743f6f0a71459561efd41ab7c73081503fe134 b/a0/743f6f0a71459561efd41ab7c73081503fe134
new file mode 100644 (file)
index 0000000..debbd66
--- /dev/null
@@ -0,0 +1,152 @@
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id C65D86DE1766\r
+ for <notmuch@notmuchmail.org>; Sun, 25 Oct 2015 02:17:13 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.099\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.099 tagged_above=-999 required=5 tests=[AWL=0.471,\r
+  DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 1v1BwuIPwDSA for <notmuch@notmuchmail.org>;\r
+ Sun, 25 Oct 2015 02:17:12 -0700 (PDT)\r
+Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com\r
+ [209.85.212.177])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id BBB056DE1405\r
+ for <notmuch@notmuchmail.org>; Sun, 25 Oct 2015 02:17:11 -0700 (PDT)\r
+Received: by wicll6 with SMTP id ll6so78436637wic.1\r
+ for <notmuch@notmuchmail.org>; Sun, 25 Oct 2015 02:17:07 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=ZtLixrTPzwaSU0obzuHnb1d7sDo+v553YyniA8qzwKk=;\r
+ b=Jry1bn2iXQ8u64difrdBvgAwIma3ITgQ62ias00qEelye299awj25b518Q/icdOZwu\r
+ U6I0WgypIP/685Qp9qcYwgOOaYUnAWwLSMH86JlJ+VGQ1Z2+hBuvwSMFO+QpIZ4FuSl4\r
+ H2dXuw+E43q/iNzQzgzN68+TanVa5W1G2g1dCXSihfQm4nOUbI3C9hAA/y52eeqOpoJ5\r
+ tSmHkMsHpSWdURn6eQsVOpggK6YJeIcUBegFU+WAWMV9LMJNBwb0NWExpzgaqo6Z0qsY\r
+ 1mBd/9rR7uAjNzDtajAGuJHZe7Wwy4HnVxPOnc+OjnoSMHLndazfbInQXMpZeke5QhQZ\r
+ PW6g==\r
+X-Received: by 10.28.87.1 with SMTP id l1mr1347836wmb.72.1445764627732;\r
+ Sun, 25 Oct 2015 02:17:07 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id bh5sm32506514wjb.42.2015.10.25.02.17.05\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sun, 25 Oct 2015 02:17:06 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] Fix clash of company mode and async harvest\r
+Date: Sun, 25 Oct 2015 09:16:58 +0000\r
+Message-Id: <1445764618-29250-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <87lhardeo6.fsf@qmul.ac.uk>\r
+References: <87lhardeo6.fsf@qmul.ac.uk>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 25 Oct 2015 09:17:13 -0000\r
+\r
+The current code has a bug such that an async partial harvest kills\r
+the full harvest, and marks the full harvest complete. This means the\r
+full harvest is not reattempted for another 24 hours (during which\r
+time the user will only get partial results).\r
+\r
+Fix this by using separate buffers for full and partial harvests. Also\r
+check the return value of the full harvest and only mark the harvest\r
+complete if it finishes successfully.\r
+---\r
+\r
+This seems to fix the bug mentioned in my previous email. It works\r
+under light testing in both emacs 23 and emacs 24.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+emacs/notmuch-address.el | 41 +++++++++++++++++++++++++++++------------\r
+ 1 file changed, 29 insertions(+), 12 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
+index d82c2aa..228135e 100644\r
+--- a/emacs/notmuch-address.el\r
++++ b/emacs/notmuch-address.el\r
+@@ -161,7 +161,10 @@ (defun notmuch-address-harvest-filter (proc string)\r
+       (notmuch-sexp-parse-partial-list\r
+        'notmuch-address-harvest-handle-result (process-buffer proc)))))\r
\r
+-(defvar notmuch-address-harvest-proc nil)   ; the process of a harvest underway\r
++(defvar notmuch-address-harvest-procs '(nil . nil)\r
++  "The currently running harvests.\r
++\r
++The car is a partial harvest, and the cdr is a full harvest")\r
\r
+ (defun notmuch-address-harvest (&optional filter-query synchronous callback)\r
+   "Collect addresses completion candidates. It queries the\r
+@@ -184,16 +187,25 @@ (defun notmuch-address-harvest (&optional filter-query synchronous callback)\r
+       (mapc #'notmuch-address-harvest-addr\r
+                                  (apply 'notmuch-call-notmuch-sexp args))\r
+       ;; Asynchronous\r
+-      (when notmuch-address-harvest-proc\r
+-      (kill-buffer (process-buffer notmuch-address-harvest-proc))) ; this also kills the process\r
+-      (setq notmuch-address-harvest-proc\r
+-          (apply 'notmuch-start-notmuch\r
+-           "notmuch-address-harvest"          ; process name\r
+-           " *notmuch-address-harvest*"       ; process buffer\r
+-           callback                           ; process sentinel\r
+-           args))\r
+-      (set-process-filter notmuch-address-harvest-proc 'notmuch-address-harvest-filter)\r
+-      (set-process-query-on-exit-flag notmuch-address-harvest-proc nil)))\r
++      (let* ((current-proc (if filter-query\r
++                             (car notmuch-address-harvest-procs)\r
++                           (cdr notmuch-address-harvest-procs)))\r
++           (proc-name (format "notmuch-address-%s-harvest"\r
++                              (if filter-query "partial" "full")))\r
++           (proc-buf (concat " *" proc-name "*")))\r
++      ;; Kill any existing process\r
++      (when current-proc\r
++        (kill-buffer (process-buffer current-proc))) ; this also kills the process\r
++\r
++      (setq current-proc\r
++            (apply 'notmuch-start-notmuch proc-name proc-buf\r
++                   callback                           ; process sentinel\r
++                   args))\r
++      (set-process-filter current-proc 'notmuch-address-harvest-filter)\r
++      (set-process-query-on-exit-flag current-proc nil)\r
++      (if filter-query\r
++          (setcar notmuch-address-harvest-procs current-proc)\r
++        (setcdr notmuch-address-harvest-procs current-proc)))))\r
+   ;; return value\r
+   nil)\r
\r
+@@ -203,7 +215,12 @@ (defun notmuch-address-harvest-trigger ()\r
+       (setq notmuch-address-last-harvest now)\r
+       (notmuch-address-harvest nil nil\r
+                              (lambda (proc event)\r
+-                               (setq notmuch-address-full-harvest-finished t))))))\r
++                               ;; If harvest fails, we want to try\r
++                               ;; again when the trigger is next\r
++                               ;; called\r
++                               (if (string= event "finished\n")\r
++                                   (setq notmuch-address-full-harvest-finished t)\r
++                                 (setq notmuch-address-last-harvest 0)))))))\r
\r
+ ;;\r
\r
+-- \r
+2.1.4\r
+\r