1 Return-Path: <anthony.j.towns@gmail.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 043224196F2
\r
6 for <notmuch@notmuchmail.org>; Sat, 10 Apr 2010 08:03:07 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id EUKbabgtfdu2 for <notmuch@notmuchmail.org>;
\r
17 Sat, 10 Apr 2010 08:03:06 -0700 (PDT)
\r
18 Received: from mail-yw0-f187.google.com (mail-yw0-f187.google.com
\r
20 by olra.theworths.org (Postfix) with ESMTP id D6FEE431FC1
\r
21 for <notmuch@notmuchmail.org>; Sat, 10 Apr 2010 08:03:05 -0700 (PDT)
\r
22 Received: by ywh17 with SMTP id 17so816203ywh.22
\r
23 for <notmuch@notmuchmail.org>; Sat, 10 Apr 2010 08:03:05 -0700 (PDT)
\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
25 h=domainkey-signature:mime-version:sender:received:date
\r
26 :x-google-sender-auth:received:message-id:subject:from:to
\r
27 :content-type; bh=WQWH5nAUZwnz1o9Vj12pWs+XAS/tDeOKUqxcSY6dHPk=;
\r
28 b=fEj49pk9mMO4GLMRZgHE/Ahb8g+aeM6k0TJaOZCOSS5V/Xn3+NbBftw7nyA0PJwubb
\r
29 AcWcWRhdEPqdkOAuFJQQB6W+6mtiyWVuPUDBVkQITIX98dz95lXSrRDXv5eyXmIdvCWa
\r
30 C1KLKft/CL4O7GKxJqkbL8nFfoKOJdG1cAb04=
\r
31 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
\r
32 h=mime-version:sender:date:x-google-sender-auth:message-id:subject
\r
33 :from:to:content-type;
\r
34 b=kPGxo3HrT3L/NQrGHPPy7Ls4bQ/osUPUKKZg0Z+cGpYv0NW5jfD9tO0Qw/wA4BoWmo
\r
35 FM4IC6/lg8vIvp2GXictL19ln3RCZ09fz8caxpe3/BI/XbdbtqwI2KfW1cFD6jJZ/HeL
\r
36 tXcMh/qzhgPz8QVAT/HKUPq4J51WYcCfHfWh8=
\r
38 Sender: anthony.j.towns@gmail.com
\r
39 Received: by 10.90.114.1 with HTTP; Sat, 10 Apr 2010 08:03:04 -0700 (PDT)
\r
40 Date: Sun, 11 Apr 2010 01:03:04 +1000
\r
41 X-Google-Sender-Auth: 5bef8ae0e3f058d7
\r
42 Received: by 10.91.1.2 with SMTP id d2mr680895agi.121.1270911784490; Sat, 10
\r
43 Apr 2010 08:03:04 -0700 (PDT)
\r
44 Message-ID: <n2x87b3a4191004100803z9d4c4c2bp52f5cf0d7b712362@mail.gmail.com>
\r
45 Subject: [PATCH] notmuch new --new-tags=tags...
\r
46 From: Anthony Towns <aj@erisian.com.au>
\r
47 To: notmuch <notmuch@notmuchmail.org>
\r
48 Content-Type: text/plain; charset=ISO-8859-1
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Sat, 10 Apr 2010 15:03:07 -0000
\r
65 The attached patch makes "notmuch new --new-tags=unread,new" set the
\r
66 "unread" and "new" tags on any new mail it finds rather than "unread"
\r
67 and "inbox". Or whatever other tags you happen to specify.
\r
69 Signed-off-by: Anthony Towns <aj@erisian.com.au>
\r
72 notmuch-new.c | 49 +++++++++++++++++++++++++++++++++++++++++++++----
\r
73 notmuch.1 | 19 ++++++++++++++++++-
\r
74 notmuch.c | 7 ++++++-
\r
75 4 files changed, 72 insertions(+), 6 deletions(-)
\r
77 diff --git a/NEWS b/NEWS
\r
78 index f29ac27..cbfae5a 100644
\r
82 +The "notmuch new" command accepts a "--new-tags=tags..." option to override
\r
83 +the default tags applied to new mail.
\r
85 Notmuch 0.1 (2010-04-05)
\r
86 ========================
\r
87 This is the first release of the notmuch mail system.
\r
88 diff --git a/notmuch-new.c b/notmuch-new.c
\r
89 index 44b50aa..77c99e0 100644
\r
92 @@ -32,6 +32,11 @@ typedef struct _filename_list {
\r
93 _filename_node_t **tail;
\r
96 +typedef struct _tag_list {
\r
98 + struct _tag_list *next;
\r
102 int output_is_a_tty;
\r
104 @@ -41,6 +46,8 @@ typedef struct {
\r
105 int added_messages;
\r
106 struct timeval tv_start;
\r
108 + _tag_list_t *new_msg_tags;
\r
110 _filename_list_t *removed_files;
\r
111 _filename_list_t *removed_directories;
\r
112 } add_files_state_t;
\r
113 @@ -93,11 +100,40 @@ _filename_list_add (_filename_list_t *list,
\r
114 list->tail = &node->next;
\r
117 +static _tag_list_t *
\r
118 +_parse_tags (void *ctx, const char *orig_str)
\r
120 + _tag_list_t *tag_head = NULL, **tag_tail = &tag_head;
\r
121 + char *dupe_str, *start, *comma;
\r
123 + dupe_str = talloc_strdup(ctx, orig_str);
\r
124 + start = dupe_str;
\r
127 + comma = strchr(start, ',');
\r
129 + *(comma++) = '\0';
\r
131 + if (*start != '\0') {
\r
132 + *tag_tail = talloc(dupe_str, _tag_list_t);
\r
133 + (*tag_tail)->tag = start;
\r
134 + (*tag_tail)->next = NULL;
\r
135 + tag_tail = &(*tag_tail)->next;
\r
145 -tag_inbox_and_unread (notmuch_message_t *message)
\r
146 +tag_new_message (add_files_state_t *state, notmuch_message_t *message)
\r
148 - notmuch_message_add_tag (message, "inbox");
\r
149 - notmuch_message_add_tag (message, "unread");
\r
150 + _tag_list_t *cur;
\r
151 + for (cur = state->new_msg_tags; cur; cur = cur->next) {
\r
152 + notmuch_message_add_tag (message, cur->tag);
\r
157 @@ -412,7 +448,7 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
159 case NOTMUCH_STATUS_SUCCESS:
\r
160 state->added_messages++;
\r
161 - tag_inbox_and_unread (message);
\r
162 + tag_new_message (state, message);
\r
164 /* Non-fatal issues (go on to next file) */
\r
165 case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
\r
166 @@ -714,6 +750,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
168 const char *db_path;
\r
169 char *dot_notmuch_path;
\r
170 + const char *new_msg_tags = "inbox,unread";
\r
171 struct sigaction action;
\r
172 _filename_node_t *f;
\r
173 int renamed_files, removed_files;
\r
174 @@ -726,12 +763,16 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
175 for (i = 0; i < argc && argv[i][0] == '-'; i++) {
\r
176 if (STRNCMP_LITERAL (argv[i], "--verbose") == 0) {
\r
177 add_files_state.verbose = 1;
\r
178 + } else if (STRNCMP_LITERAL (argv[i], "--new-tags=") == 0) {
\r
179 + new_msg_tags = argv[i]+strlen("--new-tags=");
\r
181 fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
\r
186 + add_files_state.new_msg_tags = _parse_tags(ctx, new_msg_tags);
\r
188 config = notmuch_config_open (ctx, NULL, NULL);
\r
189 if (config == NULL)
\r
191 diff --git a/notmuch.1 b/notmuch.1
\r
192 index 86830f4..3bab17c 100644
\r
195 @@ -85,7 +85,7 @@ The
\r
196 command is used to incorporate new mail into the notmuch database.
\r
200 +.BR new " [options...]"
\r
202 Find and import any new messages to the database.
\r
204 @@ -109,6 +109,23 @@ whenever new mail is delivered and you wish to
\r
205 incorporate it into the
\r
206 database. These subsequent runs will be much quicker than the initial
\r
209 +Supported options for
\r
214 +.BR \-\-new\-tags= tags...
\r
216 +Set the listed tags (separated by commas) on new messages
\r
217 +instead of the default
\r
228 with no command argument will run
\r
229 diff --git a/notmuch.c b/notmuch.c
\r
230 index dcfda32..f7b16e3 100644
\r
233 @@ -126,7 +126,7 @@ command_t commands[] = {
\r
234 "\tInvoking notmuch with no command argument will run setup if\n"
\r
235 "\tthe setup command has not previously been completed." },
\r
236 { "new", notmuch_new_command,
\r
238 + "[--verbose] [--new-tags=inbox,unread]",
\r
239 "Find and import new messages to the notmuch database.",
\r
240 "\tScans all sub-directories of the mail directory, performing\n"
\r
241 "\tfull-text indexing on new messages that are found. Each new\n"
\r
242 @@ -148,6 +148,11 @@ command_t commands[] = {
\r
243 "\t\tVerbose operation. Shows paths of message files as\n"
\r
244 "\t\tthey are being indexed.\n"
\r
246 + "\t--new-tags=tags...\n"
\r
248 + "\t\tSet the listed tags (separated by commas) on new messages\n"
\r
249 + "\t\tinstead of the default \"inbox\" and \"unread\" tags.\n"
\r
251 "\tInvoking notmuch with no command argument will run new if\n"
\r
252 "\tthe setup command has previously been completed, but new has\n"
\r
253 "\tnot previously been run." },
\r