Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 4F2BA431FC2 for ; Sat, 17 Jan 2015 06:49:40 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 2.438 X-Spam-Level: ** X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I7ioCcmDBLet for ; Sat, 17 Jan 2015 06:49:37 -0800 (PST) Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 15C9A431FAF for ; Sat, 17 Jan 2015 06:49:37 -0800 (PST) Received: from remotemail by yantan.tethera.net with local (Exim 4.80) (envelope-from ) id 1YCUgw-0007Yi-A4; Sat, 17 Jan 2015 10:49:34 -0400 Received: (nullmailer pid 13963 invoked by uid 1000); Sat, 17 Jan 2015 14:49:28 -0000 From: David Bremner To: David Bremner , Michal Sojka , notmuch@notmuchmail.org Subject: [PATCH] emacs: convert notmuch-address-harvester to use notmuch-address Date: Sat, 17 Jan 2015 15:49:14 +0100 Message-Id: <1421506154-13886-1-git-send-email-david@tethera.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421503031-25797-1-git-send-email-david@tethera.net> References: <1421503031-25797-1-git-send-email-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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, 17 Jan 2015 14:49:40 -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. --- Let us never speak of the parent message again. 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.1.4