Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / c2 / aaeb850928a39c06d706508c90e505a2758e0d
1 Return-Path: <amdragon@mit.edu>\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 3EC17431FAF\r
6         for <notmuch@notmuchmail.org>; Thu, 19 Jan 2012 11:44:58 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 GXOWWeYCQgfY for <notmuch@notmuchmail.org>;\r
16         Thu, 19 Jan 2012 11:44:57 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU\r
18         [18.7.68.34])\r
19         by olra.theworths.org (Postfix) with ESMTP id 99A9D431FAE\r
20         for <notmuch@notmuchmail.org>; Thu, 19 Jan 2012 11:44:57 -0800 (PST)\r
21 X-AuditID: 12074422-b7fd66d0000008f9-18-4f1872b8f0fb\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id F4.91.02297.8B2781F4; Thu, 19 Jan 2012 14:44:56 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q0JJiuHb032713; \r
27         Thu, 19 Jan 2012 14:44:56 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0JJitta014990\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Thu, 19 Jan 2012 14:44:55 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1RnxuX-000467-T8; Thu, 19 Jan 2012 14:44:37 -0500\r
37 Date: Thu, 19 Jan 2012 14:44:37 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Pieter Praet <pieter@praet.org>\r
40 Subject: Re: [PATCH 4/4] setup: prompt user for search.exclude_tags value\r
41 Message-ID: <20120119194437.GP16740@mit.edu>\r
42 References: <1326586654-16840-3-git-send-email-amdragon@mit.edu>\r
43         <1327000744-25463-1-git-send-email-pieter@praet.org>\r
44         <1327000744-25463-5-git-send-email-pieter@praet.org>\r
45 MIME-Version: 1.0\r
46 Content-Type: text/plain; charset=us-ascii\r
47 Content-Disposition: inline\r
48 In-Reply-To: <1327000744-25463-5-git-send-email-pieter@praet.org>\r
49 User-Agent: Mutt/1.5.21 (2010-09-15)\r
50 X-Brightmail-Tracker:\r
51  H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IRYrdT0d1RJOFvcGCpvMX1mzOZLX6/vsHs\r
52         wOTxbNUtZo+OfZdZA5iiuGxSUnMyy1KL9O0SuDJuzXnGXNApUNG0fjJLA2MHTxcjJ4eEgInE\r
53         t/tNbBC2mMSFe+uBbC4OIYF9jBKzzx9mB0kICWxglOjcLgWROMkkcXdLFxOEs4RR4vyEzWDt\r
54         LAKqEjc79jOC2GwCGhLb9i8Hs0UElCVOP/kJNolZQEti68YPYHFhAU+Jl/PbwOK8AjoSX06f\r
55         YoQYuo5RYu+2BqiEoMTJmU9YYJpv/HsJtJkDyJaWWP6PAyTMKeAoMfPoe7ASUQEViSknt7FN\r
56         YBSahaR7FpLuWQjdCxiZVzHKpuRW6eYmZuYUpybrFicn5uWlFuma6uVmluilppRuYgQHtovS\r
57         DsafB5UOMQpwMCrx8HK5SvgLsSaWFVfmHmKU5GBSEuXtLgAK8SXlp1RmJBZnxBeV5qQWH2KU\r
58         4GBWEuGdlwOU401JrKxKLcqHSUlzsCiJ86prvfMTEkhPLEnNTk0tSC2CycpwcChJ8LICI1hI\r
59         sCg1PbUiLTOnBCHNxMEJMpwHaLgVSA1vcUFibnFmOkT+FKOilDgvA0hCACSRUZoH1wtLPK8Y\r
60         xYFeEeZVB6niASYtuO5XQIOZgAZ7NImBDC5JREhJNTDWGOUdeGb96TTLYvUzgqrrvgS31bBX\r
61         MC9Y+1EjgHGn+uOC4NWRUdnfzd7ZsWs4zbR9+yrJ/cDT5drRr5qFUo9PFbJXWzBzwdesX0d+\r
62         Z/+7Hrum32ZDhGCyZumjxD23y/2fOb90c5a9Oddd1uzSzv5dxe2XH3dWHFuqvDKe40PpsScq\r
63         Hrv1Wx4osRRnJBpqMRcVJwIAvC7BxRcDAAA=\r
64 Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Thu, 19 Jan 2012 19:44:58 -0000\r
78 \r
79 Quoth Pieter Praet on Jan 19 at  8:19 pm:\r
80 > Allow users to customize the search.exclude_tags option during setup.\r
81\r
82 > ---\r
83 >  notmuch-setup.c |   36 ++++++++++++++++++++++++++++++++++++\r
84 >  1 files changed, 36 insertions(+), 0 deletions(-)\r
85\r
86 > diff --git a/notmuch-setup.c b/notmuch-setup.c\r
87 > index c3ea937..44d4aaa 100644\r
88 > --- a/notmuch-setup.c\r
89 > +++ b/notmuch-setup.c\r
90 > @@ -101,6 +101,8 @@ notmuch_setup_command (unused (void *ctx),\r
91 >      int is_new;\r
92 >      const char **new_tags;\r
93 >      size_t new_tags_len;\r
94 > +    const char **search_exclude_tags;\r
95 > +    size_t search_exclude_tags_len;\r
96 >  \r
97 >  #define prompt(format, ...)                                  \\r
98 >      do {                                                     \\r
99 > @@ -195,6 +197,40 @@ notmuch_setup_command (unused (void *ctx),\r
100 >       g_ptr_array_free (tags, TRUE);\r
101 >      }\r
102 >  \r
103 > +    search_exclude_tags = notmuch_config_get_search_exclude_tags (config, &search_exclude_tags_len);\r
104 > +\r
105 > +    printf ("Tags to exclude when searching messages (separated by spaces) [");\r
106 > +\r
107 > +    for (i = 0; i < search_exclude_tags_len; i++) {\r
108 > +     if (i != 0)\r
109 > +         printf (" ");\r
110 > +     printf ("%s", search_exclude_tags[i]);\r
111 > +    }\r
112 > +\r
113 > +    prompt ("]: ");\r
114 > +\r
115 > +    if (strlen (response)) {\r
116 > +     GPtrArray *tags = g_ptr_array_new ();\r
117 > +     char *tag = response;\r
118 > +     char *space;\r
119 > +\r
120 > +     while (tag && *tag) {\r
121 > +         space = strchr (tag, ' ');\r
122 > +         if (space)\r
123 > +             g_ptr_array_add (tags, talloc_strndup (ctx, tag, space - tag));\r
124 > +         else\r
125 > +             g_ptr_array_add (tags, talloc_strdup (ctx, tag));\r
126 > +         tag = space;\r
127 > +         while (tag && *tag == ' ')\r
128 > +             tag++;\r
129 > +     }\r
130 > +\r
131 > +     notmuch_config_set_search_exclude_tags (config, (const char **) tags->pdata,\r
132 > +                                  tags->len);\r
133 > +\r
134 > +     g_ptr_array_free (tags, TRUE);\r
135 > +    }\r
136 > +\r
137 \r
138 Holy code duplication.  Can we move most of this (at least the\r
139 response parsing part and maybe the prompt printing) into a function\r
140 and use it for both new tags and exclude tags?\r
141 \r
142 >      if (! notmuch_config_save (config)) {\r
143 >       if (is_new)\r
144 >         welcome_message_post_setup ();\r