[PATCH 1/9] lib: read "property" terms from messages.
[notmuch-archives.git] / 6b / 0994fc957571f76cf0981a71e503eecc87345e
1 Return-Path: <m.walters@qmul.ac.uk>\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 547F6431FB6\r
6         for <notmuch@notmuchmail.org>; Sun, 18 Nov 2012 09:05:47 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 KmuJJ-Ufk78F for <notmuch@notmuchmail.org>;\r
17         Sun, 18 Nov 2012 09:05:45 -0800 (PST)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 803E3431FAF\r
22         for <notmuch@notmuchmail.org>; Sun, 18 Nov 2012 09:05:45 -0800 (PST)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1Ta8JT-0006op-O3; Sun, 18 Nov 2012 17:05:44 +0000\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1Ta8JT-0003UQ-Cm; Sun, 18 Nov 2012 17:05:43 +0000\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH 10/18] insert: parse command-line tag operations\r
34 In-Reply-To: <1343223767-9812-10-git-send-email-novalazy@gmail.com>\r
35 References: <1343223767-9812-1-git-send-email-novalazy@gmail.com>\r
36         <1343223767-9812-10-git-send-email-novalazy@gmail.com>\r
37 User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1\r
38         (x86_64-pc-linux-gnu)\r
39 Date: Sun, 18 Nov 2012 17:05:42 +0000\r
40 Message-ID: <87r4nqq1sp.fsf@qmul.ac.uk>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=us-ascii\r
43 X-Sender-Host-Address: 93.97.24.31\r
44 X-QM-SPAM-Info: Sender has good ham record.  :)\r
45 X-QM-Body-MD5: 097be4e91f00fec4afeec6e6003e71d1 (of first 20000 bytes)\r
46 X-SpamAssassin-Score: -1.8\r
47 X-SpamAssassin-SpamBar: -\r
48 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
49         determine if it is\r
50         spam. We require at least 5.0 points to mark a message as spam.\r
51         This message scored -1.8 points.\r
52         Summary of the scoring: \r
53         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
54         *      medium trust\r
55         *      [138.37.6.40 listed in list.dnswl.org]\r
56         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
57         provider *      (markwalters1009[at]gmail.com)\r
58         *  0.5 AWL AWL: From: address is in the auto white-list\r
59 X-QM-Scan-Virus: ClamAV says the message is clean\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Sun, 18 Nov 2012 17:05:47 -0000\r
73 \r
74 \r
75 Hi\r
76 \r
77 On Wed, 25 Jul 2012, Peter Wang <novalazy@gmail.com> wrote:\r
78 > Parse +tag and -tag on the 'insert' command-line.\r
79 > Issue a warning about ambiguous -tag arguments which don't follow\r
80 > +tag nor an explicit option list terminator.\r
81 > ---\r
82 >  notmuch-insert.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
83 >  1 files changed, 50 insertions(+), 0 deletions(-)\r
84 >\r
85 > diff --git a/notmuch-insert.c b/notmuch-insert.c\r
86 > index 4fb3ea3..6db03e3 100644\r
87 > --- a/notmuch-insert.c\r
88 > +++ b/notmuch-insert.c\r
89 > @@ -24,6 +24,11 @@\r
90 >  #include <sys/stat.h>\r
91 >  #include <fcntl.h>\r
92 >  \r
93 > +typedef struct {\r
94 > +    const char *tag;\r
95 > +    notmuch_bool_t remove;\r
96 > +} tag_operation_t;\r
97 > +\r
98 >  static notmuch_bool_t\r
99 >  check_folder_name (const char *folder)\r
100 >  {\r
101 > @@ -236,8 +241,11 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])\r
102 >      const char **new_tags;\r
103 >      size_t new_tags_length;\r
104 >      const char *folder = NULL;\r
105 > +    tag_operation_t *tag_ops;\r
106 > +    int tag_ops_count = 0;\r
107 >      char *maildir;\r
108 >      int opt_index;\r
109 > +    notmuch_bool_t warn_tag_rem;\r
110 >      notmuch_bool_t ret;\r
111 >  \r
112 >      notmuch_opt_desc_t options[] = {\r
113 > @@ -253,6 +261,48 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])\r
114 >       return 1;\r
115 >      }\r
116 >  \r
117 > +    if (opt_index > 0 && strcmp (argv[opt_index - 1], "--") == 0) {\r
118 > +     warn_tag_rem = FALSE;\r
119 > +    } else {\r
120 > +     warn_tag_rem = TRUE;\r
121 > +    }\r
122 > +\r
123 > +    /* Array of tagging operations (add or remove), terminated with an\r
124 > +     * empty element. */\r
125 > +    tag_ops = talloc_array (ctx, tag_operation_t, argc - opt_index + 1);\r
126 > +    if (tag_ops == NULL) {\r
127 > +     fprintf (stderr, "Out of memory.\n");\r
128 > +     return 1;\r
129 > +    }\r
130 > +\r
131 > +    for (; opt_index < argc; opt_index++) {\r
132 > +     if (argv[opt_index][0] == '+') {\r
133 > +         tag_ops[tag_ops_count].tag = argv[opt_index] + 1;\r
134 > +         tag_ops[tag_ops_count].remove = FALSE;\r
135 > +         tag_ops_count++;\r
136 > +         warn_tag_rem = FALSE;\r
137 > +     } else if (argv[opt_index][0] == '-') {\r
138 > +         if (warn_tag_rem) {\r
139 > +             fprintf (stderr,\r
140 > +                      "Warning: ambiguous argument treated as tag removal: %s\n",\r
141 > +                      argv[opt_index]);\r
142 > +         }\r
143 > +         tag_ops[tag_ops_count].tag = argv[opt_index] + 1;\r
144 > +         tag_ops[tag_ops_count].remove = TRUE;\r
145 > +         tag_ops_count++;\r
146 > +     } else {\r
147 > +         break;\r
148 > +     }\r
149 > +    }\r
150 \r
151 I don't like the code duplication between this and notmuch-tag.c. In\r
152 particular the two (now) differ on how they deal with malformed tags\r
153 etc. Would it be possible to unify them?\r
154 \r
155 Best wishes\r
156 \r
157 Mark\r
158 \r
159 > +\r
160 > +    tag_ops[tag_ops_count].tag = NULL;\r
161 > +\r
162 > +    if (opt_index != argc) {\r
163 > +     fprintf (stderr, "Error: bad argument to notmuch insert: %s\n",\r
164 > +              argv[opt_index]);\r
165 > +     return 1;\r
166 > +    }\r
167 > +\r
168 >      config = notmuch_config_open (ctx, NULL, NULL);\r
169 >      if (config == NULL)\r
170 >       return 1;\r
171 > -- \r
172 > 1.7.4.4\r
173 >\r
174 > _______________________________________________\r
175 > notmuch mailing list\r
176 > notmuch@notmuchmail.org\r
177 > http://notmuchmail.org/mailman/listinfo/notmuch\r