1 Return-Path: <eg@gaute.vetsj.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 06615431FBC
\r
6 for <notmuch@notmuchmail.org>; Sun, 6 Apr 2014 09:12:55 -0700 (PDT)
\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 Z1fBRpAvTIbu for <notmuch@notmuchmail.org>;
\r
16 Sun, 6 Apr 2014 09:12:47 -0700 (PDT)
\r
17 Received: from mail-we0-f171.google.com (mail-we0-f171.google.com
\r
18 [74.125.82.171]) (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 D7A18431FB6
\r
21 for <notmuch@notmuchmail.org>; Sun, 6 Apr 2014 09:12:46 -0700 (PDT)
\r
22 Received: by mail-we0-f171.google.com with SMTP id t61so5674112wes.16
\r
23 for <notmuch@notmuchmail.org>; Sun, 06 Apr 2014 09:12:44 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=1e100.net; s=20130820;
\r
26 h=x-gm-message-state:from:to:cc:subject:date:message-id;
\r
27 bh=xnlWSPwhR6JuK24gvecKiujzIIJJTGKqVWuvlipNrTs=;
\r
28 b=BWCRKj7zlVxRuZv24KkyFYKLFkkzLlynPhJ4E1TCn5+xGP1+gbk4tHo1f7khGbDTe2
\r
29 sG82IYt1bQYf1ILgSLSRWaLEdf1X54bo2rjs+xC1LvbmlWyqbi0K6gDoPiwrXCm6O+eK
\r
30 CgjOxEWuabBoOpCpCTZeTA05MafQ1zaOhZP6SgBbK2lzWtXxwOT20pwdnAnDt5cCywn5
\r
31 7M2fWeAvBLgPsVAirSEwy7NSIat1fALWq4lpiEoUESXcWo+YOjxLeYRBGxQbNKzx0dLP
\r
32 5kWqLUR66ZfCp9n2kee6r7c/I+27i+U8bVP1412tyVESBVwMaQZaZUuszi2Ifuo1BhZH
\r
35 ALoCoQk8QRRKz3SqUix/D50k1MZQ2lnvwQckV84OmQy2mmklENBMzDJrB8kUSOTrAx2KK2gtPD3T
\r
36 X-Received: by 10.194.48.80 with SMTP id j16mr36104947wjn.44.1396800764024;
\r
37 Sun, 06 Apr 2014 09:12:44 -0700 (PDT)
\r
38 Received: from localhost ([188.113.84.221])
\r
39 by mx.google.com with ESMTPSA id n41sm35458956eeg.4.2014.04.06.09.12.42
\r
40 for <multiple recipients>
\r
41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
42 Sun, 06 Apr 2014 09:12:43 -0700 (PDT)
\r
43 From: Gaute Hope <eg@gaute.vetsj.com>
\r
44 To: notmuch@notmuchmail.org
\r
45 Subject: [PATCH] Add configurable changed tag to messages that have been
\r
47 Date: Sun, 6 Apr 2014 18:11:23 +0200
\r
48 Message-Id: <1396800683-9164-1-git-send-email-eg@gaute.vetsj.com>
\r
49 X-Mailer: git-send-email 1.9.1
\r
50 X-BeenThere: notmuch@notmuchmail.org
\r
51 X-Mailman-Version: 2.1.13
\r
53 List-Id: "Use and development of the notmuch mail system."
\r
54 <notmuch.notmuchmail.org>
\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
58 List-Post: <mailto:notmuch@notmuchmail.org>
\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
62 X-List-Received-Date: Sun, 06 Apr 2014 16:12:55 -0000
\r
64 When one of the source files for a message is changed on disk, renamed,
\r
65 deleted or a new source file is added. A configurable changed tag is
\r
66 is added. The tag can be configured under the option 'changed_tags' in
\r
67 the [new] section, the default is none. Tests have been updated to
\r
68 accept the new config option.
\r
70 notmuch-setup now asks for a changed tag after the new tags question.
\r
72 This could be useful for for example 'afew' to detect remote changes in
\r
73 IMAP folders and update the FolderNameFilter to also add tags or remove
\r
74 tags when a _existing_ message has been added to or removed from a
\r
77 notmuch-client.h | 8 ++++++++
\r
78 notmuch-config.c | 42 ++++++++++++++++++++++++++++++++++++++----
\r
79 notmuch-new.c | 34 +++++++++++++++++++++++++++++-----
\r
80 notmuch-setup.c | 17 +++++++++++++++++
\r
81 test/T030-config.sh | 1 +
\r
82 test/T040-setup.sh | 2 ++
\r
83 6 files changed, 95 insertions(+), 9 deletions(-)
\r
85 diff --git a/notmuch-client.h b/notmuch-client.h
\r
86 index d110648..8b60645 100644
\r
87 --- a/notmuch-client.h
\r
88 +++ b/notmuch-client.h
\r
89 @@ -314,6 +314,14 @@ notmuch_config_set_new_ignore (notmuch_config_t *config,
\r
90 const char *new_ignore[],
\r
94 +notmuch_config_get_changed_tags (notmuch_config_t *config,
\r
97 +notmuch_config_set_changed_tags (notmuch_config_t *config,
\r
98 + const char *changed_tags[],
\r
102 notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config);
\r
104 diff --git a/notmuch-config.c b/notmuch-config.c
\r
105 index 8d28653..5ea0635 100644
\r
106 --- a/notmuch-config.c
\r
107 +++ b/notmuch-config.c
\r
108 @@ -51,7 +51,11 @@ static const char new_config_comment[] =
\r
110 "\t NOTE: *Every* file/directory that goes by one of those\n"
\r
111 "\t names will be ignored, independent of its depth/location\n"
\r
112 - "\t in the mail store.\n";
\r
113 + "\t in the mail store.\n"
\r
115 + "\tchanged_tags A list (separated by ';') of tags that will be\n"
\r
116 + "\t added to messages where a one or more of its source files have\n"
\r
117 + "\t have been changed (added, renamed or deleted).\n";
\r
119 static const char user_config_comment[] =
\r
120 " User configuration\n"
\r
121 @@ -111,10 +115,15 @@ struct _notmuch_config {
\r
122 char *user_primary_email;
\r
123 const char **user_other_email;
\r
124 size_t user_other_email_length;
\r
126 const char **new_tags;
\r
127 size_t new_tags_length;
\r
128 const char **new_ignore;
\r
129 size_t new_ignore_length;
\r
131 + const char **changed_tags;
\r
132 + size_t changed_tags_length;
\r
134 notmuch_bool_t maildir_synchronize_flags;
\r
135 const char **search_exclude_tags;
\r
136 size_t search_exclude_tags_length;
\r
137 @@ -249,7 +258,7 @@ notmuch_config_open (void *ctx,
\r
138 fprintf (stderr, "Out of memory.\n");
\r
143 talloc_set_destructor (config, notmuch_config_destructor);
\r
146 @@ -273,6 +282,8 @@ notmuch_config_open (void *ctx,
\r
147 config->new_tags_length = 0;
\r
148 config->new_ignore = NULL;
\r
149 config->new_ignore_length = 0;
\r
150 + config->changed_tags = NULL;
\r
151 + config->changed_tags_length = 0;
\r
152 config->maildir_synchronize_flags = TRUE;
\r
153 config->search_exclude_tags = NULL;
\r
154 config->search_exclude_tags_length = 0;
\r
155 @@ -373,6 +384,10 @@ notmuch_config_open (void *ctx,
\r
156 notmuch_config_set_new_ignore (config, NULL, 0);
\r
159 + if (notmuch_config_get_changed_tags (config, &tmp) == NULL) {
\r
160 + notmuch_config_set_changed_tags (config, NULL, 0);
\r
163 if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) {
\r
164 if (config->is_new) {
\r
165 const char *tags[] = { "deleted", "spam" };
\r
166 @@ -422,7 +437,7 @@ notmuch_config_open (void *ctx,
\r
169 /* Close the given notmuch_config_t object, freeing all resources.
\r
172 * Note: Any changes made to the configuration are *not* saved by this
\r
173 * function. To save changes, call notmuch_config_save before
\r
174 * notmuch_config_close.
\r
175 @@ -631,6 +646,14 @@ notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length)
\r
176 &(config->new_ignore_length), length);
\r
180 +notmuch_config_get_changed_tags (notmuch_config_t *config, size_t *length)
\r
182 + return _config_get_list (config, "new", "changed_tags",
\r
183 + &(config->changed_tags),
\r
184 + &(config->changed_tags_length), length);
\r
188 notmuch_config_set_user_other_email (notmuch_config_t *config,
\r
189 const char *list[],
\r
190 @@ -658,6 +681,15 @@ notmuch_config_set_new_ignore (notmuch_config_t *config,
\r
191 &(config->new_ignore));
\r
195 +notmuch_config_set_changed_tags (notmuch_config_t *config,
\r
196 + const char *list[],
\r
199 + _config_set_list (config, "new", "changed_tags", list, length,
\r
200 + &(config->changed_tags));
\r
204 notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length)
\r
206 @@ -714,17 +746,19 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)
\r
207 } else if (strcmp(item, "user.other_email") == 0) {
\r
208 const char **other_email;
\r
212 other_email = notmuch_config_get_user_other_email (config, &length);
\r
213 for (i = 0; i < length; i++)
\r
214 printf ("%s\n", other_email[i]);
\r
215 } else if (strcmp(item, "new.tags") == 0) {
\r
220 tags = notmuch_config_get_new_tags (config, &length);
\r
221 for (i = 0; i < length; i++)
\r
222 printf ("%s\n", tags[i]);
\r
227 diff --git a/notmuch-new.c b/notmuch-new.c
\r
228 index 82acf69..db52961 100644
\r
229 --- a/notmuch-new.c
\r
230 +++ b/notmuch-new.c
\r
231 @@ -50,6 +50,9 @@ typedef struct {
\r
232 const char **new_ignore;
\r
233 size_t new_ignore_length;
\r
235 + const char **changed_tags;
\r
236 + size_t changed_tags_length;
\r
239 int processed_files;
\r
240 int added_messages, removed_messages, renamed_messages;
\r
241 @@ -274,8 +277,12 @@ add_file (notmuch_database_t *notmuch, const char *filename,
\r
243 /* Non-fatal issues (go on to next file). */
\r
244 case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
\r
245 + notmuch_message_freeze (message);
\r
246 + for (tag = state->changed_tags; *tag != NULL; tag++)
\r
247 + notmuch_message_add_tag (message, *tag);
\r
248 if (state->synchronize_flags)
\r
249 notmuch_message_maildir_flags_to_tags (message);
\r
250 + notmuch_message_thaw (message);
\r
252 case NOTMUCH_STATUS_FILE_NOT_EMAIL:
\r
253 fprintf (stderr, "Note: Ignoring non-mail file: %s\n", filename);
\r
254 @@ -809,13 +816,25 @@ remove_filename (notmuch_database_t *notmuch,
\r
256 status = notmuch_database_remove_message (notmuch, path);
\r
257 if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
\r
258 - add_files_state->renamed_messages++;
\r
259 - if (add_files_state->synchronize_flags == TRUE)
\r
260 - notmuch_message_maildir_flags_to_tags (message);
\r
261 - status = NOTMUCH_STATUS_SUCCESS;
\r
263 + add_files_state->renamed_messages++;
\r
265 + /* add changed tags */
\r
266 + const char **tag;
\r
267 + for (tag = add_files_state->changed_tags; *tag != NULL; tag++)
\r
268 + notmuch_message_add_tag (message, *tag);
\r
270 + if (add_files_state->synchronize_flags == TRUE)
\r
271 + notmuch_message_maildir_flags_to_tags (message);
\r
273 + status = NOTMUCH_STATUS_SUCCESS;
\r
275 } else if (status == NOTMUCH_STATUS_SUCCESS) {
\r
276 - add_files_state->removed_messages++;
\r
278 + add_files_state->removed_messages++;
\r
282 notmuch_message_destroy (message);
\r
285 @@ -946,8 +965,13 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
287 add_files_state.verbosity = VERBOSITY_VERBOSE;
\r
289 + /* tags for added files */
\r
290 add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
291 add_files_state.new_ignore = notmuch_config_get_new_ignore (config, &add_files_state.new_ignore_length);
\r
293 + /* tags for changed files */
\r
294 + add_files_state.changed_tags = notmuch_config_get_changed_tags (config, &add_files_state.changed_tags_length);
\r
296 add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
297 db_path = notmuch_config_get_database_path (config);
\r
299 diff --git a/notmuch-setup.c b/notmuch-setup.c
\r
300 index 36a6171..cf99ee0 100644
\r
301 --- a/notmuch-setup.c
\r
302 +++ b/notmuch-setup.c
\r
303 @@ -131,6 +131,8 @@ notmuch_setup_command (notmuch_config_t *config,
\r
305 const char **new_tags;
\r
306 size_t new_tags_len;
\r
307 + const char **changed_tags;
\r
308 + size_t changed_tags_len;
\r
309 const char **search_exclude_tags;
\r
310 size_t search_exclude_tags_len;
\r
312 @@ -206,6 +208,21 @@ notmuch_setup_command (notmuch_config_t *config,
\r
313 g_ptr_array_free (tags, TRUE);
\r
316 + changed_tags = notmuch_config_get_changed_tags (config, &changed_tags_len);
\r
318 + printf ("Tags to apply to all changed messages (separated by spaces) [");
\r
319 + print_tag_list (changed_tags, changed_tags_len);
\r
322 + if (strlen (response)) {
\r
323 + GPtrArray *tags = parse_tag_list (config, response);
\r
325 + notmuch_config_set_changed_tags (config, (const char **) tags->pdata,
\r
328 + g_ptr_array_free (tags, TRUE);
\r
332 search_exclude_tags = notmuch_config_get_search_exclude_tags (config, &search_exclude_tags_len);
\r
334 diff --git a/test/T030-config.sh b/test/T030-config.sh
\r
335 index ca4cf33..d1e095b 100755
\r
336 --- a/test/T030-config.sh
\r
337 +++ b/test/T030-config.sh
\r
338 @@ -52,6 +52,7 @@ user.primary_email=test_suite@notmuchmail.org
\r
339 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
\r
340 new.tags=unread;inbox;
\r
343 search.exclude_tags=
\r
344 maildir.synchronize_flags=true
\r
345 foo.string=this is another string value
\r
346 diff --git a/test/T040-setup.sh b/test/T040-setup.sh
\r
347 index 124ef1c..7e37ea1 100755
\r
348 --- a/test/T040-setup.sh
\r
349 +++ b/test/T040-setup.sh
\r
350 @@ -11,6 +11,7 @@ another.suite@example.com
\r
357 output=$(notmuch --config=new-notmuch-config config list)
\r
358 @@ -21,6 +22,7 @@ user.primary_email=test.suite@example.com
\r
359 user.other_email=another.suite@example.com;
\r
362 +new.changed_tags=chaz;
\r
363 search.exclude_tags=baz;
\r
364 maildir.synchronize_flags=true"
\r