1 Return-Path: <pieter@praet.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id A6281429E54
\r
6 for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 21:52:42 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 8sfMgQMHKzbh for <notmuch@notmuchmail.org>;
\r
16 Sun, 22 Jan 2012 21:52:42 -0800 (PST)
\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
18 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 05B72429E40
\r
21 for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 21:52:41 -0800 (PST)
\r
22 Received: by werb10 with SMTP id b10so2146731wer.26
\r
23 for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 21:52:40 -0800 (PST)
\r
25 Received: by 10.180.86.105 with SMTP id o9mr4177839wiz.4.1327297960837;
\r
26 Sun, 22 Jan 2012 21:52:40 -0800 (PST)
\r
27 Received: from localhost ([109.131.95.182])
\r
28 by mx.google.com with ESMTPS id hc10sm7780443wib.8.2012.01.22.21.52.40
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Sun, 22 Jan 2012 21:52:40 -0800 (PST)
\r
31 From: Pieter Praet <pieter@praet.org>
\r
32 To: Austin Clements <amdragon@MIT.EDU>
\r
33 Subject: [PATCH v3 4/6] setup: Create functions for tag list printing and
\r
35 Date: Mon, 23 Jan 2012 06:50:45 +0100
\r
36 Message-Id: <1327297845-16438-1-git-send-email-pieter@praet.org>
\r
37 X-Mailer: git-send-email 1.7.8.1
\r
38 In-Reply-To: <20120123050737.GT16740@mit.edu>
\r
39 References: <20120123050737.GT16740@mit.edu>
\r
41 ALoCoQkrorl97QSMdRsCoFliTmjVHgBTShvwRKiHyttvg3i71w+t4HmiKFsl7sxPEuxXPpV8rVu+
\r
42 Cc: Notmuch Mail <notmuch@notmuchmail.org>
\r
43 X-BeenThere: notmuch@notmuchmail.org
\r
44 X-Mailman-Version: 2.1.13
\r
46 List-Id: "Use and development of the notmuch mail system."
\r
47 <notmuch.notmuchmail.org>
\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
51 List-Post: <mailto:notmuch@notmuchmail.org>
\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
55 X-List-Received-Date: Mon, 23 Jan 2012 05:52:42 -0000
\r
57 From: Austin Clements <amdragon@MIT.EDU>
\r
59 This refactors the tag list printing and parsing currently used for
\r
60 new.tags so that both can be reused for the new search.exclude_tags
\r
64 notmuch-setup.c | 55 ++++++++++++++++++++++++++++++++++---------------------
\r
65 1 files changed, 34 insertions(+), 21 deletions(-)
\r
67 diff --git a/notmuch-setup.c b/notmuch-setup.c
\r
68 index c3ea937..f85e0eb 100644
\r
69 --- a/notmuch-setup.c
\r
70 +++ b/notmuch-setup.c
\r
71 @@ -87,6 +87,38 @@ welcome_message_post_setup (void)
\r
72 "have sufficient storage space available now.\n\n");
\r
76 +print_tag_list (const char **tags, size_t tags_len)
\r
79 + for (i = 0; i < tags_len; i++) {
\r
82 + printf ("%s", tags[i]);
\r
87 +parse_tag_list (void *ctx, char *response)
\r
89 + GPtrArray *tags = g_ptr_array_new ();
\r
90 + char *tag = response;
\r
93 + while (tag && *tag) {
\r
94 + space = strchr (tag, ' ');
\r
96 + g_ptr_array_add (tags, talloc_strndup (ctx, tag, space - tag));
\r
98 + g_ptr_array_add (tags, talloc_strdup (ctx, tag));
\r
100 + while (tag && *tag == ' ')
\r
108 notmuch_setup_command (unused (void *ctx),
\r
109 unused (int argc), unused (char *argv[]))
\r
110 @@ -164,30 +196,11 @@ notmuch_setup_command (unused (void *ctx),
\r
111 new_tags = notmuch_config_get_new_tags (config, &new_tags_len);
\r
113 printf ("Tags to apply to all new messages (separated by spaces) [");
\r
115 - for (i = 0; i < new_tags_len; i++) {
\r
118 - printf ("%s", new_tags[i]);
\r
121 + print_tag_list (new_tags, new_tags_len);
\r
124 if (strlen (response)) {
\r
125 - GPtrArray *tags = g_ptr_array_new ();
\r
126 - char *tag = response;
\r
129 - while (tag && *tag) {
\r
130 - space = strchr (tag, ' ');
\r
132 - g_ptr_array_add (tags, talloc_strndup (ctx, tag, space - tag));
\r
134 - g_ptr_array_add (tags, talloc_strdup (ctx, tag));
\r
136 - while (tag && *tag == ' ')
\r
139 + GPtrArray *tags = parse_tag_list (ctx, response);
\r
141 notmuch_config_set_new_tags (config, (const char **) tags->pdata,
\r