[PATCH 2/2] emacs: add stash thread-id function to notmuch-search mode
[notmuch-archives.git] / 4d / 4f65657c6daf28f7c70a7de993e633284ea823
1 Return-Path: <BATV+28bf489b39c899822e75+2435+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 051634196F3\r
6         for <notmuch@notmuchmail.org>; Sat, 24 Apr 2010 09:57:43 -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 v-yGGIcrJ-7W for <notmuch@notmuchmail.org>;\r
16         Sat, 24 Apr 2010 09:57:41 -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 BDCB2431FC1\r
19         for <notmuch@notmuchmail.org>; Sat, 24 Apr 2010 09:57:41 -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 1O5ifl-00051T-93; Sat, 24 Apr 2010 16:57:41 +0000\r
23 Received: by x200.gr8dns.org (Postfix, from userid 500)\r
24         id 39E92CC593; Sat, 24 Apr 2010 09:57:40 -0700 (PDT)\r
25 From: Dirk Hohndel <hohndel@infradead.org>\r
26 To: Carl Worth <cworth@cworth.org>, notmuch <notmuch@notmuchmail.org>\r
27 Subject: Re: [PATCH] Clean up author display for some "Last, First" cases\r
28 In-Reply-To: <87mxwshnqp.fsf@yoom.home.cworth.org>\r
29 References: <m3633kyt5k.fsf@x200.gr8dns.org>\r
30         <87mxwshnqp.fsf@yoom.home.cworth.org>\r
31 User-Agent: Notmuch/0.2-187-g7c5f017 (http://notmuchmail.org) Emacs/23.1.1\r
32         (i386-redhat-linux-gnu)\r
33 Date: Sat, 24 Apr 2010 09:57:40 -0700\r
34 Message-ID: <m3bpd83i0r.fsf@x200.gr8dns.org>\r
35 MIME-Version: 1.0\r
36 Content-Type: text/plain; charset=us-ascii\r
37 X-SRS-Rewrite: SMTP reverse-path rewritten from <hohndel@infradead.org> by\r
38         bombadil.infradead.org See http://www.infradead.org/rpr.html\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Sat, 24 Apr 2010 16:57:43 -0000\r
52 \r
53 On Sat, 24 Apr 2010 08:30:22 -0700, Carl Worth <cworth@cworth.org> wrote:\r
54 > On Wed, 21 Apr 2010 22:04:39 -0700, Dirk Hohndel <hohndel@infradead.org> wrote:\r
55 > > +/* clean up the uggly "Lastname, Firstname" format that some mail systems\r
56 > > + * (most notably, Exchange) are creating to be "Firstname Lastname" \r
57 > > + * To make sure that we don't change other potential situations where a \r
58 > > + * comma is in the name, we check that we match one of these patterns\r
59 > > + * "Last, First" <first.last@company.com>\r
60 > > + * "Last, First MI" <first.mi.last@company.com>\r
61\r
62 > This is an interesting idea. We could make it a little more flexible by\r
63 > doing a regexp comparison of "first.*last" against the email address,\r
64 > (perhaps people have email addresses like carl_worth@example.com?)\r
65 \r
66 I'll look into that. We actually had some discussion about this on IRC\r
67 and I was thinking of taking this feature to a new level... something\r
68 like: \r
69 - by default we show names as they come in (least surprise)\r
70 - we offer to reverse Last, First\r
71 - we offer to shorten to FirstL\r
72 - we offer an alias map\r
73 So I could define that mail from "cworth@cworth.org" gets the author\r
74 listed as "cworth". Or as CarlW.\r
75 \r
76 > > +    char *cleanauthor,*testauthor;\r
77\r
78 > I'd much rather see an underscore separating two words in a single\r
79 > identifier, (so clean_author, test_author).\r
80 \r
81 Happy to comply to your preferences in the future\r
82 \r
83 > > +   /* let's assemble what we think is the correct name */\r
84 > > +   lname = comma - author;\r
85 > > +   fname = strlen(author) - lname - 2;\r
86 > > +   strncpy(cleanauthor, comma + 2, fname);\r
87 > > +   *(cleanauthor+fname) = ' ';\r
88 > > +   strncpy(cleanauthor + fname + 1, author, lname);\r
89 > > +   *(cleanauthor+fname+1+lname) = '\0';\r
90\r
91 > The comment above, ("what we think is the correct name"), didn't help me\r
92 > understand what the code is doing. And the code is hard enough to follow\r
93 > that I could really use some help. Something like:\r
94\r
95 > /* Break at comma and reverse: "Last, First etc." -> "First Last etc." */\r
96 \r
97 Ok, I'll try to be more explicit in documenting algorithms\r
98 \r
99 > Lots of little additions here and there so plenty of chance for an\r
100 > off-by-one. Do we have a test case for this yet?\r
101 \r
102 Nope. Will do.\r
103 \r
104 > > +   /* make a temporary copy and see if it matches the email */\r
105 > > +   testauthor = xstrdup(cleanauthor);\r
106\r
107 > It would be preferable to use talloc functions consistently. (Existing\r
108 > occurrences of xstrdup in the code base are for the sake of\r
109 > talloc-unfriendly glib data structures like GHashTable.)\r
110\r
111 > As is, testauthor is leaking.\r
112 \r
113 Oops.\r
114 \r
115 /D\r