From 143d43687410aefec7988e2d785a63c60c6062b5 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 12 Mar 2010 17:13:26 -0500 Subject: 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. --- notmuch-new.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'notmuch-new.c') 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; @@ -93,13 +95,6 @@ _filename_list_add (_filename_list_t *list, list->tail = &node->next; } -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) { @@ -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"); -- cgit v1.2.3