From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 703E0418C2B for ; Mon, 30 Jan 2012 20:57:37 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 ne0xO-GaVN9o for ; Mon, 30 Jan 2012 20:57:35 -0800 (PST) Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU [18.7.68.36]) by olra.theworths.org (Postfix) with ESMTP id E94CA414B92 for ; Mon, 30 Jan 2012 20:57:18 -0800 (PST) X-AuditID: 12074424-b7fae6d000000906-c8-4f2774ae5b89 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP id 0B.3A.02310.EA4772F4; Mon, 30 Jan 2012 23:57:18 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q0V4vHXW004252; Mon, 30 Jan 2012 23:57:18 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0V4vGYZ002133 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 30 Jan 2012 23:57:17 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1Rs5lZ-0002nY-0A; Mon, 30 Jan 2012 23:56:25 -0500 Date: Mon, 30 Jan 2012 23:56:24 -0500 From: Austin Clements To: Mark Walters Subject: Re: [PATCH 5/7] cli: Make notmuch-show respect excludes. Message-ID: <20120131045624.GB17991@mit.edu> References: <8762fu4aqt.fsf@qmul.ac.uk> <1327862394-14334-5-git-send-email-markwalters1009@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1327862394-14334-5-git-send-email-markwalters1009@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkleLIzCtJLcpLzFFi42IR4hTV1l1Xou5vcGi6osXquTwW12/OZHZg 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4Mqaf38RWMEOj4tamHywNjL/kuxg5OSQETCTm P5/GDmGLSVy4t56ti5GLQ0hgH6NE286tzBDOBkaJPc9OQTknmSQa106AcpYwStxbPJ+li5GD g0VAVeL+JUWQUWwCGhLb9i9nBLFFBHQkbh9aALaCWUBa4tvvZiYQW1jAUeJo02KwGl6gmhPn v4CNERJIl5g3zwAiLChxcuYTFohWLYkb/14ygZSAjFn+jwMkzCngJXH86k5WEFtUQEViyslt bBMYhWYh6Z6FpHsWQvcCRuZVjLIpuVW6uYmZOcWpybrFyYl5ealFuuZ6uZkleqkppZsYQSHN 7qKyg7H5kNIhRgEORiUeXqFPav5CrIllxZW5hxglOZiURHnnFKj7C/El5adUZiQWZ8QXleak Fh9ilOBgVhLhfbMaqJw3JbGyKrUoHyYlzcGiJM6rofXOD+jdxJLU7NTUgtQimKwMB4eSBO+b YqChgkWp6akVaZk5JQhpJg5OkOE8QMPXgtTwFhck5hZnpkPkTzEqSonzHgNJCIAkMkrz4Hph KecVozjQK8K8R0CqeIDpCq77FdBgJqDBzxlUQQaXJCKkpBoY2+/2fxF3WjnToP4h//9za/ov zci6zDF34n6H3sCEYwvlt1e9yfYpVf07Q3zbOT3pzW4vDzwUtltkdOz+pAbXuCcdequ/J5W/ sJPcdOjinLUfprGk6VRxrLpkZrl5q9N3sa0tvXbb8+ZcWNir/359TYzDoS2fClbeXp10rEL6 wwkBvtNnpC6JViuxFGckGmoxFxUnAgDo5J8sFAMAAA== Cc: notmuch@notmuchmail.org 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: Tue, 31 Jan 2012 04:57:37 -0000 Quoth Mark Walters on Jan 29 at 6:39 pm: > 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 | 26 +++++++++++++++++++++----- > 1 files changed, 21 insertions(+), 5 deletions(-) > > diff --git a/notmuch-show.c b/notmuch-show.c > index dec799c..681827f 100644 > --- a/notmuch-show.c > +++ b/notmuch-show.c > @@ -193,10 +193,12 @@ _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", > + /* Could changing this could break users ? */ I don't think anybody seriously tries to parse the text format, so I wouldn't worry about breaking anything. > + 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 +214,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\": [", I wonder if it would be better to switch to an array of flag names... That obviously would break consumers, but it's worth thinking about in the longer term. > 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 +1062,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; > int mbox = 0; > int format_specified = 0; > int i; > + notmuch_bool_t do_not_exclude = FALSE; > + unsigned int j; > > params.entire_thread = 0; > params.raw = 0; > @@ -1098,6 +1105,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], "--do-not-exclude") == 0) { > + do_not_exclude = TRUE; "no-exclude" if you change the others. > } else if ((STRNCMP_LITERAL (argv[i], "--verify") == 0) || > (STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) { > if (params.cryptoctx == NULL) { > @@ -1105,7 +1114,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) > /* TODO: GMimePasswordRequestFunc */ > if (NULL == (params.cryptoctx = g_mime_gpg_context_new(NULL, "gpg"))) > #else > - GMimeSession* session = g_object_new(g_mime_session_get_type(), NULL); > + GMimeSession* session = g_object_new(g_mime_session_get_type(), NULL); Accidental reindent? > if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, "gpg"))) > #endif > fprintf (stderr, "Failed to construct gpg context.\n"); > @@ -1167,10 +1176,17 @@ 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 */ Capital and period. > if (params.part >= 0) > return do_show_single (ctx, query, format, ¶ms); > else > - return do_show (ctx, query, format, ¶ms); > + if (!do_not_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); > + } I don't think this is the control flow you meant. With --do-not-exclude, there won't be any output. > > notmuch_query_destroy (query); > notmuch_database_close (notmuch); Cool. That was easy!