From 757d7b244648f8ab824867d2b3529d9aae153583 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 3 Feb 2012 01:13:31 +0200 Subject: [PATCH] Re: [PATCH v4 08/11] cli: Make notmuch-show respect excludes. --- 2d/bf8f9bd0f810de5a212a5a3473a23aa815e070 | 173 ++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 2d/bf8f9bd0f810de5a212a5a3473a23aa815e070 diff --git a/2d/bf8f9bd0f810de5a212a5a3473a23aa815e070 b/2d/bf8f9bd0f810de5a212a5a3473a23aa815e070 new file mode 100644 index 000000000..4a0fc02c7 --- /dev/null +++ b/2d/bf8f9bd0f810de5a212a5a3473a23aa815e070 @@ -0,0 +1,173 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 39E59431FBD + for ; Thu, 2 Feb 2012 15:13:39 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id SKLXgQJCCo3S for ; + Thu, 2 Feb 2012 15:13:38 -0800 (PST) +Received: from mail-lpp01m020-f181.google.com (mail-lpp01m020-f181.google.com + [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 3160D431FAF + for ; Thu, 2 Feb 2012 15:13:37 -0800 (PST) +Received: by lbbgn5 with SMTP id gn5so666657lbb.26 + for ; Thu, 02 Feb 2012 15:13:36 -0800 (PST) +Received: by 10.112.40.101 with SMTP id w5mr1235666lbk.97.1328224416493; + Thu, 02 Feb 2012 15:13:36 -0800 (PST) +Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi. + [84.248.80.253]) + by mx.google.com with ESMTPS id w10sm3171639lbe.14.2012.02.02.15.13.33 + (version=SSLv3 cipher=OTHER); Thu, 02 Feb 2012 15:13:34 -0800 (PST) +From: Jani Nikula +To: Mark Walters , notmuch@notmuchmail.org, + amdragon@MIT.EDU +Subject: Re: [PATCH v4 08/11] cli: Make notmuch-show respect excludes. +In-Reply-To: <87y5skrhi9.fsf@qmul.ac.uk> +References: <874nv9rv79.fsf@qmul.ac.uk> + <1328204619-25046-8-git-send-email-markwalters1009@gmail.com> + <87haz8yjkv.fsf@nikula.org> <87y5skrhi9.fsf@qmul.ac.uk> +User-Agent: Notmuch/0.11+139~g4340989 (http://notmuchmail.org) Emacs/23.3.1 + (i686-pc-linux-gnu) +Date: Fri, 03 Feb 2012 01:13:31 +0200 +Message-ID: <87aa50ygkk.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 02 Feb 2012 23:13:39 -0000 + +On Thu, 02 Feb 2012 22:35:10 +0000, Mark Walters wrote: +> +> On Fri, 03 Feb 2012 00:08:32 +0200, Jani Nikula wrote: +> > On Thu, 2 Feb 2012 17:43:36 +0000, Mark Walters wrote: +> > > This adds the excludes to notmuch-show.c. We do not exclude when only +> > > a single message (or part) is requested. notmuch-show will output the +> > > exclude information when either text or json format is requested. As +> > > this changes the output from notmuch-show it breaks many tests (in a +> > > trivial and expected fashion). +> > > --- +> > > notmuch-show.c | 24 ++++++++++++++++++++---- +> > > 1 files changed, 20 insertions(+), 4 deletions(-) +> > > +> > > diff --git a/notmuch-show.c b/notmuch-show.c +> > > index dec799c..108f13b 100644 +> > > --- a/notmuch-show.c +> > > +++ b/notmuch-show.c +> > > @@ -193,10 +193,11 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message) +> > > static void +> > > format_message_text (unused (const void *ctx), notmuch_message_t *message, int indent) +> > > { +> > > - printf ("id:%s depth:%d match:%d filename:%s\n", +> > > + printf ("id:%s depth:%d match:%d excluded:%d filename:%s\n", +> > > notmuch_message_get_message_id (message), +> > > indent, +> > > - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH), +> > > + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 : 0, +> > > + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0, +> > > notmuch_message_get_filename (message)); +> > > } +> > > +> > > @@ -212,9 +213,10 @@ format_message_json (const void *ctx, notmuch_message_t *message, unused (int in +> > > date = notmuch_message_get_date (message); +> > > relative_date = notmuch_time_relative_date (ctx, date); +> > > +> > > - printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [", +> > > + printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [", +> > > json_quote_str (ctx_quote, notmuch_message_get_message_id (message)), +> > > notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false", +> > > + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false", +> > > json_quote_str (ctx_quote, notmuch_message_get_filename (message)), +> > > date, relative_date); +> > > +> > > @@ -1059,9 +1061,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) +> > > char *opt; +> > > const notmuch_show_format_t *format = &format_text; +> > > notmuch_show_params_t params; +> > > + const char **search_exclude_tags; +> > > + size_t search_exclude_tags_length; +> > +> > Please move these within the if (!no_exclude) block. +> +> Will do. (I forgot to move them in notmuch-show when doing notmuch-count +> and notmuch-search) +> +> > > int mbox = 0; +> > > int format_specified = 0; +> > > int i; +> > > + notmuch_bool_t no_exclude = FALSE; +> > > + unsigned int j; +> > +> > Same. Or better yet, reuse i. +> +> Will do. +> +> > > params.entire_thread = 0; +> > > params.raw = 0; +> > > @@ -1098,6 +1104,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) +> > > params.part = atoi(argv[i] + sizeof ("--part=") - 1); +> > > } else if (STRNCMP_LITERAL (argv[i], "--entire-thread") == 0) { +> > > params.entire_thread = 1; +> > > + } else if (STRNCMP_LITERAL (argv[i], "--no-exclude") == 0) { +> > > + no_exclude = TRUE; +> > > } else if ((STRNCMP_LITERAL (argv[i], "--verify") == 0) || +> > > (STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) { +> > > if (params.cryptoctx == NULL) { +> > > @@ -1167,10 +1175,18 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) +> > > if (params.raw && params.part < 0) +> > > params.part = 0; +> > > +> > > + /* If a single message is requested we do not use search_excludes. */ +> > > if (params.part >= 0) +> > > return do_show_single (ctx, query, format, ¶ms); +> > > - else +> > > + else { +> > +> > Nitpick: There's no rule about this, but I do like the style of using +> > braces for both branches if either branch needs them. +> +> Will fix. +> +> > > + if (!no_exclude) { +> > > + search_exclude_tags = notmuch_config_get_search_exclude_tags +> > > + (config, &search_exclude_tags_length); +> > > + for (j = 0; j < search_exclude_tags_length; j++) +> > > + notmuch_query_add_tag_exclude (query, search_exclude_tags[j]); +> > > + } +> > > return do_show (ctx, query, format, ¶ms); +> > > + } +> > +> > Hmm, unreachable code below. Why doesn't the compiler complain? +> +> Yes I wondered about that (id:"20120120171801.GA16740@mit.edu"): but didn't think I should do anything about +> that in this series. + +I'll send patches to fix that along with converting notmuch-show to the +new style argument parsing in a day or two. I didn't like you adding +options to old style parsing, but also didn't think it reasonable to ask +you to fix it in this series. I might have to ask you to rebase if my +patches get in first, though. ;) + +> +> Thanks +> +> Mark +> -- 2.26.2