Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / dd / 510fb7f4fae8618a5f2141c7a90b843df3bf2e
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 3FC5D431FBD\r
6         for <notmuch@notmuchmail.org>; Thu,  2 Feb 2012 15:18:40 -0800 (PST)\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 S9DcaozIHjMk for <notmuch@notmuchmail.org>;\r
17         Thu,  2 Feb 2012 15:18:39 -0800 (PST)\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 24F0E431FAF\r
22         for <notmuch@notmuchmail.org>; Thu,  2 Feb 2012 15:18:39 -0800 (PST)\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 1Rt5vJ-0001vN-6i; Thu, 02 Feb 2012 23:18:37 +0000\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1Rt5vI-0002rG-M0; Thu, 02 Feb 2012 23:18:36 +0000\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org, amdragon@MIT.EDU\r
34 Subject: Re: [PATCH v4 08/11] cli: Make notmuch-show respect excludes.\r
35 In-Reply-To: <87aa50ygkk.fsf@nikula.org>\r
36 References: <874nv9rv79.fsf@qmul.ac.uk>\r
37         <1328204619-25046-8-git-send-email-markwalters1009@gmail.com>\r
38         <87haz8yjkv.fsf@nikula.org> <87y5skrhi9.fsf@qmul.ac.uk>\r
39         <87aa50ygkk.fsf@nikula.org>\r
40 User-Agent: Notmuch/0.11+140~gb5e1cf0 (http://notmuchmail.org) Emacs/23.2.1\r
41         (i486-pc-linux-gnu)\r
42 Date: Thu, 02 Feb 2012 23:19:45 +0000\r
43 Message-ID: <87vcnorffy.fsf@qmul.ac.uk>\r
44 MIME-Version: 1.0\r
45 Content-Type: text/plain; charset=us-ascii\r
46 X-Sender-Host-Address: 94.192.233.223\r
47 X-QM-SPAM-Info: Sender has good ham record.  :)\r
48 X-QM-Body-MD5: 76618db4bb00db037f1fa2956c6f31b1 (of first 20000 bytes)\r
49 X-SpamAssassin-Score: -1.8\r
50 X-SpamAssassin-SpamBar: -\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
52         determine if it is\r
53         spam. We require at least 5.0 points to mark a message as spam.\r
54         This message scored -1.8 points.\r
55         Summary of the scoring: \r
56         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
57         *      medium trust\r
58         *      [138.37.6.40 listed in list.dnswl.org]\r
59         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
60         provider *      (markwalters1009[at]gmail.com)\r
61         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
62         *      domain\r
63         *  0.5 AWL AWL: From: address is in the auto white-list\r
64 X-QM-Scan-Virus: ClamAV says the message is clean\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Thu, 02 Feb 2012 23:18:40 -0000\r
78 \r
79 On Fri, 03 Feb 2012 01:13:31 +0200, Jani Nikula <jani@nikula.org> wrote:\r
80 > On Thu, 02 Feb 2012 22:35:10 +0000, Mark Walters <markwalters1009@gmail.com> wrote:\r
81 > > \r
82 > > On Fri, 03 Feb 2012 00:08:32 +0200, Jani Nikula <jani@nikula.org> wrote:\r
83 > > > On Thu,  2 Feb 2012 17:43:36 +0000, Mark Walters <markwalters1009@gmail.com> wrote:\r
84 > > > > This adds the excludes to notmuch-show.c. We do not exclude when only\r
85 > > > > a single message (or part) is requested. notmuch-show will output the\r
86 > > > > exclude information when either text or json format is requested. As\r
87 > > > > this changes the output from notmuch-show it breaks many tests (in a\r
88 > > > > trivial and expected fashion).\r
89 > > > > ---\r
90 > > > >  notmuch-show.c |   24 ++++++++++++++++++++----\r
91 > > > >  1 files changed, 20 insertions(+), 4 deletions(-)\r
92 > > > > \r
93 > > > > diff --git a/notmuch-show.c b/notmuch-show.c\r
94 > > > > index dec799c..108f13b 100644\r
95 > > > > --- a/notmuch-show.c\r
96 > > > > +++ b/notmuch-show.c\r
97 > > > > @@ -193,10 +193,11 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)\r
98 > > > >  static void\r
99 > > > >  format_message_text (unused (const void *ctx), notmuch_message_t *message, int indent)\r
100 > > > >  {\r
101 > > > > -    printf ("id:%s depth:%d match:%d filename:%s\n",\r
102 > > > > +    printf ("id:%s depth:%d match:%d excluded:%d filename:%s\n",\r
103 > > > >             notmuch_message_get_message_id (message),\r
104 > > > >             indent,\r
105 > > > > -           notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),\r
106 > > > > +           notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 : 0,\r
107 > > > > +           notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0,\r
108 > > > >             notmuch_message_get_filename (message));\r
109 > > > >  }\r
110 > > > >  \r
111 > > > > @@ -212,9 +213,10 @@ format_message_json (const void *ctx, notmuch_message_t *message, unused (int in\r
112 > > > >      date = notmuch_message_get_date (message);\r
113 > > > >      relative_date = notmuch_time_relative_date (ctx, date);\r
114 > > > >  \r
115 > > > > -    printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",\r
116 > > > > +    printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",\r
117 > > > >             json_quote_str (ctx_quote, notmuch_message_get_message_id (message)),\r
118 > > > >             notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false",\r
119 > > > > +           notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false",\r
120 > > > >             json_quote_str (ctx_quote, notmuch_message_get_filename (message)),\r
121 > > > >             date, relative_date);\r
122 > > > >  \r
123 > > > > @@ -1059,9 +1061,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
124 > > > >      char *opt;\r
125 > > > >      const notmuch_show_format_t *format = &format_text;\r
126 > > > >      notmuch_show_params_t params;\r
127 > > > > +    const char **search_exclude_tags;\r
128 > > > > +    size_t search_exclude_tags_length;\r
129 > > > \r
130 > > > Please move these within the if (!no_exclude) block.\r
131 > > \r
132 > > Will do. (I forgot to move them in notmuch-show when doing notmuch-count\r
133 > > and notmuch-search)\r
134 > > \r
135 > > > >      int mbox = 0;\r
136 > > > >      int format_specified = 0;\r
137 > > > >      int i;\r
138 > > > > +    notmuch_bool_t no_exclude = FALSE;\r
139 > > > > +    unsigned int j;\r
140 > > > \r
141 > > > Same. Or better yet, reuse i.\r
142 > > \r
143 > > Will do.\r
144 > > \r
145 > > > >      params.entire_thread = 0;\r
146 > > > >      params.raw = 0;\r
147 > > > > @@ -1098,6 +1104,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
148 > > > >             params.part = atoi(argv[i] + sizeof ("--part=") - 1);\r
149 > > > >         } else if (STRNCMP_LITERAL (argv[i], "--entire-thread") == 0) {\r
150 > > > >             params.entire_thread = 1;\r
151 > > > > +       } else if (STRNCMP_LITERAL (argv[i], "--no-exclude") == 0) {\r
152 > > > > +           no_exclude = TRUE;\r
153 > > > >         } else if ((STRNCMP_LITERAL (argv[i], "--verify") == 0) ||\r
154 > > > >                    (STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {\r
155 > > > >             if (params.cryptoctx == NULL) {\r
156 > > > > @@ -1167,10 +1175,18 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
157 > > > >      if (params.raw && params.part < 0)\r
158 > > > >         params.part = 0;\r
159 > > > >  \r
160 > > > > +    /* If a single message is requested we do not use search_excludes. */\r
161 > > > >      if (params.part >= 0)\r
162 > > > >         return do_show_single (ctx, query, format, &params);\r
163 > > > > -    else\r
164 > > > > +    else {\r
165 > > > \r
166 > > > Nitpick: There's no rule about this, but I do like the style of using\r
167 > > > braces for both branches if either branch needs them.\r
168 > > \r
169 > > Will fix.\r
170 > > \r
171 > > > > +       if (!no_exclude) {\r
172 > > > > +           search_exclude_tags = notmuch_config_get_search_exclude_tags\r
173 > > > > +               (config, &search_exclude_tags_length);\r
174 > > > > +           for (j = 0; j < search_exclude_tags_length; j++)\r
175 > > > > +               notmuch_query_add_tag_exclude (query, search_exclude_tags[j]);\r
176 > > > > +       }\r
177 > > > >         return do_show (ctx, query, format, &params);\r
178 > > > > +    }\r
179 > > > \r
180 > > > Hmm, unreachable code below. Why doesn't the compiler complain?\r
181 > > \r
182 > > Yes I wondered about that (id:"20120120171801.GA16740@mit.edu"): but didn't think I should do anything about\r
183 > > that in this series.\r
184\r
185 > I'll send patches to fix that along with converting notmuch-show to the\r
186 > new style argument parsing in a day or two. I didn't like you adding\r
187 > options to old style parsing, but also didn't think it reasonable to ask\r
188 > you to fix it in this series. I might have to ask you to rebase if my\r
189 > patches get in first, though. ;)\r
190 \r
191 That's great: I looked at the impressive spaghetti argument parsing and\r
192 couldn't face trying to convert it. I am very happy to rebase on top of\r
193 your patch!\r
194 \r
195 Best wishes\r
196 \r
197 Mark\r
198 \r