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 4738042119F
\r
6 for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 20:24:54 -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 056yZO3t+0XH for <notmuch@notmuchmail.org>;
\r
16 Sun, 22 Jan 2012 20:24:53 -0800 (PST)
\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com
\r
18 [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
19 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
20 8C9D242119C for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 20:24:53 -0800
\r
22 Received: by mail-ww0-f45.google.com with SMTP id dt12so2215149wgb.2
\r
23 for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 20:24:53 -0800 (PST)
\r
25 Received: by 10.180.94.97 with SMTP id db1mr10668097wib.16.1327292693232;
\r
26 Sun, 22 Jan 2012 20:24:53 -0800 (PST)
\r
27 Received: from localhost ([109.131.95.182])
\r
28 by mx.google.com with ESMTPS id t6sm10821091wid.1.2012.01.22.20.24.52
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Sun, 22 Jan 2012 20:24:52 -0800 (PST)
\r
31 From: Pieter Praet <pieter@praet.org>
\r
32 To: Austin Clements <amdragon@mit.edu>
\r
33 Subject: [PATCH v2 4/6] setup: move tag printing and parsing into separate
\r
35 Date: Mon, 23 Jan 2012 05:22:35 +0100
\r
36 Message-Id: <1327292557-7701-4-git-send-email-pieter@praet.org>
\r
37 X-Mailer: git-send-email 1.7.8.1
\r
38 In-Reply-To: <87obtvaw8h.fsf@praet.org>
\r
39 References: <87obtvaw8h.fsf@praet.org>
\r
41 ALoCoQmWtSK7smf0hfR/BJXgezHOQnpEgrVUCbWDqiAlDymzQBSzcp+J81rTNyo3c4mZl8s3j1On
\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 04:24:54 -0000
\r
57 From: Austin Clements <amdragon@MIT.EDU>
\r
59 * notmuch-setup.c (notmuch_setup_command):
\r
60 Break tag printing and response parsing out into separate functions
\r
61 called `print_tag_list' respectively `parse_tag_list', for reuse
\r
62 with the 'search.exclude_tags' option.
\r
65 notmuch-setup.c | 55 ++++++++++++++++++++++++++++++++++---------------------
\r
66 1 files changed, 34 insertions(+), 21 deletions(-)
\r
68 diff --git a/notmuch-setup.c b/notmuch-setup.c
\r
69 index c3ea937..dcfa607 100644
\r
70 --- a/notmuch-setup.c
\r
71 +++ b/notmuch-setup.c
\r
72 @@ -87,6 +87,38 @@ welcome_message_post_setup (void)
\r
73 "have sufficient storage space available now.\n\n");
\r
77 +print_tag_list (const char **tags, size_t tags_len)
\r
80 + for (i = 0; i < tags_len; i++) {
\r
83 + printf ("%s", tags[i]);
\r
88 +parse_tag_list (void *ctx, char *response)
\r
90 + GPtrArray *tags = g_ptr_array_new ();
\r
91 + char *tag = response;
\r
94 + while (tag && *tag) {
\r
95 + space = strchr (tag, ' ');
\r
97 + g_ptr_array_add (tags, talloc_strndup (ctx, tag, space - tag));
\r
99 + g_ptr_array_add (tags, talloc_strdup (ctx, tag));
\r
101 + while (tag && *tag == ' ')
\r
109 notmuch_setup_command (unused (void *ctx),
\r
110 unused (int argc), unused (char *argv[]))
\r
111 @@ -164,30 +196,11 @@ notmuch_setup_command (unused (void *ctx),
\r
112 new_tags = notmuch_config_get_new_tags (config, &new_tags_len);
\r
114 printf ("Tags to apply to all new messages (separated by spaces) [");
\r
116 - for (i = 0; i < new_tags_len; i++) {
\r
119 - printf ("%s", new_tags[i]);
\r
122 + print_tag_list(new_tags, new_tags_len);
\r
125 if (strlen (response)) {
\r
126 - GPtrArray *tags = g_ptr_array_new ();
\r
127 - char *tag = response;
\r
130 - while (tag && *tag) {
\r
131 - space = strchr (tag, ' ');
\r
133 - g_ptr_array_add (tags, talloc_strndup (ctx, tag, space - tag));
\r
135 - g_ptr_array_add (tags, talloc_strdup (ctx, tag));
\r
137 - while (tag && *tag == ' ')
\r
140 + GPtrArray *tags = parse_tag_list (ctx, response);
\r
142 notmuch_config_set_new_tags (config, (const char **) tags->pdata,
\r