Re: BUG: bad notmuch shared library install_name on Mac OS X
[notmuch-archives.git] / d4 / 1c01aae90d317e3101336400cccae2ebf550cc
1 Return-Path: <jan@ryngle.com>\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 DFE1D431FD2\r
6         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:30:27 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id grxPE3eL9H3e for <notmuch@notmuchmail.org>;\r
11         Wed, 25 Nov 2009 15:30:24 -0800 (PST)\r
12 Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com\r
13         [209.85.219.213])\r
14         by olra.theworths.org (Postfix) with ESMTP id 00017431FBC\r
15         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:30:23 -0800 (PST)\r
16 Received: by ewy5 with SMTP id 5so257211ewy.30\r
17         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:30:23 -0800 (PST)\r
18 Received: by 10.213.102.129 with SMTP id g1mr1551593ebo.41.1259191822479;\r
19         Wed, 25 Nov 2009 15:30:22 -0800 (PST)\r
20 Received: from x61s.janakj ([213.192.30.141])\r
21         by mx.google.com with ESMTPS id 28sm337742eyg.12.2009.11.25.15.30.18\r
22         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
23         Wed, 25 Nov 2009 15:30:21 -0800 (PST)\r
24 Received: by x61s.janakj (Postfix, from userid 1000)\r
25         id B02E9440659; Thu, 26 Nov 2009 00:30:16 +0100 (CET)\r
26 From: Jan Janak <jan@ryngle.com>\r
27 To: notmuch@notmuchmail.org\r
28 Date: Thu, 26 Nov 2009 00:30:14 +0100\r
29 Message-Id: <1259191816-1982-3-git-send-email-jan@ryngle.com>\r
30 X-Mailer: git-send-email 1.6.3.3\r
31 In-Reply-To: <1259191816-1982-2-git-send-email-jan@ryngle.com>\r
32 References: <1259100630-13673-1-git-send-email-jan@ryngle.com>\r
33         <1259191816-1982-1-git-send-email-jan@ryngle.com>\r
34         <1259191816-1982-2-git-send-email-jan@ryngle.com>\r
35 Subject: [notmuch] [PATCH 3/5] notmuch-setup: Copy/create the new section\r
36         with tags for 'notmuch-new'.\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.12\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Wed, 25 Nov 2009 23:30:28 -0000\r
50 \r
51 If the user runs 'notmuch setup' and there is no configuration file yet\r
52 then we also add the new section [new] to the configuration file and\r
53 set the tags option as:\r
54 \r
55   tags=inbox;unread\r
56 \r
57 This will be picked up by 'notmuch new' and all new mail added to the\r
58 database will be tagged with the two tags as before.\r
59 \r
60 If the user already has a configuration file and runs 'notmuch setup'\r
61 then we just copy whatever tags we find in the old configuration file\r
62 to the new one. If there are no tags in the old configuration file then\r
63 we assume that the user configured notmuch that way and the new config\r
64 file would also have no tags in the section [new].\r
65 \r
66 We never ask the user interactively for the list of tags to be used by\r
67 'notmuch new', it is assumed that beginners would want to stick to the\r
68 defaults and advanced users can edit the configuration manually.\r
69 \r
70 This revision of the patch includes suggestions from Bart Trojanowski.\r
71 \r
72 Signed-off-by: Jan Janak <jan@ryngle.com>\r
73 ---\r
74  notmuch-client.h |    4 ++++\r
75  notmuch-config.c |   40 ++++++++++++++++++++++++++++++++++++++++\r
76  notmuch-setup.c  |   18 ++++++++++++++----\r
77  3 files changed, 58 insertions(+), 4 deletions(-)\r
78 \r
79 diff --git a/notmuch-client.h b/notmuch-client.h\r
80 index 0fb9c19..bb7d3d4 100644\r
81 --- a/notmuch-client.h\r
82 +++ b/notmuch-client.h\r
83 @@ -187,6 +187,10 @@ notmuch_config_set_user_other_email (notmuch_config_t *config,\r
84  char **\r
85  notmuch_config_get_new_tags (notmuch_config_t *config, size_t *length);\r
86  \r
87 +void\r
88 +notmuch_config_set_new_tags (notmuch_config_t *config, const char *tags[],\r
89 +                            size_t length);\r
90 +\r
91  notmuch_bool_t\r
92  debugger_is_active (void);\r
93  \r
94 diff --git a/notmuch-config.c b/notmuch-config.c\r
95 index 57072ce..2bbeb20 100644\r
96 --- a/notmuch-config.c\r
97 +++ b/notmuch-config.c\r
98 @@ -54,6 +54,16 @@ static const char user_config_comment[] =\r
99      " recipient list of replies, and will set the From address based on the\n"\r
100      " address to which the original email was addressed.\n";\r
101  \r
102 +static const char new_config_comment[] =\r
103 +    " Configuration section for 'notmuch new'\n"\r
104 +    "\n"\r
105 +    " The only supported value at the moment is 'tags. This option contains a\n"\r
106 +    " list of tags (separated by ';') that should be  automatically applied to\n"\r
107 +    " newly added messages.\n"\r
108 +    "\n"\r
109 +    " Note that 'notmuch new' also has a command line option which can be used\n"\r
110 +    " to add additional tags to the ones configured here.\n";\r
111 +\r
112  struct _notmuch_config {\r
113      char *filename;\r
114      GKeyFile *key_file;\r
115 @@ -174,6 +184,7 @@ notmuch_config_open (void *ctx,\r
116      GError *error = NULL;\r
117      int is_new = 0;\r
118      char *notmuch_config_env = NULL;\r
119 +    const char* def_new_tags[2] = {"inbox", "unread"};\r
120  \r
121      if (is_new_ret)\r
122         *is_new_ret = 0;\r
123 @@ -270,6 +281,20 @@ notmuch_config_open (void *ctx,\r
124         }\r
125      }\r
126  \r
127 +    /* If we have no configuration file then we configure "inbox" and "unread"\r
128 +     * tags by default for 'notmuch new'. This ensures that the Emacs mode\r
129 +     * would still work as expected.\r
130 +     *\r
131 +     * We do not ask the user for tags to be used by 'notmuch new'. That's too\r
132 +     * much detail for beginners and others can edit the configuration file by\r
133 +     * hand.\r
134 +     */\r
135 +    if (is_new) {\r
136 +       notmuch_config_set_new_tags (config, def_new_tags,\r
137 +                                    sizeof(def_new_tags) /\r
138 +                                    sizeof(const char*));\r
139 +    }\r
140 +\r
141      /* When we create a new configuration file here, we  add some\r
142       * comments to help the user understand what can be done. */\r
143      if (is_new) {\r
144 @@ -279,6 +304,8 @@ notmuch_config_open (void *ctx,\r
145                                 database_config_comment, NULL);\r
146         g_key_file_set_comment (config->key_file, "user", NULL,\r
147                                 user_config_comment, NULL);\r
148 +       g_key_file_set_comment (config->key_file, "new", NULL,\r
149 +                               new_config_comment, NULL);\r
150      }\r
151  \r
152      if (is_new_ret)\r
153 @@ -493,3 +520,16 @@ notmuch_config_get_new_tags (notmuch_config_t *config, size_t *length)\r
154      *length = config->new_tags_length;\r
155      return config->new_tags;\r
156  }\r
157 +\r
158 +void\r
159 +notmuch_config_set_new_tags (notmuch_config_t *config,\r
160 +                            const char *tags[],\r
161 +                            size_t length)\r
162 +{\r
163 +    g_key_file_set_string_list (config->key_file,\r
164 +                               "new", "tags",\r
165 +                               tags, length);\r
166 +\r
167 +    talloc_free (config->new_tags);\r
168 +    config->user_other_email = NULL;\r
169 +}\r
170 diff --git a/notmuch-setup.c b/notmuch-setup.c\r
171 index d06fbf8..aeffb88 100644\r
172 --- a/notmuch-setup.c\r
173 +++ b/notmuch-setup.c\r
174 @@ -92,12 +92,10 @@ notmuch_setup_command (unused (void *ctx),\r
175                        unused (int argc), unused (char *argv[]))\r
176  {\r
177      char *response = NULL;\r
178 -    size_t response_size;\r
179 +    size_t response_size, old_other_emails_len, new_tags_len, i;\r
180      notmuch_config_t *config;\r
181 -    char **old_other_emails;\r
182 -    size_t old_other_emails_len;\r
183 +    char **old_other_emails, **new_tags;\r
184      GPtrArray *other_emails;\r
185 -    unsigned int i;\r
186      int is_new;\r
187  \r
188  #define prompt(format, ...)                            \\r
189 @@ -147,6 +145,18 @@ notmuch_setup_command (unused (void *ctx),\r
190                                              other_emails->len);\r
191      g_ptr_array_free (other_emails, TRUE);\r
192  \r
193 +    /* If we already have a configuration file then we preserve the tags\r
194 +     * configured there. If the original configuration file contains no tags\r
195 +     * then we assume that the user configured it that way and add no tags.\r
196 +     */\r
197 +    if (!is_new) {\r
198 +       new_tags = notmuch_config_get_new_tags (config, &new_tags_len);\r
199 +       if (new_tags) {\r
200 +           notmuch_config_set_new_tags (config, (const char**)new_tags,\r
201 +                                        new_tags_len);\r
202 +       }\r
203 +    }\r
204 +\r
205      prompt ("Top-level directory of your email archive [%s]: ",\r
206             notmuch_config_get_database_path (config));\r
207      if (strlen (response)) {\r
208 -- \r
209 1.6.3.3\r
210 \r