1 Return-Path: <novalazy@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 B4CB2431FB6
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 17:18:13 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\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 xexACAUHANPC for <notmuch@notmuchmail.org>;
\r
17 Sat, 24 Nov 2012 17:18:12 -0800 (PST)
\r
18 Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com
\r
19 [209.85.220.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id BF89A431FAE
\r
22 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 17:18:12 -0800 (PST)
\r
23 Received: by mail-pa0-f53.google.com with SMTP id hz1so3911431pad.26
\r
24 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 17:18:12 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
27 bh=C/OKiYOj1R2YY88A/3izhtdqhpAObijV7xGH0v3i6zU=;
\r
28 b=pI5XW9ikv4pp/7MqnklEzKCBeNk9zrjt/YDt05pNaaakKB2EMqMf8gbqC7XbQ64dIr
\r
29 eH7kDLOijtf+07lxEPrBQBpRaVPHQX3DB5A9LooCYP7VBnbLb90AZWO6AjUUI9NMiFI8
\r
30 lKZi1VtnE2fyKUUN2QCmpacoblkbkTPAPaBdhtIwPwRrnEh3dK9S/q+n74N1qa6iMn6u
\r
31 +s3O7V0mJ2ST9GCbcKPSQ2RpDCUSS7SSr3JH6SDeJPfLpq1xCVH3LwVAhqBXbeFNX8Ka
\r
32 t0+Bt3IZZLcWvDJDFuVVlGB+TD8kzf+XQrmSrZ8zM15ANBEqmUk5eWT+nJCAaq4lpT93
\r
34 Received: by 10.69.1.35 with SMTP id bd3mr26639614pbd.141.1353806292536;
\r
35 Sat, 24 Nov 2012 17:18:12 -0800 (PST)
\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.
\r
38 by mx.google.com with ESMTPS id uk9sm6220363pbc.63.2012.11.24.17.18.09
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Sat, 24 Nov 2012 17:18:11 -0800 (PST)
\r
41 From: Peter Wang <novalazy@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH v2 12/20] insert: apply command-line tag operations
\r
44 Date: Sun, 25 Nov 2012 12:16:38 +1100
\r
45 Message-Id: <1353806206-29133-13-git-send-email-novalazy@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.12.1
\r
47 In-Reply-To: <1353806206-29133-1-git-send-email-novalazy@gmail.com>
\r
48 References: <1353806206-29133-1-git-send-email-novalazy@gmail.com>
\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: Sun, 25 Nov 2012 01:18:14 -0000
\r
63 Apply the +tag and -tag operations specified on the command-line.
\r
65 notmuch-insert.c | 19 +++++++++++++++----
\r
66 1 file changed, 15 insertions(+), 4 deletions(-)
\r
68 diff --git a/notmuch-insert.c b/notmuch-insert.c
\r
69 index e4631a2..81a528c 100644
\r
70 --- a/notmuch-insert.c
\r
71 +++ b/notmuch-insert.c
\r
72 @@ -174,7 +174,8 @@ copy_fd_data (int fdin, int fdout)
\r
73 * The file is renamed to encode notmuch tags as maildir flags. */
\r
74 static notmuch_bool_t
\r
75 add_file_to_database (notmuch_database_t *notmuch, const char *path,
\r
76 - const char **new_tags)
\r
77 + const char **new_tags,
\r
78 + const notmuch_tag_operation_t *tag_ops)
\r
80 notmuch_message_t *message;
\r
81 notmuch_status_t status;
\r
82 @@ -211,6 +212,14 @@ add_file_to_database (notmuch_database_t *notmuch, const char *path,
\r
83 notmuch_message_add_tag (message, new_tags[i]);
\r
86 + /* Apply the tags specified on the command-line. */
\r
87 + for (i = 0; tag_ops[i].tag; i++) {
\r
88 + if (tag_ops[i].remove)
\r
89 + notmuch_message_remove_tag (message, tag_ops[i].tag);
\r
91 + notmuch_message_add_tag (message, tag_ops[i].tag);
\r
94 notmuch_message_thaw (message);
\r
96 notmuch_message_tags_to_maildir_flags (message);
\r
97 @@ -222,7 +231,8 @@ add_file_to_database (notmuch_database_t *notmuch, const char *path,
\r
99 static notmuch_bool_t
\r
100 insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
\r
101 - const char *dir, const char **new_tags)
\r
102 + const char *dir, const char **new_tags,
\r
103 + const notmuch_tag_operation_t *tag_ops)
\r
107 @@ -243,7 +253,7 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
\r
111 - ret = add_file_to_database (notmuch, newpath, new_tags);
\r
112 + ret = add_file_to_database (notmuch, newpath, new_tags, tag_ops);
\r
114 /* XXX maybe there should be an option to keep the file in maildir? */
\r
116 @@ -327,7 +337,8 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])
\r
117 NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
\r
120 - ret = insert_message (ctx, notmuch, STDIN_FILENO, maildir, new_tags);
\r
121 + ret = insert_message (ctx, notmuch, STDIN_FILENO, maildir, new_tags,
\r
124 notmuch_database_destroy (notmuch);
\r