--- /dev/null
+Return-Path: <bremner@tethera.net>\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 99AE06DE1384\r
+ for <notmuch@notmuchmail.org>; Fri, 23 Oct 2015 17:22:46 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.104\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.104 tagged_above=-999 required=5 tests=[AWL=0.094, \r
+ T_FILL_THIS_FORM_SHORT=0.01] 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 Reyy8-_ZsRZF for <notmuch@notmuchmail.org>;\r
+ Fri, 23 Oct 2015 17:22:44 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 71D8B6DE1405\r
+ for <notmuch@notmuchmail.org>; Fri, 23 Oct 2015 17:22:44 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1Zpmav-0006nQ-VU; Sat, 24 Oct 2015 00:22:01 +0000\r
+Received: (nullmailer pid 26053 invoked by uid 1000); Sat, 24 Oct 2015\r
+ 00:20:41 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v5 2/3] emacs: convert notmuch-address-harvester to use\r
+ notmuch-address\r
+Date: Fri, 23 Oct 2015 21:20:36 -0300\r
+Message-Id: <1445646037-25994-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.6.1\r
+In-Reply-To: <1445646037-25994-1-git-send-email-david@tethera.net>\r
+References: <1445646037-25994-1-git-send-email-david@tethera.net>\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: Sat, 24 Oct 2015 00:22:46 -0000\r
+\r
+No attempt is made to optimize anything here, just drop in the new\r
+command. In particular the use of --output=recipients is known to be\r
+slower than --output=senders, but it fit the existing logic better.\r
+---\r
+ emacs/notmuch-address.el | 25 ++++++++-----------------\r
+ 1 file changed, 8 insertions(+), 17 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
+index 9f6711b..d54a8bb 100644\r
+--- a/emacs/notmuch-address.el\r
++++ b/emacs/notmuch-address.el\r
+@@ -20,7 +20,6 @@\r
+ ;; Authors: David Edmondson <dme@dme.org>\r
+ \r
+ (require 'message)\r
+-(require 'notmuch-query)\r
+ (require 'notmuch-parser)\r
+ \r
+ ;;\r
+@@ -148,21 +147,12 @@ external commands."\r
+ (not (file-directory-p bin))))\r
+ (throw 'found-command bin))))))))\r
+ \r
+-(defun notmuch-address-harvest-msg (msg)\r
+- (let* ((headers (plist-get msg :headers))\r
+- (to (ignore-errors (mail-extract-address-components (plist-get headers :To) t)))\r
+- (cc (ignore-errors (mail-extract-address-components (plist-get headers :Cc) t)))\r
+- (bcc (ignore-errors (mail-extract-address-components (plist-get headers :Bcc) t))))\r
+- (mapc (lambda (parts)\r
+- (let* ((name (car parts))\r
+- (email (cadr parts))\r
+- (entry (if name (format "%s <%s>" name email) email)))\r
+- (puthash entry t notmuch-address-completions)))\r
+- (append to cc bcc))\r
+- nil))\r
++(defun notmuch-address-harvest-addr (result)\r
++ (let ((name-addr (plist-get result :name-addr)))\r
++ (puthash name-addr t notmuch-address-completions)))\r
+ \r
+ (defun notmuch-address-harvest-handle-result (obj)\r
+- (notmuch-query-map-threads 'notmuch-address-harvest-msg (list obj)))\r
++ (notmuch-address-harvest-addr obj))\r
+ \r
+ (defun notmuch-address-harvest-filter (proc string)\r
+ (when (buffer-live-p (process-buffer proc))\r
+@@ -188,10 +178,11 @@ called when harvesting finishes."\r
+ (query (if filter-query\r
+ (format "(%s) and (%s)" from-me-query filter-query)\r
+ from-me-query))\r
+- (args `("show" "--format=sexp" "--format-version=2"\r
+- "--body=false" "--entire-thread=false" ,query)))\r
++ (args `("address" "--format=sexp" "--format-version=2"\r
++ "--output=recipients"\r
++ ,query)))\r
+ (if synchronous\r
+- (notmuch-query-map-threads 'notmuch-address-harvest-msg\r
++ (mapc #'notmuch-address-harvest-addr\r
+ (apply 'notmuch-call-notmuch-sexp args))\r
+ ;; Asynchronous\r
+ (when notmuch-address-harvest-proc\r
+-- \r
+2.6.1\r
+\r