Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / c2 / 1e5262f6512bc6f46ba596031c82a5c1f63450
1 Return-Path: <mi@kismala.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 6F665431FD0\r
6         for <notmuch@notmuchmail.org>; Tue, 12 Jul 2011 18:55:59 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 L1M1zKDnSHEL for <notmuch@notmuchmail.org>;\r
16         Tue, 12 Jul 2011 18:55:56 -0700 (PDT)\r
17 Received: from imarko.xen.prgmr.com (imarko.xen.prgmr.com [72.13.95.244])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id D9FFD431FB6\r
21         for <notmuch@notmuchmail.org>; Tue, 12 Jul 2011 18:55:56 -0700 (PDT)\r
22 Received: from localhost ([127.0.0.1] helo=zsu.kismala.com)\r
23         by imarko.xen.prgmr.com with esmtp (Exim 4.75)\r
24         (envelope-from <mi@kismala.com>)\r
25         id 1Qgog7-0003rC-Va; Tue, 12 Jul 2011 18:55:56 -0700\r
26 From: Istvan Marko <notmuch@kismala.com>\r
27 To: Austin Clements <amdragon@mit.edu>\r
28 Subject: Re: Slowness (search opens every email file?)\r
29 References: <20110711190721.GA5386@compy.jasonwoof.org>\r
30         <CAH-f9WtBHJ8bL6eWoSNrTs=jkrOYYCuWEVVPDUt_iCw0dKcZbw@mail.gmail.com>\r
31         <20110712202459.GB15019@compy.jasonwoof.org>\r
32         <CAH-f9WujE8s3DK1PyDGf3kdWLx2qvPx=dp7WZ-z_v8prqauvug@mail.gmail.com>\r
33 Date: Tue, 12 Jul 2011 18:55:55 -0700\r
34 In-Reply-To:\r
35  <CAH-f9WujE8s3DK1PyDGf3kdWLx2qvPx=dp7WZ-z_v8prqauvug@mail.gmail.com>   (Austin\r
36  Clements's message of "Tue, 12 Jul 2011 20:50:56 -0400")\r
37 Message-ID: <m3pqlfhrkk.fsf@zsu.kismala.com>\r
38 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)\r
39 MIME-Version: 1.0\r
40 Content-Type: multipart/mixed; boundary="=-=-="\r
41 Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Wed, 13 Jul 2011 01:55:59 -0000\r
55 \r
56 --=-=-=\r
57 Content-Type: text/plain\r
58 \r
59 Austin Clements <amdragon-3s7WtUTddSA@public.gmane.org> writes:\r
60 \r
61 > Istvan, did you make any progress on this patch since the last\r
62 > version?  I seem to recall it just needed general cleanup (code style\r
63 > and such) and a better answer for backwards compatibility (the\r
64 > unfortunate " " thing).\r
65 \r
66 I have been using the version that encodes empty headers to " " but\r
67 another way to handle this is to simply not set a VALUE for empty\r
68 headers and then fall back to the original parsing method for these\r
69 messages. Emails without from/subject/message-id headers are not very\r
70 common so perhaps this is a good compromise.\r
71 \r
72 Below is the patch without the " " hack.\r
73 \r
74 \r
75 --=-=-=\r
76 Content-Type: text/x-patch\r
77 Content-Disposition: inline; filename=notmuch-value2.patch\r
78 \r
79 diff --git a/lib/database.cc b/lib/database.cc\r
80 index 9c2f4ec..63a15bb 100644\r
81 --- a/lib/database.cc\r
82 +++ b/lib/database.cc\r
83 @@ -1654,7 +1654,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,\r
84                 goto DONE;\r
85  \r
86             date = notmuch_message_file_get_header (message_file, "date");\r
87 -           _notmuch_message_set_date (message, date);\r
88 +           _notmuch_message_set_header_values (message, date, from, subject);\r
89  \r
90             _notmuch_message_index_file (message, filename);\r
91         } else {\r
92 diff --git a/lib/message.cc b/lib/message.cc\r
93 index d993cde..48a31f5 100644\r
94 --- a/lib/message.cc\r
95 +++ b/lib/message.cc\r
96 @@ -410,6 +410,20 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message)\r
97  const char *\r
98  notmuch_message_get_header (notmuch_message_t *message, const char *header)\r
99  {\r
100 +    std::string value;\r
101 +\r
102 +    // fetch header from the appropriate xapian value field if available\r
103 +    if (strcmp(header,"from") == 0)\r
104 +        value=message->doc.get_value(NOTMUCH_VALUE_FROM);\r
105 +    else if (strcmp(header,"subject") == 0)\r
106 +        value=message->doc.get_value (NOTMUCH_VALUE_SUBJECT);\r
107 +    else if (strcmp(header,"message-id") == 0)\r
108 +       value=message->doc.get_value (NOTMUCH_VALUE_MESSAGE_ID);\r
109 +\r
110 +    if (!value.empty())\r
111 +       return talloc_strdup (message, value.c_str ());\r
112 +\r
113 +    // otherwise fall back to parsing the file\r
114      _notmuch_message_ensure_message_file (message);\r
115      if (message->message_file == NULL)\r
116         return NULL;\r
117 @@ -785,8 +799,10 @@ notmuch_message_set_author (notmuch_message_t *message,\r
118  }\r
119  \r
120  void\r
121 -_notmuch_message_set_date (notmuch_message_t *message,\r
122 -                          const char *date)\r
123 +_notmuch_message_set_header_values (notmuch_message_t *message,\r
124 +                                   const char *date,\r
125 +                                   const char *from,\r
126 +                                   const char *subject)\r
127  {\r
128      time_t time_value;\r
129  \r
130 @@ -799,6 +815,8 @@ _notmuch_message_set_date (notmuch_message_t *message,\r
131  \r
132      message->doc.add_value (NOTMUCH_VALUE_TIMESTAMP,\r
133                             Xapian::sortable_serialise (time_value));\r
134 +    message->doc.add_value (NOTMUCH_VALUE_FROM, from);\r
135 +    message->doc.add_value (NOTMUCH_VALUE_SUBJECT, subject);\r
136  }\r
137  \r
138  /* Synchronize changes made to message->doc out into the database. */\r
139 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
140 index 02e24ee..2e91afd 100644\r
141 --- a/lib/notmuch-private.h\r
142 +++ b/lib/notmuch-private.h\r
143 @@ -111,7 +111,9 @@ _internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2);\r
144  \r
145  typedef enum {\r
146      NOTMUCH_VALUE_TIMESTAMP = 0,\r
147 -    NOTMUCH_VALUE_MESSAGE_ID\r
148 +    NOTMUCH_VALUE_MESSAGE_ID,\r
149 +    NOTMUCH_VALUE_FROM,\r
150 +    NOTMUCH_VALUE_SUBJECT\r
151  } notmuch_value_t;\r
152  \r
153  /* Xapian (with flint backend) complains if we provide a term longer\r
154 @@ -287,9 +289,10 @@ void\r
155  _notmuch_message_ensure_thread_id (notmuch_message_t *message);\r
156  \r
157  void\r
158 -_notmuch_message_set_date (notmuch_message_t *message,\r
159 -                          const char *date);\r
160 -\r
161 +_notmuch_message_set_header_values (notmuch_message_t *message,\r
162 +                                   const char *date,\r
163 +                                   const char *from,\r
164 +                                   const char *subject);\r
165  void\r
166  _notmuch_message_sync (notmuch_message_t *message);\r
167  \r
168 \r
169 --=-=-=\r
170 Content-Type: text/plain\r
171 \r
172 \r
173 -- \r
174         Istvan\r
175 \r
176 --=-=-=--\r