Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 2c / 07a1b325a657c95e64e612720d1d94ffde82fb
1 Return-Path: <m.walters@qmul.ac.uk>\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 144B0431FB6\r
6         for <notmuch@notmuchmail.org>; Tue, 21 Oct 2014 16:32:36 -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: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id orDRXjNKJbOW for <notmuch@notmuchmail.org>;\r
17         Tue, 21 Oct 2014 16:32:28 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\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 1F57D431FAE\r
22         for <notmuch@notmuchmail.org>; Tue, 21 Oct 2014 16:32:28 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1XgiuL-0002un-SR; Wed, 22 Oct 2014 00:32:26 +0100\r
27 Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1XgiuL-0006Lw-AQ; Wed, 22 Oct 2014 00:32:05 +0100\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Austin Clements <aclements@csail.mit.edu>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH 00/12] Add ghost messages and fix thread linking\r
34 In-Reply-To: <1412637438-4821-1-git-send-email-aclements@csail.mit.edu>\r
35 References: <1412637438-4821-1-git-send-email-aclements@csail.mit.edu>\r
36 User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1\r
37         (x86_64-pc-linux-gnu)\r
38 Date: Wed, 22 Oct 2014 00:32:03 +0100\r
39 Message-ID: <8761fdrocs.fsf@qmul.ac.uk>\r
40 MIME-Version: 1.0\r
41 Content-Type: text/plain; charset=us-ascii\r
42 X-Sender-Host-Address: 87.81.223.162\r
43 X-QM-Geographic: According to ripencc,\r
44         this message was delivered by a machine in Britain (UK) (GB).\r
45 X-QM-SPAM-Info: Sender has good ham record.  :)\r
46 X-QM-Body-MD5: e0f4863151f97d6debbe100bbbb22c5d (of first 20000 bytes)\r
47 X-SpamAssassin-Score: -0.1\r
48 X-SpamAssassin-SpamBar: /\r
49 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
50         determine if it is\r
51         spam. We require at least 5.0 points to mark a message as spam.\r
52         This message scored -0.1 points.\r
53         Summary of the scoring: \r
54         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
55         provider *      (markwalters1009[at]gmail.com)\r
56         * -0.1 AWL AWL: From: address is in the auto white-list\r
57 X-QM-Scan-Virus: ClamAV says the message is clean\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Tue, 21 Oct 2014 23:32:36 -0000\r
71 \r
72 \r
73 On Tue, 07 Oct 2014, Austin Clements <aclements@csail.mit.edu> wrote:\r
74 > This is v2 of the\r
75 > id:1412345958-8278-1-git-send-email-aclements@csail.mit.edu.  This\r
76 > adds some comments and clarifies some code as suggested by David.\r
77 > Patch 6 is new in v2 and adds some bit-twiddling macros for clarity\r
78 > and robustness in later patches.\r
79 \r
80 Ok I have now been through the whole series and am basically happy with\r
81 it (I sent some trivial comments separately). The tests pass, and my\r
82 database still seems to work.\r
83 \r
84 So +1 from me but it is code I am not very familiar with so it's a\r
85 slightly more cautious +1 than usual.\r
86 \r
87 Best wishes\r
88 \r
89 Mark\r
90 \r
91 \r
92 >\r
93 > The diff from v1 is below.\r
94 >\r
95 > diff --git a/lib/database.cc b/lib/database.cc\r
96 > index 4655f59..6e51a72 100644\r
97 > --- a/lib/database.cc\r
98 > +++ b/lib/database.cc\r
99 > @@ -1277,6 +1277,8 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
100 >           ++total;\r
101 >      }\r
102 >      if (new_features & NOTMUCH_FEATURE_GHOSTS) {\r
103 > +     /* The ghost message upgrade converts all thread_id_*\r
104 > +      * metadata values into ghost message documents. */\r
105 >       t_end = db->metadata_keys_end ("thread_id_");\r
106 >       for (t = db->metadata_keys_begin ("thread_id_"); t != t_end; ++t)\r
107 >           ++total;\r
108 > diff --git a/lib/message.cc b/lib/message.cc\r
109 > index ad832cf..a7a13cc 100644\r
110 > --- a/lib/message.cc\r
111 > +++ b/lib/message.cc\r
112 > @@ -344,15 +344,17 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message)\r
113 >  \r
114 >      /* Get document type */\r
115 >      assert (strcmp (id_prefix, type_prefix) < 0);\r
116 > -    if (! (message->lazy_flags & (1 << NOTMUCH_MESSAGE_FLAG_GHOST))) {\r
117 > +    if (! NOTMUCH_TEST_BIT (message->lazy_flags, NOTMUCH_MESSAGE_FLAG_GHOST)) {\r
118 >       i.skip_to (type_prefix);\r
119 > +     /* "T" is the prefix "type" fields.  See\r
120 > +      * BOOLEAN_PREFIX_INTERNAL. */\r
121 >       if (*i == "Tmail")\r
122 > -         message->flags &= ~(1 << NOTMUCH_MESSAGE_FLAG_GHOST);\r
123 > +         NOTMUCH_CLEAR_BIT (&message->flags, NOTMUCH_MESSAGE_FLAG_GHOST);\r
124 >       else if (*i == "Tghost")\r
125 > -         message->flags |= (1 << NOTMUCH_MESSAGE_FLAG_GHOST);\r
126 > +         NOTMUCH_SET_BIT (&message->flags, NOTMUCH_MESSAGE_FLAG_GHOST);\r
127 >       else\r
128 >           INTERNAL_ERROR ("Message without type term");\r
129 > -     message->lazy_flags |= (1 << NOTMUCH_MESSAGE_FLAG_GHOST);\r
130 > +     NOTMUCH_SET_BIT (&message->lazy_flags, NOTMUCH_MESSAGE_FLAG_GHOST);\r
131 >      }\r
132 >  \r
133 >      /* Get filename list.  Here we get only the terms.  We lazily\r
134 > @@ -390,8 +392,8 @@ _notmuch_message_invalidate_metadata (notmuch_message_t *message,\r
135 >      }\r
136 >  \r
137 >      if (strcmp ("type", prefix_name) == 0) {\r
138 > -     message->flags &= ~(1 << NOTMUCH_MESSAGE_FLAG_GHOST);\r
139 > -     message->lazy_flags &= ~(1 << NOTMUCH_MESSAGE_FLAG_GHOST);\r
140 > +     NOTMUCH_CLEAR_BIT (&message->flags, NOTMUCH_MESSAGE_FLAG_GHOST);\r
141 > +     NOTMUCH_CLEAR_BIT (&message->lazy_flags, NOTMUCH_MESSAGE_FLAG_GHOST);\r
142 >      }\r
143 >  \r
144 >      if (strcmp ("file-direntry", prefix_name) == 0) {\r
145 > @@ -893,10 +895,10 @@ notmuch_message_get_flag (notmuch_message_t *message,\r
146 >                         notmuch_message_flag_t flag)\r
147 >  {\r
148 >      if (flag == NOTMUCH_MESSAGE_FLAG_GHOST &&\r
149 > -     ! (message->lazy_flags & (1 << flag)))\r
150 > +     ! NOTMUCH_TEST_BIT (message->lazy_flags, flag))\r
151 >       _notmuch_message_ensure_metadata (message);\r
152 >  \r
153 > -    return message->flags & (1 << flag);\r
154 > +    return NOTMUCH_TEST_BIT (message->flags, flag);\r
155 >  }\r
156 >  \r
157 >  void\r
158 > @@ -904,10 +906,10 @@ notmuch_message_set_flag (notmuch_message_t *message,\r
159 >                         notmuch_message_flag_t flag, notmuch_bool_t enable)\r
160 >  {\r
161 >      if (enable)\r
162 > -     message->flags |= (1 << flag);\r
163 > +     NOTMUCH_SET_BIT (&message->flags, flag);\r
164 >      else\r
165 > -     message->flags &= ~(1 << flag);\r
166 > -    message->lazy_flags |= (1 << flag);\r
167 > +     NOTMUCH_CLEAR_BIT (&message->flags, flag);\r
168 > +    NOTMUCH_SET_BIT (&message->lazy_flags, flag);\r
169 >  }\r
170 >  \r
171 >  time_t\r
172 > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
173 > index 2fbd38e..2f43c1d 100644\r
174 > --- a/lib/notmuch-private.h\r
175 > +++ b/lib/notmuch-private.h\r
176 > @@ -63,6 +63,17 @@ NOTMUCH_BEGIN_DECLS\r
177 >  #define STRNCMP_LITERAL(var, literal) \\r
178 >      strncmp ((var), (literal), sizeof (literal) - 1)\r
179 >  \r
180 > +/* Robust bit test/set/reset macros */\r
181 > +#define NOTMUCH_TEST_BIT(val, bit) \\r
182 > +    ((bit < 0 || bit >= CHAR_BIT * sizeof (unsigned long long)) ? 0  \\r
183 > +     : !!((val) & (1ull << bit)))\r
184 > +#define NOTMUCH_SET_BIT(valp, bit) \\r
185 > +    ((bit < 0 || bit >= CHAR_BIT * sizeof (unsigned long long)) ? *(valp) \\r
186 > +     : (*(valp) |= (1ull << bit)))\r
187 > +#define NOTMUCH_CLEAR_BIT(valp,  bit) \\r
188 > +    ((bit < 0 || bit >= CHAR_BIT * sizeof (unsigned long long)) ? *(valp) \\r
189 > +     : (*(valp) &= ~(1ull << bit)))\r
190 > +\r
191 >  #define unused(x) x __attribute__ ((unused))\r
192 >  \r
193 >  #ifdef __cplusplus\r
194 >\r
195 >\r
196 > _______________________________________________\r
197 > notmuch mailing list\r
198 > notmuch@notmuchmail.org\r
199 > http://notmuchmail.org/mailman/listinfo/notmuch\r