1 Return-Path: <felipe.contreras@gmail.com>
\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 83CE7417341
\r
6 for <notmuch@notmuchmail.org>; Sat, 5 Jun 2010 04:13:09 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
\r
13 DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001] autolearn=ham
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id Jnr2Au0Du5Nt for <notmuch@notmuchmail.org>;
\r
17 Sat, 5 Jun 2010 04:12:56 -0700 (PDT)
\r
18 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com
\r
20 by olra.theworths.org (Postfix) with ESMTP id 9524C4196F0
\r
21 for <notmuch@notmuchmail.org>; Sat, 5 Jun 2010 04:12:56 -0700 (PDT)
\r
22 Received: by fxm4 with SMTP id 4so284086fxm.26
\r
23 for <notmuch@notmuchmail.org>; Sat, 05 Jun 2010 04:12:54 -0700 (PDT)
\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
25 h=domainkey-signature:received:received:from:to:cc:subject:date
\r
26 :message-id:x-mailer:in-reply-to:references;
\r
27 bh=6KFUk6efsr41pCVz8d/9dGtyw+zvTodllU9PMNfN6Ns=;
\r
28 b=UrDQ60XjOovuZZaY7DNKWd3aAMWd2EP76bmWV/PDTkv+0DjfdjEny0CssS2WAnz2+9
\r
29 6qqUfqaD0OuASCf1799RIcS7gHtasCM9NwLcX/rUHbxthzLNX5ZTiPWtffaOvqW06gaD
\r
30 iNYpMUzk0Vg1GPqBXFiWcUrbJIG0YhjnMisNs=
\r
31 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
\r
32 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
33 b=Wuid/t8xZr/ofewepp/qZjDZta5UMTkUcCrrmORnyY8aX7QBW1j5XPa+sWGi0awLL/
\r
34 5qJH/IU4NufVSqPMr6hyWNL8If6LM87Dun/gFSJs40IMaUr6WqTd5pS25qEBhFDT8g0O
\r
35 //3beL8v9S9whgkAP5pttny9iAR4h9xieAgAg=
\r
36 Received: by 10.204.4.66 with SMTP id 2mr4849213bkq.214.1275736374242;
\r
37 Sat, 05 Jun 2010 04:12:54 -0700 (PDT)
\r
38 Received: from localhost (a91-153-253-80.elisa-laajakaista.fi [91.153.253.80])
\r
39 by mx.google.com with ESMTPS id v3sm9579053bkz.22.2010.06.05.04.12.53
\r
40 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
41 Sat, 05 Jun 2010 04:12:53 -0700 (PDT)
\r
42 From: Felipe Contreras <felipe.contreras@gmail.com>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH 1/9] thread: really clean authors
\r
45 Date: Sat, 5 Jun 2010 14:12:34 +0300
\r
46 Message-Id: <1275736362-22771-2-git-send-email-felipe.contreras@gmail.com>
\r
47 X-Mailer: git-send-email 1.7.1
\r
48 In-Reply-To: <1275736362-22771-1-git-send-email-felipe.contreras@gmail.com>
\r
49 References: <1275736362-22771-1-git-send-email-felipe.contreras@gmail.com>
\r
50 Cc: Bart Trojanowski <bart@jukie.net>
\r
51 X-BeenThere: notmuch@notmuchmail.org
\r
52 X-Mailman-Version: 2.1.13
\r
54 List-Id: "Use and development of the notmuch mail system."
\r
55 <notmuch.notmuchmail.org>
\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
59 List-Post: <mailto:notmuch@notmuchmail.org>
\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
63 X-List-Received-Date: Sat, 05 Jun 2010 11:13:09 -0000
\r
65 To show the thread, usually 'foo' is enough from "Foo Bar
\r
66 <foo.bar@mail.com>", specially since the authors field is too small
\r
69 Gmail does something similar: "Foo (2), John (3)".
\r
71 Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
\r
73 lib/thread.cc | 38 +++++---------------------------------
\r
74 1 files changed, 5 insertions(+), 33 deletions(-)
\r
76 diff --git a/lib/thread.cc b/lib/thread.cc
\r
77 index 13872d4..6a445b5 100644
\r
80 @@ -151,44 +151,16 @@ char *
\r
81 _thread_cleanup_author (notmuch_thread_t *thread,
\r
82 const char *author, const char *from)
\r
84 - char *clean_author,*test_author;
\r
85 - const char *comma;
\r
88 + char *clean_author;
\r
89 + const char *begin,*end;
\r
93 - clean_author = talloc_strdup(thread, author);
\r
94 + begin = strchr (from, '<') + 1;
\r
95 + end = strchr (begin, '>');
\r
96 + clean_author = talloc_strndup (thread, begin, end - begin);
\r
97 if (clean_author == NULL)
\r
99 - /* check if there's a comma in the name and that there's a
\r
100 - * component of the name behind it (so the name doesn't end with
\r
101 - * the comma - in which case the string that strchr finds is just
\r
102 - * one character long ",\0").
\r
103 - * Otherwise just return the copy of the original author name that
\r
105 - comma = strchr(author,',');
\r
106 - if (comma && strlen(comma) > 1) {
\r
107 - /* let's assemble what we think is the correct name */
\r
108 - lname = comma - author;
\r
109 - fname = strlen(author) - lname - 2;
\r
110 - strncpy(clean_author, comma + 2, fname);
\r
111 - *(clean_author+fname) = ' ';
\r
112 - strncpy(clean_author + fname + 1, author, lname);
\r
113 - *(clean_author+fname+1+lname) = '\0';
\r
114 - /* make a temporary copy and see if it matches the email */
\r
115 - test_author = talloc_strdup(thread,clean_author);
\r
117 - blank=strchr(test_author,' ');
\r
118 - while (blank != NULL) {
\r
120 - blank=strchr(test_author,' ');
\r
122 - if (strcasestr(from, test_author) == NULL)
\r
123 - /* we didn't identify this as part of the email address
\r
124 - * so let's punt and return the original author */
\r
125 - strcpy (clean_author, author);
\r
127 return clean_author;
\r