[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / f0 / 0692e9a31fed49a76645ca40fb1f291f3f8f74
1 Return-Path: <BATV+bbc4756b788e67be553a+2433+infradead.org+hohndel@bombadil.srs.infradead.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 C938E4196F2\r
6         for <notmuch@notmuchmail.org>; Wed, 21 Apr 2010 22:04:41 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -4.2\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3] 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 n3q5qp4yKwbT for <notmuch@notmuchmail.org>;\r
16         Wed, 21 Apr 2010 22:04:40 -0700 (PDT)\r
17 Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 94394431FC1\r
19         for <notmuch@notmuchmail.org>; Wed, 21 Apr 2010 22:04:40 -0700 (PDT)\r
20 Received: from localhost ([::1] helo=x200.gr8dns.org)\r
21         by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux))\r
22         id 1O4oae-0001Wr-4D\r
23         for notmuch@notmuchmail.org; Thu, 22 Apr 2010 05:04:40 +0000\r
24 Received: by x200.gr8dns.org (Postfix, from userid 500)\r
25         id 7B4A9C0214; Wed, 21 Apr 2010 22:04:39 -0700 (PDT)\r
26 From: Dirk Hohndel <hohndel@infradead.org>\r
27 To: notmuch <notmuch@notmuchmail.org>\r
28 Subject: [PATCH] Clean up author display for some "Last, First" cases\r
29 Date: Wed, 21 Apr 2010 22:04:39 -0700\r
30 Message-ID: <m3633kyt5k.fsf@x200.gr8dns.org>\r
31 User-Agent: notmuch 0.2-52-ga28d2fe (Emacs 23.1.1/i386-redhat-linux-gnu)\r
32 MIME-Version: 1.0\r
33 Content-Type: text/plain; charset=us-ascii\r
34 X-SRS-Rewrite: SMTP reverse-path rewritten from <hohndel@infradead.org> by\r
35         bombadil.infradead.org See http://www.infradead.org/rpr.html\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.13\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40         <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Thu, 22 Apr 2010 05:04:41 -0000\r
49 \r
50 \r
51 We specifically check if this is one of these two patterns:\r
52  "Last, First" <first.last@company.com>\r
53  "Last, First MI" <first.mi.last@company.com>\r
54 If this is the case, we rewrite the author name in a more\r
55 reader friendly manner\r
56 \r
57 Signed-off-by: Dirk Hohndel <hohndel@infradead.org>\r
58 ---\r
59  lib/thread.cc |   51 +++++++++++++++++++++++++++++++++++++++++++++++++--\r
60  1 files changed, 49 insertions(+), 2 deletions(-)\r
61 \r
62 diff --git a/lib/thread.cc b/lib/thread.cc\r
63 index baa0d7f..7e72114 100644\r
64 --- a/lib/thread.cc\r
65 +++ b/lib/thread.cc\r
66 @@ -144,6 +144,51 @@ _thread_move_matched_author (notmuch_thread_t *thread,\r
67      return;\r
68  }\r
69  \r
70 +/* clean up the uggly "Lastname, Firstname" format that some mail systems\r
71 + * (most notably, Exchange) are creating to be "Firstname Lastname" \r
72 + * To make sure that we don't change other potential situations where a \r
73 + * comma is in the name, we check that we match one of these patterns\r
74 + * "Last, First" <first.last@company.com>\r
75 + * "Last, First MI" <first.mi.last@company.com>\r
76 + */\r
77 +char *\r
78 +_thread_cleanup_author (notmuch_thread_t *thread,\r
79 +                       const char *author, const char *from)\r
80 +{\r
81 +    char *cleanauthor,*testauthor;\r
82 +    const char *comma;\r
83 +    char *blank;\r
84 +    int fname,lname;\r
85 +\r
86 +    cleanauthor = talloc_strdup(thread, author);\r
87 +    if (cleanauthor == NULL)\r
88 +       return NULL;\r
89 +    comma = strchr(author,',');\r
90 +    if (comma) {\r
91 +       /* let's assemble what we think is the correct name */\r
92 +       lname = comma - author;\r
93 +       fname = strlen(author) - lname - 2;\r
94 +       strncpy(cleanauthor, comma + 2, fname);\r
95 +       *(cleanauthor+fname) = ' ';\r
96 +       strncpy(cleanauthor + fname + 1, author, lname);\r
97 +       *(cleanauthor+fname+1+lname) = '\0';\r
98 +       /* make a temporary copy and see if it matches the email */\r
99 +       testauthor = xstrdup(cleanauthor);\r
100 +       \r
101 +       blank=strchr(testauthor,' ');\r
102 +       while (blank != NULL) {\r
103 +           *blank = '.';\r
104 +           blank=strchr(testauthor,' ');\r
105 +       }\r
106 +       if (strcasestr(from, testauthor) == NULL)\r
107 +           /* we didn't identify this as part of the email address \r
108 +           * so let's punt and return the original author */\r
109 +           strcpy (cleanauthor, author);\r
110 +              \r
111 +    }\r
112 +    return cleanauthor;\r
113 +}\r
114 +\r
115  /* Add 'message' as a message that belongs to 'thread'.\r
116   *\r
117   * The 'thread' will talloc_steal the 'message' and hold onto a\r
118 @@ -158,6 +203,7 @@ _thread_add_message (notmuch_thread_t *thread,\r
119      InternetAddressList *list;\r
120      InternetAddress *address;\r
121      const char *from, *author;\r
122 +    char *cleanauthor;\r
123  \r
124      _notmuch_message_list_add_message (thread->message_list,\r
125                                        talloc_steal (thread, message));\r
126 @@ -178,8 +224,9 @@ _thread_add_message (notmuch_thread_t *thread,\r
127                 mailbox = INTERNET_ADDRESS_MAILBOX (address);\r
128                 author = internet_address_mailbox_get_addr (mailbox);\r
129             }\r
130 -           _thread_add_author (thread, author);\r
131 -           notmuch_message_set_author (message, author);\r
132 +           cleanauthor = _thread_cleanup_author (thread, author, from);\r
133 +           _thread_add_author (thread, cleanauthor);\r
134 +           notmuch_message_set_author (message, cleanauthor);\r
135         }\r
136         g_object_unref (G_OBJECT (list));\r
137      }\r
138 -- \r
139 1.6.6.1\r
140 \r
141 \r
142 -- \r
143 Dirk Hohndel\r
144 Intel Open Source Technology Center\r