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 B2022431FB6 for ; Mon, 13 May 2013 07:20:36 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 87EKU+b+X4vn for ; Mon, 13 May 2013 07:20:31 -0700 (PDT) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 28A27431FAE for ; Mon, 13 May 2013 07:20:31 -0700 (PDT) Received: by mail-pa0-f50.google.com with SMTP id fb10so4616819pad.23 for ; Mon, 13 May 2013 07:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=egNzpeoyPhsaR+IxbSLHUjrlVwa66ky0s5ooVduz6gI=; b=xiGF/bkiBNEOorkMPHD6zYreBz4fjyCge9KIFxT5mu0JssSZNuX5bdybIwY3RHUaeN rj8+5YsWiZ/wp/kOaRP+HldUJOsBVaOT01nt0PqYwJieM5xDPqg+5Aud8OykNVlM1yNc OJXs/aD2JHE0lLdUfhcQ0bUAIDRE9jmkI11pgInv4WUt4F0hakA+MHo6og2QNIq1eB4Y mVaHnbkkg3fEiyExbmH9mPZ4lID4gz1DP9TfI0jvBHsGhZgs36fDLuATAPnWYN5y8MjX 7hOz4/bDgEG+L960clc1xIoOPPRagaQl9cVfl3gcN6KBg/4lS4r37juK6FgGYHljNJNl 0YgA== X-Received: by 10.66.218.170 with SMTP id ph10mr30529077pac.134.1368454830472; Mon, 13 May 2013 07:20:30 -0700 (PDT) Received: from localhost (215.42.233.220.static.exetel.com.au. [220.233.42.215]) by mx.google.com with ESMTPSA id 10sm14219628pbr.45.2013.05.13.07.20.27 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 13 May 2013 07:20:29 -0700 (PDT) From: Peter Wang To: notmuch@notmuchmail.org Subject: [PATCH v2] cli: clarify correspondence of --exclude to omit_excluded in search Date: Tue, 14 May 2013 00:20:15 +1000 Message-Id: <1368454815-1854-1-git-send-email-novalazy@gmail.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1368301809-12532-1-git-send-email-markwalters1009@gmail.com> References: <1368301809-12532-1-git-send-email-markwalters1009@gmail.com> 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: Mon, 13 May 2013 14:20:36 -0000 Make it obvious how the --exclude command-line option affects the omit_excluded field in notmuch_query_t objects, with an explicit and exhaustive switch. Do not expect the reader to know the default value of omit_excluded. --- This can be inserted after patch 2. notmuch-search.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 4323201..893df10 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -290,6 +290,24 @@ enum { EXCLUDE_ALL }; +static int +exclude_option_to_omit_excluded (int exclude) +{ + switch (exclude) { + case EXCLUDE_TRUE: + return NOTMUCH_EXCLUDE_TRUE; + case EXCLUDE_FALSE: + return NOTMUCH_EXCLUDE_FALSE; + case EXCLUDE_FLAG: + return NOTMUCH_EXCLUDE_FALSE; + case EXCLUDE_ALL: + return NOTMUCH_EXCLUDE_ALL; + default: + INTERNAL_ERROR ("unhandled exclude option %d", exclude); + /*UNREACHED*/ + } +} + int notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) { @@ -410,11 +428,8 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) (config, &search_exclude_tags_length); for (i = 0; i < search_exclude_tags_length; i++) notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); - if (exclude == EXCLUDE_FLAG) - notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FALSE); - if (exclude == EXCLUDE_ALL) - notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL); } + notmuch_query_set_omit_excluded (query, exclude_option_to_omit_excluded (exclude)); switch (output) { default: -- 1.7.12.1