1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 4F2BA431FC2
\r
6 for <notmuch@notmuchmail.org>; Sat, 17 Jan 2015 06:49:40 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5
\r
12 tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id I7ioCcmDBLet for <notmuch@notmuchmail.org>;
\r
16 Sat, 17 Jan 2015 06:49:37 -0800 (PST)
\r
17 Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])
\r
18 (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 15C9A431FAF
\r
21 for <notmuch@notmuchmail.org>; Sat, 17 Jan 2015 06:49:37 -0800 (PST)
\r
22 Received: from remotemail by yantan.tethera.net with local (Exim 4.80)
\r
23 (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
24 id 1YCUgw-0007Yi-A4; Sat, 17 Jan 2015 10:49:34 -0400
\r
25 Received: (nullmailer pid 13963 invoked by uid 1000); Sat, 17 Jan 2015
\r
27 From: David Bremner <david@tethera.net>
\r
28 To: David Bremner <david@tethera.net>, Michal Sojka <sojkam1@fel.cvut.cz>,
\r
29 notmuch@notmuchmail.org
\r
30 Subject: [PATCH] emacs: convert notmuch-address-harvester to use
\r
32 Date: Sat, 17 Jan 2015 15:49:14 +0100
\r
33 Message-Id: <1421506154-13886-1-git-send-email-david@tethera.net>
\r
34 X-Mailer: git-send-email 2.1.4
\r
35 In-Reply-To: <1421503031-25797-1-git-send-email-david@tethera.net>
\r
36 References: <1421503031-25797-1-git-send-email-david@tethera.net>
\r
37 X-BeenThere: notmuch@notmuchmail.org
\r
38 X-Mailman-Version: 2.1.13
\r
40 List-Id: "Use and development of the notmuch mail system."
\r
41 <notmuch.notmuchmail.org>
\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
45 List-Post: <mailto:notmuch@notmuchmail.org>
\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
49 X-List-Received-Date: Sat, 17 Jan 2015 14:49:40 -0000
\r
51 No attempt is made to optimize anything here, just drop in the new
\r
52 command. In particular the use of --output=recipients is known to be
\r
53 slower than --output=senders, but it fit the existing logic better.
\r
55 Let us never speak of the parent message again.
\r
56 emacs/notmuch-address.el | 25 ++++++++-----------------
\r
57 1 file changed, 8 insertions(+), 17 deletions(-)
\r
59 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
\r
60 index 9f6711b..d54a8bb 100644
\r
61 --- a/emacs/notmuch-address.el
\r
62 +++ b/emacs/notmuch-address.el
\r
64 ;; Authors: David Edmondson <dme@dme.org>
\r
67 -(require 'notmuch-query)
\r
68 (require 'notmuch-parser)
\r
71 @@ -148,21 +147,12 @@ external commands."
\r
72 (not (file-directory-p bin))))
\r
73 (throw 'found-command bin))))))))
\r
75 -(defun notmuch-address-harvest-msg (msg)
\r
76 - (let* ((headers (plist-get msg :headers))
\r
77 - (to (ignore-errors (mail-extract-address-components (plist-get headers :To) t)))
\r
78 - (cc (ignore-errors (mail-extract-address-components (plist-get headers :Cc) t)))
\r
79 - (bcc (ignore-errors (mail-extract-address-components (plist-get headers :Bcc) t))))
\r
80 - (mapc (lambda (parts)
\r
81 - (let* ((name (car parts))
\r
82 - (email (cadr parts))
\r
83 - (entry (if name (format "%s <%s>" name email) email)))
\r
84 - (puthash entry t notmuch-address-completions)))
\r
85 - (append to cc bcc))
\r
87 +(defun notmuch-address-harvest-addr (result)
\r
88 + (let ((name-addr (plist-get result :name-addr)))
\r
89 + (puthash name-addr t notmuch-address-completions)))
\r
91 (defun notmuch-address-harvest-handle-result (obj)
\r
92 - (notmuch-query-map-threads 'notmuch-address-harvest-msg (list obj)))
\r
93 + (notmuch-address-harvest-addr obj))
\r
95 (defun notmuch-address-harvest-filter (proc string)
\r
96 (when (buffer-live-p (process-buffer proc))
\r
97 @@ -188,10 +178,11 @@ called when harvesting finishes."
\r
98 (query (if filter-query
\r
99 (format "(%s) and (%s)" from-me-query filter-query)
\r
101 - (args `("show" "--format=sexp" "--format-version=2"
\r
102 - "--body=false" "--entire-thread=false" ,query)))
\r
103 + (args `("address" "--format=sexp" "--format-version=2"
\r
104 + "--output=recipients"
\r
107 - (notmuch-query-map-threads 'notmuch-address-harvest-msg
\r
108 + (mapc #'notmuch-address-harvest-addr
\r
109 (apply 'notmuch-call-notmuch-sexp args))
\r
111 (when notmuch-address-harvest-proc
\r