1 Return-Path: <hohndel@gr8dns.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 olra.theworths.org (Postfix) with ESMTP id 52E7A4196F5
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Apr 2010 11:21:21 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9] autolearn=ham
\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 eeqOwvzLE3W5 for <notmuch@notmuchmail.org>;
\r
16 Sat, 24 Apr 2010 11:21:19 -0700 (PDT)
\r
17 Received: from mail.hohndel.org (mail.hohndel.org [65.23.157.147])
\r
18 by olra.theworths.org (Postfix) with ESMTP id D0950418C36
\r
19 for <notmuch@notmuchmail.org>; Sat, 24 Apr 2010 11:21:15 -0700 (PDT)
\r
20 Received: by mail.hohndel.org (Postfix, from userid 112)
\r
21 id 89A08340FA; Sat, 24 Apr 2010 14:21:15 -0400 (EDT)
\r
22 Received: from x200.gr8dns.org (unknown [65.23.157.147])
\r
23 by mail.hohndel.org (Postfix) with ESMTP id C117D340FE;
\r
24 Sat, 24 Apr 2010 14:21:01 -0400 (EDT)
\r
25 Received: by x200.gr8dns.org (Postfix, from userid 500)
\r
26 id 1CD92CC5A0; Sat, 24 Apr 2010 11:21:01 -0700 (PDT)
\r
27 From: Dirk Hohndel <hohndel@infradead.org>
\r
28 To: <notmuch@notmuchmail.org>
\r
29 Subject: [PATCH 5/5] Simple attempt to display author names in a friendlier
\r
31 Date: Sat, 24 Apr 2010 11:20:57 -0700
\r
32 Message-Id: <1272133257-15708-6-git-send-email-hohndel@infradead.org>
\r
33 X-Mailer: git-send-email 1.6.6.1
\r
34 In-Reply-To: <1272133257-15708-5-git-send-email-hohndel@infradead.org>
\r
35 References: <1272133257-15708-1-git-send-email-hohndel@infradead.org>
\r
36 <1272133257-15708-2-git-send-email-hohndel@infradead.org>
\r
37 <1272133257-15708-3-git-send-email-hohndel@infradead.org>
\r
38 <1272133257-15708-4-git-send-email-hohndel@infradead.org>
\r
39 <1272133257-15708-5-git-send-email-hohndel@infradead.org>
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\r
43 List-Id: "Use and development of the notmuch mail system."
\r
44 <notmuch.notmuchmail.org>
\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
48 List-Post: <mailto:notmuch@notmuchmail.org>
\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
52 X-List-Received-Date: Sat, 24 Apr 2010 18:21:22 -0000
\r
54 This patch only addresses the typical Outlook/Exchange case
\r
55 where we have "Last, First" <first.last@company.com> or
\r
56 "Last, First MI" <first.mi.last@company.com>.
\r
58 In the future we should be more fexible as to the formats
\r
59 we recognize, but for now we address this one as it is the
\r
60 Exchange default setting and therefore the most common one.
\r
62 Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
\r
64 lib/thread.cc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
\r
65 1 files changed, 49 insertions(+), 2 deletions(-)
\r
67 diff --git a/lib/thread.cc b/lib/thread.cc
\r
68 index c80bb26..b8be3e1 100644
\r
71 @@ -147,6 +147,51 @@ _thread_move_matched_author (notmuch_thread_t *thread,
\r
75 +/* clean up the uggly "Lastname, Firstname" format that some mail systems
\r
76 + * (most notably, Exchange) are creating to be "Firstname Lastname"
\r
77 + * To make sure that we don't change other potential situations where a
\r
78 + * comma is in the name, we check that we match one of these patterns
\r
79 + * "Last, First" <first.last@company.com>
\r
80 + * "Last, First MI" <first.mi.last@company.com>
\r
83 +_thread_cleanup_author (notmuch_thread_t *thread,
\r
84 + const char *author, const char *from)
\r
86 + char *clean_author,*test_author;
\r
87 + const char *comma;
\r
91 + clean_author = talloc_strdup(thread, author);
\r
92 + if (clean_author == NULL)
\r
94 + comma = strchr(author,',');
\r
96 + /* let's assemble what we think is the correct name */
\r
97 + lname = comma - author;
\r
98 + fname = strlen(author) - lname - 2;
\r
99 + strncpy(clean_author, comma + 2, fname);
\r
100 + *(clean_author+fname) = ' ';
\r
101 + strncpy(clean_author + fname + 1, author, lname);
\r
102 + *(clean_author+fname+1+lname) = '\0';
\r
103 + /* make a temporary copy and see if it matches the email */
\r
104 + test_author = talloc_strdup(thread,clean_author);
\r
106 + blank=strchr(test_author,' ');
\r
107 + while (blank != NULL) {
\r
109 + blank=strchr(test_author,' ');
\r
111 + if (strcasestr(from, test_author) == NULL)
\r
112 + /* we didn't identify this as part of the email address
\r
113 + * so let's punt and return the original author */
\r
114 + strcpy (clean_author, author);
\r
117 + return clean_author;
\r
120 /* Add 'message' as a message that belongs to 'thread'.
\r
122 * The 'thread' will talloc_steal the 'message' and hold onto a
\r
123 @@ -161,6 +206,7 @@ _thread_add_message (notmuch_thread_t *thread,
\r
124 InternetAddressList *list = NULL;
\r
125 InternetAddress *address;
\r
126 const char *from, *author;
\r
127 + char *clean_author;
\r
129 _notmuch_message_list_add_message (thread->message_list,
\r
130 talloc_steal (thread, message));
\r
131 @@ -183,8 +229,9 @@ _thread_add_message (notmuch_thread_t *thread,
\r
132 mailbox = INTERNET_ADDRESS_MAILBOX (address);
\r
133 author = internet_address_mailbox_get_addr (mailbox);
\r
135 - _thread_add_author (thread, author);
\r
136 - notmuch_message_set_author (message, author);
\r
137 + clean_author = _thread_cleanup_author (thread, author, from);
\r
138 + _thread_add_author (thread, clean_author);
\r
139 + notmuch_message_set_author (message, clean_author);
\r
141 g_object_unref (G_OBJECT (list));
\r