1 Return-Path: <dme@hotblack-desiato.hh.sledj.net>
\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 2DDF9429E34
\r
6 for <notmuch@notmuchmail.org>; Fri, 2 May 2014 01:23:33 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.379 tagged_above=-999 required=5
\r
12 tests=[NO_DNS_FOR_FROM=0.379] 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 p-mRLSGE+BAP for <notmuch@notmuchmail.org>;
\r
16 Fri, 2 May 2014 01:23:28 -0700 (PDT)
\r
17 Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net
\r
19 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 944F1431FCF
\r
22 for <notmuch@notmuchmail.org>; Fri, 2 May 2014 01:23:17 -0700 (PDT)
\r
23 Received: from hotblack-desiato.hh.sledj.net (hotblack-desiato.hh.sledj.net
\r
25 by disaster-area.hh.sledj.net (Postfix) with ESMTPSA id DB7825005F2;
\r
26 Fri, 2 May 2014 09:16:11 +0100 (BST)
\r
27 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
28 id BC04E103453; Fri, 2 May 2014 09:16:10 +0100 (BST)
\r
29 From: David Edmondson <dme@dme.org>
\r
30 To: notmuch@notmuchmail.org
\r
31 Subject: [PATCH 1/5] notmuch-new: Use tag_op_list_apply() rather than
\r
32 hand-coding the same.
\r
33 Date: Fri, 2 May 2014 09:15:51 +0100
\r
34 Message-Id: <1399018555-1994-2-git-send-email-dme@dme.org>
\r
35 X-Mailer: git-send-email 1.9.2
\r
36 In-Reply-To: <1399018555-1994-1-git-send-email-dme@dme.org>
\r
37 References: <1399018555-1994-1-git-send-email-dme@dme.org>
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.13
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Fri, 02 May 2014 08:23:33 -0000
\r
52 Rather than hand-coding the application of tags to new messages, use
\r
53 the existing tag_op_list_apply().
\r
55 notmuch-new.c | 31 ++++++++++++++++---------------
\r
56 1 file changed, 16 insertions(+), 15 deletions(-)
\r
58 diff --git a/notmuch-new.c b/notmuch-new.c
\r
59 index d269c7c..b53401a 100644
\r
62 @@ -45,10 +45,9 @@ typedef struct {
\r
63 int output_is_a_tty;
\r
64 enum verbosity verbosity;
\r
65 notmuch_bool_t debug;
\r
66 - const char **new_tags;
\r
67 - size_t new_tags_length;
\r
68 const char **new_ignore;
\r
69 size_t new_ignore_length;
\r
70 + tag_op_list_t *tag_ops;
\r
73 int processed_files;
\r
74 @@ -253,7 +252,6 @@ add_file (notmuch_database_t *notmuch, const char *filename,
\r
75 add_files_state_t *state)
\r
77 notmuch_message_t *message = NULL;
\r
79 notmuch_status_t status;
\r
81 status = notmuch_database_begin_atomic (notmuch);
\r
82 @@ -263,14 +261,13 @@ add_file (notmuch_database_t *notmuch, const char *filename,
\r
83 status = notmuch_database_add_message (notmuch, filename, &message);
\r
86 - case NOTMUCH_STATUS_SUCCESS:
\r
87 - state->added_messages++;
\r
88 - notmuch_message_freeze (message);
\r
89 - for (tag = state->new_tags; *tag != NULL; tag++)
\r
90 - notmuch_message_add_tag (message, *tag);
\r
91 + case NOTMUCH_STATUS_SUCCESS:;
\r
92 + tag_op_flag_t flags = 0;
\r
94 if (state->synchronize_flags)
\r
95 - notmuch_message_maildir_flags_to_tags (message);
\r
96 - notmuch_message_thaw (message);
\r
97 + flags |= TAG_FLAG_MAILDIR_SYNC;
\r
98 + state->added_messages++;
\r
99 + (void) tag_op_list_apply (message, state->tag_ops, flags);
\r
101 /* Non-fatal issues (go on to next file). */
\r
102 case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
\r
103 @@ -923,6 +920,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
104 notmuch_bool_t timer_is_active = FALSE;
\r
105 notmuch_bool_t no_hooks = FALSE;
\r
106 notmuch_bool_t quiet = FALSE, verbose = FALSE;
\r
107 + const char **new_tags;
\r
108 + size_t new_tags_length;
\r
110 add_files_state.verbosity = VERBOSITY_NORMAL;
\r
111 add_files_state.debug = FALSE;
\r
112 @@ -946,20 +945,22 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
\r
114 add_files_state.verbosity = VERBOSITY_VERBOSE;
\r
116 - add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
117 + new_tags = notmuch_config_get_new_tags (config, &new_tags_length);
\r
118 add_files_state.new_ignore = notmuch_config_get_new_ignore (config, &add_files_state.new_ignore_length);
\r
119 add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
120 + add_files_state.tag_ops = tag_op_list_create (config);
\r
121 db_path = notmuch_config_get_database_path (config);
\r
123 - for (i = 0; i < add_files_state.new_tags_length; i++) {
\r
124 + for (i = 0; i < new_tags_length; i++) {
\r
125 const char *error_msg;
\r
127 - error_msg = illegal_tag (add_files_state.new_tags[i], FALSE);
\r
128 + error_msg = illegal_tag (new_tags[i], FALSE);
\r
130 - fprintf (stderr, "Error: tag '%s' in new.tags: %s\n",
\r
131 - add_files_state.new_tags[i], error_msg);
\r
132 + fprintf (stderr, "Error: tag '%s' in new.tags: %s\n", new_tags[i], error_msg);
\r
133 return EXIT_FAILURE;
\r
135 + if (tag_op_list_append (add_files_state.tag_ops, new_tags[i], FALSE) != 0)
\r
136 + return EXIT_FAILURE;
\r