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 3EC17431FAF for ; Thu, 19 Jan 2012 11:44:58 -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 GXOWWeYCQgfY for ; Thu, 19 Jan 2012 11:44:57 -0800 (PST) Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU [18.7.68.34]) by olra.theworths.org (Postfix) with ESMTP id 99A9D431FAE for ; Thu, 19 Jan 2012 11:44:57 -0800 (PST) X-AuditID: 12074422-b7fd66d0000008f9-18-4f1872b8f0fb Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id F4.91.02297.8B2781F4; Thu, 19 Jan 2012 14:44:56 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q0JJiuHb032713; Thu, 19 Jan 2012 14:44:56 -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 q0JJitta014990 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 19 Jan 2012 14:44:55 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1RnxuX-000467-T8; Thu, 19 Jan 2012 14:44:37 -0500 Date: Thu, 19 Jan 2012 14:44:37 -0500 From: Austin Clements To: Pieter Praet Subject: Re: [PATCH 4/4] setup: prompt user for search.exclude_tags value Message-ID: <20120119194437.GP16740@mit.edu> References: <1326586654-16840-3-git-send-email-amdragon@mit.edu> <1327000744-25463-1-git-send-email-pieter@praet.org> <1327000744-25463-5-git-send-email-pieter@praet.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1327000744-25463-5-git-send-email-pieter@praet.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IRYrdT0d1RJOFvcGCpvMX1mzOZLX6/vsHs wOTxbNUtZo+OfZdZA5iiuGxSUnMyy1KL9O0SuDJuzXnGXNApUNG0fjJLA2MHTxcjJ4eEgInE t/tNbBC2mMSFe+uBbC4OIYF9jBKzzx9mB0kICWxglOjcLgWROMkkcXdLFxOEs4RR4vyEzWDt LAKqEjc79jOC2GwCGhLb9i8Hs0UElCVOP/kJNolZQEti68YPYHFhAU+Jl/PbwOK8AjoSX06f YoQYuo5RYu+2BqiEoMTJmU9YYJpv/HsJtJkDyJaWWP6PAyTMKeAoMfPoe7ASUQEViSknt7FN YBSahaR7FpLuWQjdCxiZVzHKpuRW6eYmZuYUpybrFicn5uWlFuma6uVmluilppRuYgQHtovS DsafB5UOMQpwMCrx8HK5SvgLsSaWFVfmHmKU5GBSEuXtLgAK8SXlp1RmJBZnxBeV5qQWH2KU 4GBWEuGdlwOU401JrKxKLcqHSUlzsCiJ86prvfMTEkhPLEnNTk0tSC2CycpwcChJ8LICI1hI sCg1PbUiLTOnBCHNxMEJMpwHaLgVSA1vcUFibnFmOkT+FKOilDgvA0hCACSRUZoH1wtLPK8Y xYFeEeZVB6niASYtuO5XQIOZgAZ7NImBDC5JREhJNTDWGOUdeGb96TTLYvUzgqrrvgS31bBX MC9Y+1EjgHGn+uOC4NWRUdnfzd7ZsWs4zbR9+yrJ/cDT5drRr5qFUo9PFbJXWzBzwdesX0d+ Z/+7Hrum32ZDhGCyZumjxD23y/2fOb90c5a9Oddd1uzSzv5dxe2XH3dWHFuqvDKe40PpsScq Hrv1Wx4osRRnJBpqMRcVJwIAvC7BxRcDAAA= 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:44:58 -0000 Quoth Pieter Praet on Jan 19 at 8:19 pm: > 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); > + } > + Holy code duplication. Can we move most of this (at least the response parsing part and maybe the prompt printing) into a function and use it for both new tags and exclude tags? > if (! notmuch_config_save (config)) { > if (is_new) > welcome_message_post_setup ();