Re: [PATCH v4 08/11] cli: Make notmuch-show respect excludes.
authorJani Nikula <jani@nikula.org>
Thu, 2 Feb 2012 23:13:31 +0000 (01:13 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:59 +0000 (09:43 -0800)
2d/bf8f9bd0f810de5a212a5a3473a23aa815e070 [new file with mode: 0644]

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