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 76672431FBD for ; Thu, 19 Jan 2012 11:21:14 -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 7NfvFczSDqpz for ; Thu, 19 Jan 2012 11:21:14 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id CADE2431FB6 for ; Thu, 19 Jan 2012 11:21:13 -0800 (PST) Received: by wibhr12 with SMTP id hr12so262343wib.26 for ; Thu, 19 Jan 2012 11:21:12 -0800 (PST) Received: by 10.180.109.198 with SMTP id hu6mr4342280wib.16.1327000872529; Thu, 19 Jan 2012 11:21:12 -0800 (PST) Received: from localhost ([109.131.97.13]) by mx.google.com with ESMTPS id eq5sm1056630wib.2.2012.01.19.11.21.11 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Jan 2012 11:21:12 -0800 (PST) From: Pieter Praet To: Austin Clements Subject: [PATCH 4/4] setup: prompt user for search.exclude_tags value Date: Thu, 19 Jan 2012 20:19:04 +0100 Message-Id: <1327000744-25463-5-git-send-email-pieter@praet.org> X-Mailer: git-send-email 1.7.8.1 In-Reply-To: <1327000744-25463-1-git-send-email-pieter@praet.org> References: <1326586654-16840-3-git-send-email-amdragon@mit.edu> <1327000744-25463-1-git-send-email-pieter@praet.org> Cc: Notmuch Mail 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, 19 Jan 2012 19:21:14 -0000 Allow users to customize the search.exclude_tags option during setup. --- notmuch-setup.c | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/notmuch-setup.c b/notmuch-setup.c index c3ea937..44d4aaa 100644 --- a/notmuch-setup.c +++ b/notmuch-setup.c @@ -101,6 +101,8 @@ notmuch_setup_command (unused (void *ctx), int is_new; const char **new_tags; size_t new_tags_len; + const char **search_exclude_tags; + size_t search_exclude_tags_len; #define prompt(format, ...) \ do { \ @@ -195,6 +197,40 @@ notmuch_setup_command (unused (void *ctx), g_ptr_array_free (tags, TRUE); } + search_exclude_tags = notmuch_config_get_search_exclude_tags (config, &search_exclude_tags_len); + + printf ("Tags to exclude when searching messages (separated by spaces) ["); + + for (i = 0; i < search_exclude_tags_len; i++) { + if (i != 0) + printf (" "); + printf ("%s", search_exclude_tags[i]); + } + + prompt ("]: "); + + if (strlen (response)) { + GPtrArray *tags = g_ptr_array_new (); + char *tag = response; + char *space; + + while (tag && *tag) { + space = strchr (tag, ' '); + if (space) + g_ptr_array_add (tags, talloc_strndup (ctx, tag, space - tag)); + else + g_ptr_array_add (tags, talloc_strdup (ctx, tag)); + tag = space; + while (tag && *tag == ' ') + tag++; + } + + notmuch_config_set_search_exclude_tags (config, (const char **) tags->pdata, + tags->len); + + g_ptr_array_free (tags, TRUE); + } + if (! notmuch_config_save (config)) { if (is_new) welcome_message_post_setup (); -- 1.7.8.1