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