1 Return-Path: <jani@nikula.org>
\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 arlo.cworth.org (Postfix) with ESMTP id DBE016DE15D4
\r
6 for <notmuch@notmuchmail.org>; Thu, 3 Sep 2015 12:40:36 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
10 X-Spam-Score: -0.426
\r
12 X-Spam-Status: No, score=-0.426 tagged_above=-999 required=5 tests=[AWL=0.294,
\r
13 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01]
\r
15 Received: from arlo.cworth.org ([127.0.0.1])
\r
16 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id 0ixXvFvmogwZ for <notmuch@notmuchmail.org>;
\r
18 Thu, 3 Sep 2015 12:40:35 -0700 (PDT)
\r
19 Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com
\r
21 by arlo.cworth.org (Postfix) with ESMTPS id 7E6076DE1534
\r
22 for <notmuch@notmuchmail.org>; Thu, 3 Sep 2015 12:40:28 -0700 (PDT)
\r
23 Received: by wiclk2 with SMTP id lk2so1207528wic.0
\r
24 for <notmuch@notmuchmail.org>; Thu, 03 Sep 2015 12:40:27 -0700 (PDT)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=1e100.net; s=20130820;
\r
27 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
\r
28 :references:in-reply-to:references;
\r
29 bh=wj+tnZTwmrqNPh73iKZVy64DGNf+PYHfGPjHpeWz3Cs=;
\r
30 b=RvqXDkwKlZg0JcuQOXwyfv2hJAFWgxfO69Z3gOTgorrEVwvoF8nDJrsgQzxixMI55v
\r
31 v0avq/Tu/gFsq9E0avlwIeOp+iARZRmNFxmIsZ3Vc1TdYYi/hjv6niGpvqBEkKpdQHSU
\r
32 sZaF9DWrPQV529LybAB79pp0r330Ft6mbRilgnoKCmEQrANzXePbmNWgf4YndYibvOz8
\r
33 CifBrZzNQGUN23sdAx9h94jzkDxUz5N8pAVrb4tKajhTGX7yR4dM/9mHGQGcRDdv48vY
\r
34 xjiRb9t4tDM+P5OArdJFEWnko9kaeoUVCeXaqZJ4BCibe7LEnU4hHMZtvU65qsh2FpGO
\r
37 ALoCoQmkdY8vuX2kaXvbnJVtNC/w/1HSklbfImyg9/RRvPnS3oT7FvNL4QjlTx295ce319ZqcEwf
\r
38 X-Received: by 10.180.74.52 with SMTP id q20mr18151766wiv.94.1441309226937;
\r
39 Thu, 03 Sep 2015 12:40:26 -0700 (PDT)
\r
40 Received: from localhost (mobile-access-bcee4f-131.dhcp.inet.fi.
\r
42 by smtp.gmail.com with ESMTPSA id i7sm625597wib.15.2015.09.03.12.40.26
\r
43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
44 Thu, 03 Sep 2015 12:40:26 -0700 (PDT)
\r
45 From: Jani Nikula <jani@nikula.org>
\r
46 To: notmuch@notmuchmail.org
\r
47 Subject: [PATCH v2 7/9] cli: add support for deduplicating based on case
\r
49 Date: Thu, 3 Sep 2015 22:40:03 +0300
\r
51 <e711ba0bd92624352e2366f4f866a406ff25981e.1441308761.git.jani@nikula.org>
\r
52 X-Mailer: git-send-email 2.1.4
\r
53 In-Reply-To: <cover.1441308761.git.jani@nikula.org>
\r
54 References: <cover.1441308761.git.jani@nikula.org>
\r
55 In-Reply-To: <cover.1441308761.git.jani@nikula.org>
\r
56 References: <cover.1441308761.git.jani@nikula.org>
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.18
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Thu, 03 Sep 2015 19:40:36 -0000
\r
71 Consider all variants of an email address as one, and print the most
\r
74 notmuch-search.c | 48 ++++++++++++++++++++++++++++++++++++++++++------
\r
75 1 file changed, 42 insertions(+), 6 deletions(-)
\r
77 diff --git a/notmuch-search.c b/notmuch-search.c
\r
78 index 7c51d5df6bd4..deb9e58a747c 100644
\r
79 --- a/notmuch-search.c
\r
80 +++ b/notmuch-search.c
\r
81 @@ -39,6 +39,7 @@ typedef enum {
\r
89 @@ -352,7 +353,7 @@ print_mailbox (const search_context_t *ctx, const mailbox_t *mailbox)
\r
90 name_addr = internet_address_to_string (ia, FALSE);
\r
92 if (format->is_text_printer) {
\r
94 + if (ctx->output & OUTPUT_COUNT) {
\r
95 format->integer (format, count);
\r
96 format->string (format, "\t");
\r
98 @@ -366,7 +367,7 @@ print_mailbox (const search_context_t *ctx, const mailbox_t *mailbox)
\r
99 format->string (format, addr);
\r
100 format->map_key (format, "name-addr");
\r
101 format->string (format, name_addr);
\r
103 + if (ctx->output & OUTPUT_COUNT) {
\r
104 format->map_key (format, "count");
\r
105 format->integer (format, count);
\r
107 @@ -403,7 +404,6 @@ process_address_list (const search_context_t *ctx,
\r
109 .name = internet_address_get_name (address),
\r
110 .addr = internet_address_mailbox_get_addr (mailbox),
\r
114 /* OUTPUT_COUNT only works with deduplication */
\r
115 @@ -411,7 +411,8 @@ process_address_list (const search_context_t *ctx,
\r
116 is_duplicate (ctx, mbx.name, mbx.addr))
\r
119 - if (ctx->output & OUTPUT_COUNT)
\r
120 + /* OUTPUT_COUNT and DEDUP_ADDRESS require a full pass. */
\r
121 + if (ctx->output & OUTPUT_COUNT || ctx->dedup == DEDUP_ADDRESS)
\r
124 print_mailbox (ctx, &mbx);
\r
125 @@ -450,6 +451,34 @@ _list_free_for_g_hash (void *ptr)
\r
126 g_list_free_full (ptr, _talloc_free_for_g_hash);
\r
129 +/* Print the most common variant of a list of unique mailboxes, and
\r
130 + * conflate the counts. */
\r
132 +print_popular (const search_context_t *ctx, GList *list)
\r
135 + mailbox_t *mailbox = NULL, *m;
\r
139 + for (l = list; l; l = l->next) {
\r
141 + total += m->count;
\r
142 + if (m->count > max) {
\r
149 + INTERNAL_ERROR("Empty list in address hash table\n");
\r
151 + /* The original count is no longer needed, so overwrite. */
\r
152 + mailbox->count = total;
\r
154 + print_mailbox (ctx, mailbox);
\r
158 print_list_value (void *mailbox, void *context)
\r
160 @@ -459,7 +488,12 @@ print_list_value (void *mailbox, void *context)
\r
162 print_hash_value (unused (void *key), void *list, void *context)
\r
164 - g_list_foreach (list, print_list_value, context);
\r
165 + const search_context_t *ctx = context;
\r
167 + if (ctx->dedup == DEDUP_ADDRESS)
\r
168 + print_popular (ctx, list);
\r
170 + g_list_foreach (list, print_list_value, context);
\r
174 @@ -557,7 +591,8 @@ do_search_messages (search_context_t *ctx)
\r
175 notmuch_message_destroy (message);
\r
178 - if (ctx->addresses && ctx->output & OUTPUT_COUNT)
\r
179 + if (ctx->addresses &&
\r
180 + (ctx->output & OUTPUT_COUNT || ctx->dedup == DEDUP_ADDRESS))
\r
181 g_hash_table_foreach (ctx->addresses, print_hash_value, ctx);
\r
183 notmuch_messages_destroy (messages);
\r
184 @@ -821,6 +856,7 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
\r
185 { NOTMUCH_OPT_KEYWORD, &ctx->dedup, "deduplicate", 'D',
\r
186 (notmuch_keyword_t []){ { "no", DEDUP_NONE },
\r
187 { "mailbox", DEDUP_MAILBOX },
\r
188 + { "address", DEDUP_ADDRESS },
\r
190 { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 },
\r
191 { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
\r