Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 5d / 85ace5ebc985ee4bd7d1a8e5bb1a53948e59ce
1 Return-Path: <amdragon@mit.edu>\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 369E3431FAE\r
6         for <notmuch@notmuchmail.org>; Sun, 15 Jun 2014 19:41:18 -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: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 tbQvUzeh4zlR for <notmuch@notmuchmail.org>;\r
16         Sun, 15 Jun 2014 19:41:12 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
18         [18.7.68.35])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id AD41E431FCF\r
22         for <notmuch@notmuchmail.org>; Sun, 15 Jun 2014 19:40:58 -0700 (PDT)\r
23 X-AuditID: 12074423-f79916d000000c54-2f-539e59391b2c\r
24 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
25         (using TLS with cipher AES256-SHA (256/256 bits))\r
26         (Client did not present a certificate)\r
27         by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id 9D.6D.03156.9395E935; Sun, 15 Jun 2014 22:40:57 -0400 (EDT)\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
30         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s5G2et1S005170; \r
31         Sun, 15 Jun 2014 22:40:56 -0400\r
32 Received: from drake.dyndns.org\r
33         (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
34         [216.15.114.40]) (authenticated bits=0)\r
35         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
36         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s5G2es9g003414\r
37         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
38         Sun, 15 Jun 2014 22:40:55 -0400\r
39 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
40         (envelope-from <amdragon@mit.edu>)\r
41         id 1WwMqn-0004HF-Bb; Sun, 15 Jun 2014 22:40:49 -0400\r
42 From: Austin Clements <amdragon@MIT.EDU>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH 3/5] lib: Index name and address of from/to headers as a\r
45  phrase\r
46 Date: Sun, 15 Jun 2014 22:40:32 -0400\r
47 Message-Id: <1402886434-16169-4-git-send-email-amdragon@mit.edu>\r
48 X-Mailer: git-send-email 2.0.0.rc2\r
49 In-Reply-To: <1402886434-16169-1-git-send-email-amdragon@mit.edu>\r
50 References: <1402886434-16169-1-git-send-email-amdragon@mit.edu>\r
51 X-Brightmail-Tracker:\r
52  H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixCmqrGsZOS/YYNltU4vrN2cyOzB6PFt1\r
53         izmAMYrLJiU1J7MstUjfLoEro7fxLEvBJJmKJfvTGhg/i3UxcnJICJhILJpygBHCFpO4cG89\r
54         WxcjF4eQwGwmiYdPtjJCOBsZJbqP3GKCcO4wSSxYtxCqbC6jxL62VWD9bAIaEtv2LwezRQSk\r
55         JXbenc3axcjBwSygJvGnSwXEFBbwl1jWVgpSwSKgKvHy7WcWEJtXwEFix+Y1LBBXKEncuzIH\r
56         bAqngKPExNWn2EFsIaCaf2duME1g5F/AyLCKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI10wvN7NE\r
57         LzWldBMjKGTYXZR3MP45qHSIUYCDUYmHd4LjvGAh1sSy4srcQ4ySHExKorzMICG+pPyUyozE\r
58         4oz4otKc1OJDjBIczEoivPY+QDnelMTKqtSifJiUNAeLkjjvW2urYCGB9MSS1OzU1ILUIpis\r
59         DAeHkgTvgXCgRsGi1PTUirTMnBKENBMHJ8hwHqDh/0BqeIsLEnOLM9Mh8qcYFaXEeVeFASUE\r
60         QBIZpXlwvbCYfsUoDvSKMO93kHYeYDqA634FNJgJaPDNxbNABpckIqSkGhibHD2K0/TCz819\r
61         GL4gmnlr5ZkQgW+uVspudcFfnHsN4qyFzmeEpr5K40vad6y9Zocl77rP7w3/LP2bP8Py9es/\r
62         jDl7XMIkpFdLrdR+Y6W46LpB8f8Jfld0H3n8PcCv7K/1Yqa49fNfrmqH7koItwj9EtfmfuSg\r
63         wD5LsGbDZ8EvPUe3FF+4fliJpTgj0VCLuag4EQBN9Pk0xAIAAA==\r
64 X-BeenThere: notmuch@notmuchmail.org\r
65 X-Mailman-Version: 2.1.13\r
66 Precedence: list\r
67 List-Id: "Use and development of the notmuch mail system."\r
68         <notmuch.notmuchmail.org>\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
72 List-Post: <mailto:notmuch@notmuchmail.org>\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
75         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
76 X-List-Received-Date: Mon, 16 Jun 2014 02:41:18 -0000\r
77 \r
78 Previously, we indexed the name and address parts of from/to headers\r
79 with two calls to _notmuch_message_gen_terms.  In general, this\r
80 indicates that these parts are separate phrases.  However, because of\r
81 an implementation quirk, the two calls to _notmuch_message_gen_terms\r
82 generated adjacent term positions for the prefixed terms, which\r
83 happens to be the right thing to do in this case, but the wrong thing\r
84 to do for all other calls.  Furthermore, _notmuch_message_gen_terms\r
85 produced potentially overlapping term positions for the un-prefixed\r
86 copies of the terms, which is simply wrong.\r
87 \r
88 This change indexes both the name and address in a single call to\r
89 _notmuch_message_gen_terms, indicating that they should be part of a\r
90 single phrase.  This masks the problem with the un-prefixed terms\r
91 (fixing the two known-broken tests) and puts us in a position to fix\r
92 the unintentionally phrases generated by other calls to\r
93 _notmuch_message_gen_terms.\r
94 ---\r
95  lib/index.cc        | 24 ++++++++++--------------\r
96  test/T080-search.sh |  2 --\r
97  2 files changed, 10 insertions(+), 16 deletions(-)\r
98 \r
99 diff --git a/lib/index.cc b/lib/index.cc\r
100 index e1e2a38..1a2e63d 100644\r
101 --- a/lib/index.cc\r
102 +++ b/lib/index.cc\r
103 @@ -231,26 +231,22 @@ _index_address_mailbox (notmuch_message_t *message,\r
104                         InternetAddress *address)\r
105  {\r
106      InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address);\r
107 -    const char *name, *addr;\r
108 +    const char *name, *addr, *combined;\r
109      void *local = talloc_new (message);\r
110  \r
111      name = internet_address_get_name (address);\r
112      addr = internet_address_mailbox_get_addr (mailbox);\r
113  \r
114 -    /* In the absence of a name, we'll strip the part before the @\r
115 -     * from the address. */\r
116 -    if (! name) {\r
117 -       const char *at;\r
118 +    /* Combine the name and address and index them as a phrase. */\r
119 +    if (name && addr)\r
120 +       combined = talloc_asprintf (local, "%s %s", name, addr);\r
121 +    else if (name)\r
122 +       combined = name;\r
123 +    else\r
124 +       combined = addr;\r
125  \r
126 -       at = strchr (addr, '@');\r
127 -       if (at)\r
128 -           name = talloc_strndup (local, addr, at - addr);\r
129 -    }\r
130 -\r
131 -    if (name)\r
132 -       _notmuch_message_gen_terms (message, prefix_name, name);\r
133 -    if (addr)\r
134 -       _notmuch_message_gen_terms (message, prefix_name, addr);\r
135 +    if (combined)\r
136 +       _notmuch_message_gen_terms (message, prefix_name, combined);\r
137  \r
138      talloc_free (local);\r
139  }\r
140 diff --git a/test/T080-search.sh b/test/T080-search.sh\r
141 index 8ed5701..b63bf02 100755\r
142 --- a/test/T080-search.sh\r
143 +++ b/test/T080-search.sh\r
144 @@ -67,7 +67,6 @@ output=$(notmuch search 'from:"Search By From Name <test@example.com>"' | notmuc\r
145  test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)"\r
146  \r
147  test_begin_subtest "Search by from: without prefix (name and address)"\r
148 -test_subtest_known_broken\r
149  output=$(notmuch search '"Search By From Name <test@example.com>"' | notmuch_search_sanitize)\r
150  test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)"\r
151  \r
152 @@ -86,7 +85,6 @@ output=$(notmuch search 'to:"Search By To Name <test@example.com>"' | notmuch_se\r
153  test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)"\r
154  \r
155  test_begin_subtest "Search by to: without prefix (name and adress)"\r
156 -test_subtest_known_broken\r
157  output=$(notmuch search '"Search By To Name <test@example.com>"' | notmuch_search_sanitize)\r
158  test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)"\r
159  \r
160 -- \r
161 2.0.0.rc2\r
162 \r