IMAP clients (such as webmail) use folders to mark messages as junk
etc., some even to mark messages as trash ("move to trash"). Such a
change is reported by notmuch as a rename; the message is not tagged
with new.tags since it is not new, so that there is no way to act upon a
rename.
Introduce new.rename_tags (default: not set) which are added by `notmuch
new` to renamed messages. This allows to act upon renames, e.g. to keep
the IMAP folder structure in sync with tags with a tool like `afew` or
homecooked scripts simply by filtering for this tag in the same ways as
one would filter for new messages using new.tags.
Signed-off-by: Michael J Gruber
---
NEWS| 11 +++
doc/man1/notmuch-config.rst | 6 ++
notmuch-client.h| 8
notmuch-config.c| 26 ++
notmuch-new.c | 23 +++
5 files changed, 74 insertions(+)
diff --git a/NEWS b/NEWS
index 240d594b..e3b75e74 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,14 @@
+Notmuch 0.28 (UNRELEASED)
+=
+
+New command-line features
+-
+
+User-configurable tags for renamed messages
+
+ A new "new.rename_tags" option is available in the configuration file to
+ determine which tags are applied to renamed (moved) messages.
+
Notmuch 0.27 (2018-06-13)
=
diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
index 89909808..9e4198a1 100644
--- a/doc/man1/notmuch-config.rst
+++ b/doc/man1/notmuch-config.rst
@@ -77,6 +77,12 @@ The available configuration items are described below.
Default: ``unread;inbox``.
+**new.rename_tags**
+A list of tags that will be added to all messages which
+**notmuch new** identifies as renamed (moved).
+
+Default: not set.
+
**new.ignore**
A list to specify files and directories that will not be searched
for messages by **notmuch new**. Each entry in the list is either:
diff --git a/notmuch-client.h b/notmuch-client.h
index 6c84ecc0..5e1e6b66 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -316,6 +316,14 @@ notmuch_config_set_new_tags (notmuch_config_t *config,
const char *new_tags[],
size_t length);
+const char **
+notmuch_config_get_rename_tags (notmuch_config_t *config,
+size_t *length);
+void
+notmuch_config_set_rename_tags (notmuch_config_t *config,
+const char *rename_tags[],
+size_t length);
+
const char **
notmuch_config_get_new_ignore (notmuch_config_t *config,
size_t *length);
diff --git a/notmuch-config.c b/notmuch-config.c
index e1b16609..02f7d247 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -132,6 +132,8 @@ struct _notmuch_config {
size_t user_other_email_length;
const char **new_tags;
size_t new_tags_length;
+const char **rename_tags;
+size_t rename_tags_length;
const char **new_ignore;
size_t new_ignore_length;
bool maildir_synchronize_flags;
@@ -712,6 +714,14 @@ notmuch_config_get_new_tags (notmuch_config_t *config,
size_t *length)
&(config->new_tags_length), length);
}
+const char **
+notmuch_config_get_rename_tags (notmuch_config_t *config, size_t *length)
+{
+return _config_get_list (config, "new", "rename_tags",
+&(config->rename_tags),
+&(config->rename_tags_length), length);
+}
+
const char **
notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length)
{
@@ -738,6 +748,15 @@ notmuch_config_set_new_tags (notmuch_config_t *config,
&(config->new_tags));
}
+void
+notmuch_config_set_rename_tags (notmuch_config_t *config,
+const char *list[],
+size_t length)
+{
+_config_set_list (config, "new", "rename_tags", list, length,
+&(config->rename_tags));
+}
+
void
notmuch_config_set_new_ignore (notmuch_config_t *config,
const char *list[],
@@ -867,6 +886,13 @@ notmuch_config_command_get (notmuch_config_t *config, char
*item)
tags = notmuch_config_get_new_tags (config, &length);
for (i = 0; i < length; i++)
printf ("%s\n", tags[i]);
+} else if (strcmp(item, "new.rename_tags") == 0) {
+ const char **tags;
+ size_t i, length;
+
+ tags = notmuch_config_get_rename_tags (config, &length);
+ for (i = 0; i < length; i++)
+ printf ("%s\n", tags[i]);
} else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
printf ("%s\n",
notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true"
: "false");
diff --git a/notmuch-new.c b/notmuch-new.c
index 6a54a1a1..e6d3dc82 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -50,6