1 Return-Path: <bgamari.foss@gmail.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 329404048D8
\r
6 for <notmuch@notmuchmail.org>; Fri, 12 Mar 2010 14:13:36 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.629 tagged_above=-999 required=5
\r
12 tests=[AWL=-0.030, BAYES_00=-2.599] autolearn=ham
\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 iIZs5KXUFgNU for <notmuch@notmuchmail.org>;
\r
16 Fri, 12 Mar 2010 14:13:34 -0800 (PST)
\r
17 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.154])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 90FED4048D4
\r
19 for <notmuch@notmuchmail.org>; Fri, 12 Mar 2010 14:13:34 -0800 (PST)
\r
20 Received: by fg-out-1718.google.com with SMTP id 19so464591fgg.2
\r
21 for <notmuch@notmuchmail.org>; Fri, 12 Mar 2010 14:13:33 -0800 (PST)
\r
22 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
23 h=domainkey-signature:received:received:from:to:cc:subject:date
\r
24 :message-id:x-mailer:in-reply-to:references;
\r
25 bh=67SxB7ZAH2Zg5SCtnuxfM4ixKO0iraBsSzjE+bJgABc=;
\r
26 b=Jj43PnwDe/R1GhgSTJDcHVi8Yt0xJ5VbDYoqHJZR+6+xtRQ719drDlVHvQzvVhN6eg
\r
27 I6FzrBDopfpv/9EW9wPhVTvs37I/mukuES0qbwBfHkn5c6RgJtW1k2RYcjngYxuaW0ON
\r
28 j2KUWHBKpDAZxuNu3Vgzbt43HhlxVVXthz/rY=
\r
29 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
\r
30 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
31 b=nYRd/mMnMPKy35I+MeafiNnn7w/At3Wb7HR3F5kngbW0gsTGcJX/0sjx5nxubg9FhM
\r
32 gbS/2pecuTgVR0jAiNZcq535Q2uSmutkga1h9PLe0cBK5S0MXKtcbwBnjMSUiw8HTaeB
\r
33 oOWyQeJLlc2+q7itQhSouYeug+FMLOVhZYsds=
\r
34 Received: by 10.103.126.31 with SMTP id d31mr3260791mun.49.1268432013873;
\r
35 Fri, 12 Mar 2010 14:13:33 -0800 (PST)
\r
36 Received: from localhost.localdomain (physnat56.physics.umass.edu
\r
38 by mx.google.com with ESMTPS id j9sm7141932mue.47.2010.03.12.14.13.32
\r
39 (version=SSLv3 cipher=RC4-MD5); Fri, 12 Mar 2010 14:13:33 -0800 (PST)
\r
40 From: Ben Gamari <bgamari.foss@gmail.com>
\r
41 To: notmuch <notmuch@notmuchmail.org>
\r
42 Date: Fri, 12 Mar 2010 17:13:26 -0500
\r
43 Message-Id: <1268432006-24333-2-git-send-email-bgamari.foss@gmail.com>
\r
44 X-Mailer: git-send-email 1.7.0.2
\r
45 In-Reply-To: <1268432006-24333-1-git-send-email-bgamari.foss@gmail.com>
\r
46 References: <1268432006-24333-1-git-send-email-bgamari.foss@gmail.com>
\r
47 Subject: [notmuch] [PATCH] notmuch-config: make new message tags configurable
\r
48 X-BeenThere: notmuch@notmuchmail.org
\r
49 X-Mailman-Version: 2.1.13
\r
51 List-Id: "Use and development of the notmuch mail system."
\r
52 <notmuch.notmuchmail.org>
\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
56 List-Post: <mailto:notmuch@notmuchmail.org>
\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
60 X-List-Received-Date: Fri, 12 Mar 2010 22:13:36 -0000
\r
62 Add a new_tags option in the [messages] section of the configuration
\r
63 file to allow the user to specify which tags should be added to new
\r
64 messages by notmuch new.
\r
66 notmuch-client.h | 8 ++++++
\r
67 notmuch-config.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
68 notmuch-new.c | 14 +++++------
\r
69 3 files changed, 77 insertions(+), 8 deletions(-)
\r
71 diff --git a/notmuch-client.h b/notmuch-client.h
\r
72 index c80b39c..1830584 100644
\r
73 --- a/notmuch-client.h
\r
74 +++ b/notmuch-client.h
\r
75 @@ -171,6 +171,14 @@ notmuch_config_set_user_other_email (notmuch_config_t *config,
\r
76 const char *other_email[],
\r
80 +notmuch_config_get_new_tags (notmuch_config_t *config,
\r
83 +notmuch_config_set_new_tags (notmuch_config_t *config,
\r
84 + const char *new_tags[],
\r
88 debugger_is_active (void);
\r
90 diff --git a/notmuch-config.c b/notmuch-config.c
\r
91 index 95430db..b492bc1 100644
\r
92 --- a/notmuch-config.c
\r
93 +++ b/notmuch-config.c
\r
94 @@ -37,6 +37,12 @@ static const char database_config_comment[] =
\r
95 " Notmuch will store its database within a sub-directory of the path\n"
\r
96 " configured here named \".notmuch\".\n";
\r
98 +static const char messages_config_comment[] =
\r
99 + " Messages configuration\n"
\r
101 + " The only value supported here is 'new_tags' which lists the tags that\n"
\r
102 + " should be applied to new messages.\n";
\r
104 static const char user_config_comment[] =
\r
105 " User configuration\n"
\r
107 @@ -62,6 +68,8 @@ struct _notmuch_config {
\r
108 char *user_primary_email;
\r
109 char **user_other_email;
\r
110 size_t user_other_email_length;
\r
112 + size_t new_tags_length;
\r
116 @@ -169,6 +177,7 @@ notmuch_config_open (void *ctx,
\r
118 GError *error = NULL;
\r
121 char *notmuch_config_env = NULL;
\r
124 @@ -199,6 +208,8 @@ notmuch_config_open (void *ctx,
\r
125 config->user_primary_email = NULL;
\r
126 config->user_other_email = NULL;
\r
127 config->user_other_email_length = 0;
\r
128 + config->new_tags = NULL;
\r
129 + config->new_tags_length = 0;
\r
131 if (! g_key_file_load_from_file (config->key_file,
\r
133 @@ -264,6 +275,11 @@ notmuch_config_open (void *ctx,
\r
137 + if (notmuch_config_get_new_tags (config, &tmp) == NULL) {
\r
138 + const char *tags[] = { "unread", "inbox" };
\r
139 + notmuch_config_set_new_tags (config, tags, 2);
\r
142 /* When we create a new configuration file here, we add some
\r
143 * comments to help the user understand what can be done. */
\r
145 @@ -271,6 +287,8 @@ notmuch_config_open (void *ctx,
\r
146 toplevel_config_comment, NULL);
\r
147 g_key_file_set_comment (config->key_file, "database", NULL,
\r
148 database_config_comment, NULL);
\r
149 + g_key_file_set_comment (config->key_file, "messages", NULL,
\r
150 + messages_config_comment, NULL);
\r
151 g_key_file_set_comment (config->key_file, "user", NULL,
\r
152 user_config_comment, NULL);
\r
154 @@ -452,3 +470,48 @@ notmuch_config_set_user_other_email (notmuch_config_t *config,
\r
155 talloc_free (config->user_other_email);
\r
156 config->user_other_email = NULL;
\r
160 +notmuch_config_get_new_tags (notmuch_config_t *config,
\r
164 + size_t tags_length;
\r
167 + if (config->new_tags == NULL) {
\r
168 + tags = g_key_file_get_string_list (config->key_file,
\r
169 + "messages", "new_tags",
\r
170 + &tags_length, NULL);
\r
172 + config->new_tags = talloc_size (config,
\r
173 + sizeof (char *) *
\r
174 + (tags_length + 1));
\r
175 + for (i = 0; i < tags_length; i++)
\r
176 + config->new_tags[i] = talloc_strdup (config->new_tags,
\r
178 + config->new_tags[i] = NULL;
\r
180 + g_strfreev (tags);
\r
182 + config->new_tags_length = tags_length;
\r
186 + *length = config->new_tags_length;
\r
187 + return config->new_tags;
\r
191 +notmuch_config_set_new_tags (notmuch_config_t *config,
\r
192 + const char *new_tags[],
\r
195 + g_key_file_set_string_list (config->key_file,
\r
196 + "messages", "new_tags",
\r
197 + new_tags, length);
\r
199 + talloc_free (config->new_tags);
\r
200 + config->new_tags = NULL;
\r
203 diff --git a/notmuch-new.c b/notmuch-new.c
\r
204 index 44b50aa..dd5a5a0 100644
\r
205 --- a/notmuch-new.c
\r
206 +++ b/notmuch-new.c
\r
207 @@ -35,6 +35,8 @@ typedef struct _filename_list {
\r
209 int output_is_a_tty;
\r
212 + size_t new_tags_length;
\r
215 int processed_files;
\r
216 @@ -94,13 +96,6 @@ _filename_list_add (_filename_list_t *list,
\r
220 -tag_inbox_and_unread (notmuch_message_t *message)
\r
222 - notmuch_message_add_tag (message, "inbox");
\r
223 - notmuch_message_add_tag (message, "unread");
\r
227 add_files_print_progress (add_files_state_t *state)
\r
229 struct timeval tv_now;
\r
230 @@ -222,6 +217,7 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
231 notmuch_filenames_t *db_subdirs = NULL;
\r
233 notmuch_bool_t is_maildir, new_directory;
\r
234 + const char **tag;
\r
236 if (stat (path, &st)) {
\r
237 fprintf (stderr, "Error reading directory %s: %s\n",
\r
238 @@ -412,7 +408,8 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
240 case NOTMUCH_STATUS_SUCCESS:
\r
241 state->added_messages++;
\r
242 - tag_inbox_and_unread (message);
\r
243 + for (tag=state->new_tags; *tag != NULL; tag++)
\r
244 + notmuch_message_add_tag (message, *tag);
\r
246 /* Non-fatal issues (go on to next file) */
\r
247 case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
\r
248 @@ -736,6 +733,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
249 if (config == NULL)
\r
252 + add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
253 db_path = notmuch_config_get_database_path (config);
\r
255 dot_notmuch_path = talloc_asprintf (ctx, "%s/%s", db_path, ".notmuch");
\r