aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-new.c
diff options
context:
space:
mode:
authorGravatar Ben Gamari <bgamari.foss@gmail.com>2010-03-12 17:13:26 -0500
committerGravatar Carl Worth <cworth@cworth.org>2010-04-23 08:41:59 -0700
commit143d43687410aefec7988e2d785a63c60c6062b5 (patch)
tree2556a5ed4281da0250c6b1e4897c875146e8ce26 /notmuch-new.c
parentaf8664689ac66b2ee79c904c6483f1172768da39 (diff)
notmuch-config: make new message tags configurable
Add a new_tags option in the [messages] section of the configuration file to allow the user to specify which tags should be added to new messages by notmuch new.
Diffstat (limited to 'notmuch-new.c')
-rw-r--r--notmuch-new.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/notmuch-new.c b/notmuch-new.c
index 484d9462..6432c664 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -35,6 +35,8 @@ typedef struct _filename_list {
typedef struct {
int output_is_a_tty;
int verbose;
+ char **new_tags;
+ size_t new_tags_length;
int total_files;
int processed_files;
@@ -94,13 +96,6 @@ _filename_list_add (_filename_list_t *list,
}
static void
-tag_inbox_and_unread (notmuch_message_t *message)
-{
- notmuch_message_add_tag (message, "inbox");
- notmuch_message_add_tag (message, "unread");
-}
-
-static void
add_files_print_progress (add_files_state_t *state)
{
struct timeval tv_now;
@@ -222,6 +217,7 @@ add_files_recursive (notmuch_database_t *notmuch,
notmuch_filenames_t *db_subdirs = NULL;
struct stat st;
notmuch_bool_t is_maildir, new_directory;
+ const char **tag;
if (stat (path, &st)) {
fprintf (stderr, "Error reading directory %s: %s\n",
@@ -412,7 +408,8 @@ add_files_recursive (notmuch_database_t *notmuch,
/* success */
case NOTMUCH_STATUS_SUCCESS:
state->added_messages++;
- tag_inbox_and_unread (message);
+ for (tag=state->new_tags; *tag != NULL; tag++)
+ notmuch_message_add_tag (message, *tag);
break;
/* Non-fatal issues (go on to next file) */
case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
@@ -739,6 +736,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
if (config == NULL)
return 1;
+ add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
db_path = notmuch_config_get_database_path (config);
dot_notmuch_path = talloc_asprintf (ctx, "%s/%s", db_path, ".notmuch");