Re: [PATCH 5/7] cli: Make notmuch-show respect excludes.
authorMark Walters <markwalters1009@gmail.com>
Tue, 31 Jan 2012 12:30:35 +0000 (12:30 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:49 +0000 (09:43 -0800)
2c/aa9e1c42a38e41410089405f3976112536a69d [new file with mode: 0644]

diff --git a/2c/aa9e1c42a38e41410089405f3976112536a69d b/2c/aa9e1c42a38e41410089405f3976112536a69d
new file mode 100644 (file)
index 0000000..3ddfe7d
--- /dev/null
@@ -0,0 +1,207 @@
+Return-Path: <m.walters@qmul.ac.uk>\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 0DEBC41ED96\r
+       for <notmuch@notmuchmail.org>; Tue, 31 Jan 2012 04:29:32 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+       tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+       NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 wAjogMq19Maq for <notmuch@notmuchmail.org>;\r
+       Tue, 31 Jan 2012 04:29:31 -0800 (PST)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 1D7EA41ED91\r
+       for <notmuch@notmuchmail.org>; Tue, 31 Jan 2012 04:29:31 -0800 (PST)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+       by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1RsCq1-0001Jd-Eu; Tue, 31 Jan 2012 12:29:29 +0000\r
+Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
+       helo=localhost)\r
+       by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1RsCq0-0001sk-UV; Tue, 31 Jan 2012 12:29:29 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>\r
+Subject: Re: [PATCH 5/7] cli: Make notmuch-show respect excludes.\r
+In-Reply-To: <20120131045624.GB17991@mit.edu>\r
+References: <8762fu4aqt.fsf@qmul.ac.uk>\r
+       <1327862394-14334-5-git-send-email-markwalters1009@gmail.com>\r
+       <20120131045624.GB17991@mit.edu>\r
+User-Agent: Notmuch/0.11+137~g98adc3d (http://notmuchmail.org) Emacs/23.2.1\r
+       (i486-pc-linux-gnu)\r
+Date: Tue, 31 Jan 2012 12:30:35 +0000\r
+Message-ID: <87sjiwcavo.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 94.192.233.223\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: 68a5891608c30e81d4b0c855c7a2a397 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+       determine if it is\r
+       spam. We require at least 5.0 points to mark a message as spam.\r
+       This message scored -1.8 points.\r
+       Summary of the scoring: \r
+       * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+       *      medium trust\r
+       *      [138.37.6.40 listed in list.dnswl.org]\r
+       * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+       provider *      (markwalters1009[at]gmail.com)\r
+       * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+       *      domain\r
+       *  0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+Cc: notmuch@notmuchmail.org\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: Tue, 31 Jan 2012 12:29:32 -0000\r
+\r
+On Mon, 30 Jan 2012 23:56:24 -0500, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> Quoth Mark Walters on Jan 29 at  6:39 pm:\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 |   26 +++++++++++++++++++++-----\r
+> >  1 files changed, 21 insertions(+), 5 deletions(-)\r
+> > \r
+> > diff --git a/notmuch-show.c b/notmuch-show.c\r
+> > index dec799c..681827f 100644\r
+> > --- a/notmuch-show.c\r
+> > +++ b/notmuch-show.c\r
+> > @@ -193,10 +193,12 @@ _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
+> > +    /* Could changing this could break users ? */\r
+> \r
+> I don't think anybody seriously tries to parse the text format, so I\r
+> wouldn't worry about breaking anything.\r
+\r
+Right: I will remove the comment.\r
+\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 +214,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
+> \r
+> I wonder if it would be better to switch to an array of flag names...\r
+> That obviously would break consumers, but it's worth thinking about in\r
+> the longer term.\r
+\r
+Unless you have a strong feeling for this I will leave that for a later\r
+patch.\r
+\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 +1062,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
+> >      int mbox = 0;\r
+> >      int format_specified = 0;\r
+> >      int i;\r
+> > +    notmuch_bool_t do_not_exclude = FALSE;\r
+> > +    unsigned int j;\r
+> >  \r
+> >      params.entire_thread = 0;\r
+> >      params.raw = 0;\r
+> > @@ -1098,6 +1105,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], "--do-not-exclude") == 0) {\r
+> > +      do_not_exclude = TRUE;\r
+> \r
+> "no-exclude" if you change the others.\r
+\r
+See comment on first patch: will make sure they are consistent.\r
+\r
+> >    } else if ((STRNCMP_LITERAL (argv[i], "--verify") == 0) ||\r
+> >               (STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {\r
+> >        if (params.cryptoctx == NULL) {\r
+> > @@ -1105,7 +1114,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+> >            /* TODO: GMimePasswordRequestFunc */\r
+> >            if (NULL == (params.cryptoctx = g_mime_gpg_context_new(NULL, "gpg")))\r
+> >  #else\r
+> > -          GMimeSession* session = g_object_new(g_mime_session_get_type(), NULL);\r
+> > +              GMimeSession* session = g_object_new(g_mime_session_get_type(), NULL);\r
+> \r
+> Accidental reindent?\r
+\r
+Yes will fix.\r
+\r
+> >            if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, "gpg")))\r
+> >  #endif\r
+> >                fprintf (stderr, "Failed to construct gpg context.\n");\r
+> > @@ -1167,10 +1176,17 @@ 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
+> \r
+> Capital and period.\r
+\r
+Will fix.\r
+\r
+> >      if (params.part >= 0)\r
+> >    return do_show_single (ctx, query, format, &params);\r
+> >      else\r
+> > -  return do_show (ctx, query, format, &params);\r
+> > +  if (!do_not_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
+> > +      return do_show (ctx, query, format, &params);\r
+> > +  }\r
+> \r
+> I don't think this is the control flow you meant.  With\r
+> --do-not-exclude, there won't be any output.\r
+\r
+Good catch! Will fix.\r
+\r
+Thanks \r
+\r
+Mark\r
+\r