[RFC PATCH 5/5] cli: add support for deduplicating based on case insensitive address
authorJani Nikula <jani@nikula.org>
Sat, 29 Aug 2015 14:56:36 +0000 (17:56 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:49:27 +0000 (14:49 -0700)
1f/1f3ca71997dea33a31703a663ce9ad88e996d8 [new file with mode: 0644]

diff --git a/1f/1f3ca71997dea33a31703a663ce9ad88e996d8 b/1f/1f3ca71997dea33a31703a663ce9ad88e996d8
new file mode 100644 (file)
index 0000000..466570a
--- /dev/null
@@ -0,0 +1,137 @@
+Return-Path: <jani@nikula.org>\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 3BD746DE182F\r
+ for <notmuch@notmuchmail.org>; Sat, 29 Aug 2015 07:57:12 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.371\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.371 tagged_above=-999 required=5 tests=[AWL=0.349,\r
+  RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01]\r
+ 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 a9dUjBl5yLQV for <notmuch@notmuchmail.org>;\r
+ Sat, 29 Aug 2015 07:57:10 -0700 (PDT)\r
+Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com\r
+ [209.85.212.176])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 35D326DE1422\r
+ for <notmuch@notmuchmail.org>; Sat, 29 Aug 2015 07:56:50 -0700 (PDT)\r
+Received: by wicfv10 with SMTP id fv10so28398027wic.1\r
+ for <notmuch@notmuchmail.org>; Sat, 29 Aug 2015 07:56:48 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=tOhkooD7NhsNpnCbCtRQLQLFm3P9oiALB4kanGyOPjE=;\r
+ b=ZnwfENGpRrt3GTLW7i7gmf8nDaHDvjV9RPcaIGjqkOygX0rlh+ZmxzCA3COC6JVuli\r
+ VqXCJgBbG1ybBFXbssOufWBB06bzc1Uaqd3TvQnPJQU7rfEgmrWo1Po7CB51VwUv8EYs\r
+ S7KV6LgFaeNDFecSBwAgKpYOcMvsDOX83din5FRZfYDJNR5CuKdvG0depSc2MKKASINE\r
+ S+8hSHTgoXkO7kpDRV2b2i+HO3j8q3P0lEIm5xnoy7+wOEAlxc9DzKmNfrtDift0swLP\r
+ FWNf/zu8q5XSwhGhnhzupUvEUPJfFQCr6gWKHXSwyZCSnRb73okTEEpJz41AWtfDxCou\r
+ pOdQ==\r
+X-Gm-Message-State:\r
+ ALoCoQkhzykwUuZOiRHj4/L1cZHUcdvJfyympfRTsbSa80VpbUdvhtidHwUmbLNYHMrzTqg0rI6z\r
+X-Received: by 10.180.107.39 with SMTP id gz7mr10158673wib.82.1440860208383;\r
+ Sat, 29 Aug 2015 07:56:48 -0700 (PDT)\r
+Received: from localhost (mobile-access-bcee4f-131.dhcp.inet.fi.\r
+ [188.238.79.131])\r
+ by smtp.gmail.com with ESMTPSA id k2sm8933331wif.4.2015.08.29.07.56.47\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 29 Aug 2015 07:56:47 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC PATCH 5/5] cli: add support for deduplicating based on case\r
+ insensitive address\r
+Date: Sat, 29 Aug 2015 17:56:36 +0300\r
+Message-Id:\r
+ <b33abd9a0117628932b3f197f536cf1a58793779.1440859765.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1440859765.git.jani@nikula.org>\r
+References: <cover.1440859765.git.jani@nikula.org>\r
+In-Reply-To: <cover.1440859765.git.jani@nikula.org>\r
+References: <cover.1440859765.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 29 Aug 2015 14:57:12 -0000\r
+\r
+Consider all variants of an email address as one, and print the most\r
+common variant.\r
+---\r
+ notmuch-search.c | 33 ++++++++++++++++++++++++++++++++-\r
+ 1 file changed, 32 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 60311393198d..537298788ab9 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -447,6 +447,31 @@ _list_free_for_g_hash (void *ptr)\r
+     g_list_free_full (ptr, _talloc_free_for_g_hash);\r
+ }\r
\r
++/* Print the most common variant of a list of unique mailboxes, and\r
++ * conflate the counts. */\r
++static void\r
++print_popular (const search_context_t *ctx, GList *list)\r
++{\r
++    GList *l;\r
++    mailbox_t *mailbox = NULL, *m;\r
++    int max = 0;\r
++    int total = 0;\r
++\r
++    for (l = list; l; l = l->next) {\r
++      m = l->data;\r
++      total += m->count;\r
++      if (m->count > max) {\r
++          mailbox = m;\r
++          max = m->count;\r
++      }\r
++    }\r
++\r
++    /* The original count is no longer needed, so overwrite. */\r
++    mailbox->count = total;\r
++\r
++    print_mailbox (ctx, mailbox);\r
++}\r
++\r
+ static void\r
+ print_list_value (void *mailbox, void *context)\r
+ {\r
+@@ -456,7 +481,12 @@ print_list_value (void *mailbox, void *context)\r
+ static void\r
+ print_hash_value (unused (void *key), void *list, void *context)\r
+ {\r
+-    g_list_foreach (list, print_list_value, context);\r
++    const search_context_t *ctx = context;\r
++\r
++    if (ctx->dupe == 1)\r
++      print_popular (ctx, list);\r
++    else\r
++      g_list_foreach (list, print_list_value, context);\r
+ }\r
\r
+ static int\r
+@@ -817,6 +847,7 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])\r
+       { NOTMUCH_OPT_KEYWORD, &ctx->dupe, "deduplicate", 'x',\r
+         (notmuch_keyword_t []){ { "yes", -1 },\r
+                                 { "no", 0 },\r
++                                { "address", 1 },\r
+                                 { 0, 0 } } },\r
+       { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 },\r
+       { NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },\r
+-- \r
+2.1.4\r
+\r