1 Return-Path: <jani@nikula.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 39E59431FBD
\r
6 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 15:13:39 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\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 SKLXgQJCCo3S for <notmuch@notmuchmail.org>;
\r
16 Thu, 2 Feb 2012 15:13:38 -0800 (PST)
\r
17 Received: from mail-lpp01m020-f181.google.com (mail-lpp01m020-f181.google.com
\r
18 [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 3160D431FAF
\r
21 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 15:13:37 -0800 (PST)
\r
22 Received: by lbbgn5 with SMTP id gn5so666657lbb.26
\r
23 for <notmuch@notmuchmail.org>; Thu, 02 Feb 2012 15:13:36 -0800 (PST)
\r
24 Received: by 10.112.40.101 with SMTP id w5mr1235666lbk.97.1328224416493;
\r
25 Thu, 02 Feb 2012 15:13:36 -0800 (PST)
\r
26 Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.
\r
28 by mx.google.com with ESMTPS id w10sm3171639lbe.14.2012.02.02.15.13.33
\r
29 (version=SSLv3 cipher=OTHER); Thu, 02 Feb 2012 15:13:34 -0800 (PST)
\r
30 From: Jani Nikula <jani@nikula.org>
\r
31 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org,
\r
33 Subject: Re: [PATCH v4 08/11] cli: Make notmuch-show respect excludes.
\r
34 In-Reply-To: <87y5skrhi9.fsf@qmul.ac.uk>
\r
35 References: <874nv9rv79.fsf@qmul.ac.uk>
\r
36 <1328204619-25046-8-git-send-email-markwalters1009@gmail.com>
\r
37 <87haz8yjkv.fsf@nikula.org> <87y5skrhi9.fsf@qmul.ac.uk>
\r
38 User-Agent: Notmuch/0.11+139~g4340989 (http://notmuchmail.org) Emacs/23.3.1
\r
40 Date: Fri, 03 Feb 2012 01:13:31 +0200
\r
41 Message-ID: <87aa50ygkk.fsf@nikula.org>
\r
43 Content-Type: text/plain; charset=us-ascii
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Thu, 02 Feb 2012 23:13:39 -0000
\r
58 On Thu, 02 Feb 2012 22:35:10 +0000, Mark Walters <markwalters1009@gmail.com> wrote:
\r
60 > On Fri, 03 Feb 2012 00:08:32 +0200, Jani Nikula <jani@nikula.org> wrote:
\r
61 > > On Thu, 2 Feb 2012 17:43:36 +0000, Mark Walters <markwalters1009@gmail.com> wrote:
\r
62 > > > This adds the excludes to notmuch-show.c. We do not exclude when only
\r
63 > > > a single message (or part) is requested. notmuch-show will output the
\r
64 > > > exclude information when either text or json format is requested. As
\r
65 > > > this changes the output from notmuch-show it breaks many tests (in a
\r
66 > > > trivial and expected fashion).
\r
68 > > > notmuch-show.c | 24 ++++++++++++++++++++----
\r
69 > > > 1 files changed, 20 insertions(+), 4 deletions(-)
\r
71 > > > diff --git a/notmuch-show.c b/notmuch-show.c
\r
72 > > > index dec799c..108f13b 100644
\r
73 > > > --- a/notmuch-show.c
\r
74 > > > +++ b/notmuch-show.c
\r
75 > > > @@ -193,10 +193,11 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
77 > > > format_message_text (unused (const void *ctx), notmuch_message_t *message, int indent)
\r
79 > > > - printf ("id:%s depth:%d match:%d filename:%s\n",
\r
80 > > > + printf ("id:%s depth:%d match:%d excluded:%d filename:%s\n",
\r
81 > > > notmuch_message_get_message_id (message),
\r
83 > > > - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
\r
84 > > > + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 : 0,
\r
85 > > > + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0,
\r
86 > > > notmuch_message_get_filename (message));
\r
89 > > > @@ -212,9 +213,10 @@ format_message_json (const void *ctx, notmuch_message_t *message, unused (int in
\r
90 > > > date = notmuch_message_get_date (message);
\r
91 > > > relative_date = notmuch_time_relative_date (ctx, date);
\r
93 > > > - printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
\r
94 > > > + printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
\r
95 > > > json_quote_str (ctx_quote, notmuch_message_get_message_id (message)),
\r
96 > > > notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false",
\r
97 > > > + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false",
\r
98 > > > json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
\r
99 > > > date, relative_date);
\r
101 > > > @@ -1059,9 +1061,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
103 > > > const notmuch_show_format_t *format = &format_text;
\r
104 > > > notmuch_show_params_t params;
\r
105 > > > + const char **search_exclude_tags;
\r
106 > > > + size_t search_exclude_tags_length;
\r
108 > > Please move these within the if (!no_exclude) block.
\r
110 > Will do. (I forgot to move them in notmuch-show when doing notmuch-count
\r
111 > and notmuch-search)
\r
113 > > > int mbox = 0;
\r
114 > > > int format_specified = 0;
\r
116 > > > + notmuch_bool_t no_exclude = FALSE;
\r
117 > > > + unsigned int j;
\r
119 > > Same. Or better yet, reuse i.
\r
123 > > > params.entire_thread = 0;
\r
124 > > > params.raw = 0;
\r
125 > > > @@ -1098,6 +1104,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
126 > > > params.part = atoi(argv[i] + sizeof ("--part=") - 1);
\r
127 > > > } else if (STRNCMP_LITERAL (argv[i], "--entire-thread") == 0) {
\r
128 > > > params.entire_thread = 1;
\r
129 > > > + } else if (STRNCMP_LITERAL (argv[i], "--no-exclude") == 0) {
\r
130 > > > + no_exclude = TRUE;
\r
131 > > > } else if ((STRNCMP_LITERAL (argv[i], "--verify") == 0) ||
\r
132 > > > (STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {
\r
133 > > > if (params.cryptoctx == NULL) {
\r
134 > > > @@ -1167,10 +1175,18 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
135 > > > if (params.raw && params.part < 0)
\r
136 > > > params.part = 0;
\r
138 > > > + /* If a single message is requested we do not use search_excludes. */
\r
139 > > > if (params.part >= 0)
\r
140 > > > return do_show_single (ctx, query, format, ¶ms);
\r
144 > > Nitpick: There's no rule about this, but I do like the style of using
\r
145 > > braces for both branches if either branch needs them.
\r
149 > > > + if (!no_exclude) {
\r
150 > > > + search_exclude_tags = notmuch_config_get_search_exclude_tags
\r
151 > > > + (config, &search_exclude_tags_length);
\r
152 > > > + for (j = 0; j < search_exclude_tags_length; j++)
\r
153 > > > + notmuch_query_add_tag_exclude (query, search_exclude_tags[j]);
\r
155 > > > return do_show (ctx, query, format, ¶ms);
\r
158 > > Hmm, unreachable code below. Why doesn't the compiler complain?
\r
160 > Yes I wondered about that (id:"20120120171801.GA16740@mit.edu"): but didn't think I should do anything about
\r
161 > that in this series.
\r
163 I'll send patches to fix that along with converting notmuch-show to the
\r
164 new style argument parsing in a day or two. I didn't like you adding
\r
165 options to old style parsing, but also didn't think it reasonable to ask
\r
166 you to fix it in this series. I might have to ask you to rebase if my
\r
167 patches get in first, though. ;)
\r