[PATCH v2 2/8] emacs: Take prompt and current tags in `notmuch-read-tag-changes'
[notmuch-archives.git] / 02 / a1e9834fcd03be33e93ac01d0b21a29be763f1
1 Return-Path: <jani@nikula.org>\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 1AA98431FD0\r
6         for <notmuch@notmuchmail.org>; Mon, 10 Jun 2013 09:49:58 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 sQKeSvw9-uro for <notmuch@notmuchmail.org>;\r
16         Mon, 10 Jun 2013 09:49:50 -0700 (PDT)\r
17 Received: from mail-la0-f44.google.com (mail-la0-f44.google.com\r
18         [209.85.215.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id AD37B431FB6\r
21         for <notmuch@notmuchmail.org>; Mon, 10 Jun 2013 09:49:49 -0700 (PDT)\r
22 Received: by mail-la0-f44.google.com with SMTP id er20so5955107lab.3\r
23         for <notmuch@notmuchmail.org>; Mon, 10 Jun 2013 09:49:48 -0700 (PDT)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=google.com; s=20120113;\r
26         h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
27         :mime-version:content-type:x-gm-message-state;\r
28         bh=Al9+cOvOAtoI9T1o2JzSTk7hTeu0+naIAmYz9Igf4tg=;\r
29         b=KyO0D5DTmgFBoVk4E/x3k9xwpPycvt46GR4jTnkC4w/02CzQr+jMlVz3SPKqg5JcEL\r
30         U2gb4sZ1i46YkZmH4De7jgExznQVVtJdzzgGS3mEdc7FH/JbeLq0YWmV5GnrvRs/i9TR\r
31         TR+JaHgeSm2G47igqh1oDrie9VZOLp3DbYXZBzQ3kUbj3OtXjx/oLA4JhGBxcvyHu0lK\r
32         4ZHhrgTJG6A78WmQRZOWFvHSAj27+X8QBNPRBRoiuVhqi6cIJWbIuw5fcF3kKBuzbE8j\r
33         VKMN8pLJ3Qg/pbA/mxxX0Jhsgw+HQnnkBzzK8+WmjCbh9bQi1lTnT0r7SQUBy8LoFOsh\r
34         JS1g==\r
35 X-Received: by 10.152.120.35 with SMTP id kz3mr5432918lab.55.1370882988163;\r
36         Mon, 10 Jun 2013 09:49:48 -0700 (PDT)\r
37 Received: from localhost (dsl-hkibrasgw2-58c376-211.dhcp.inet.fi.\r
38         [88.195.118.211])\r
39         by mx.google.com with ESMTPSA id x5sm5977938lbx.8.2013.06.10.09.49.46\r
40         for <multiple recipients>\r
41         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
42         Mon, 10 Jun 2013 09:49:47 -0700 (PDT)\r
43 From: Jani Nikula <jani@nikula.org>\r
44 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
45 Subject: Re: [PATCH v2 1/7] cli: add --duplicate=N option to notmuch search\r
46 In-Reply-To: <871u8b11bh.fsf@qmul.ac.uk>\r
47 References: <cover.1370775663.git.jani@nikula.org>\r
48         <61ed86f221d65b4dba438cbc2b4c5b77a484a534.1370775663.git.jani@nikula.org>\r
49         <871u8b11bh.fsf@qmul.ac.uk>\r
50 User-Agent: Notmuch/0.15.2+179~g8952790 (http://notmuchmail.org) Emacs/24.3.1\r
51         (x86_64-pc-linux-gnu)\r
52 Date: Mon, 10 Jun 2013 19:49:42 +0300\r
53 Message-ID: <87ppvt6hcp.fsf@nikula.org>\r
54 MIME-Version: 1.0\r
55 Content-Type: text/plain\r
56 X-Gm-Message-State:\r
57  ALoCoQmZUbdJ1BbvCmTk3yBlVq1+CXTstxdkeNwhMOz0lBs0cKov6Z0fCEoZVq1MXEw1zivZY+jA\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Mon, 10 Jun 2013 16:49:58 -0000\r
71 \r
72 On Sun, 09 Jun 2013, Mark Walters <markwalters1009@gmail.com> wrote:\r
73 > Overall I like this series and am happy to give it a +1 as is but have a\r
74 > few comments which might be worth considering.\r
75 >\r
76 > Is the order of filenames clear? eg is it the order that notmuch new met\r
77 > them? In particular is duplicate=1 the oldest and duplicate=N the\r
78 > newest? If so that might be worth mentioning in the manpage.\r
79 \r
80 AFAICT it's the order in which notmuch new encountered them. Which may\r
81 change if the user rebuilds the database. Which is why I intentionally\r
82 avoided making any promises about what the numbers mean.\r
83 \r
84 >\r
85 > On Sun, 09 Jun 2013, Jani Nikula <jani@nikula.org> wrote:\r
86 >> Effective with --output=files, output the Nth filename associated with\r
87 >> each message matching the query (N is 0-based). If N is equal to or\r
88 >> greater than the number of files associated with the message, don't\r
89 >> print anything.\r
90 >> ---\r
91 >>  notmuch-search.c |   18 ++++++++++++------\r
92 >>  1 file changed, 12 insertions(+), 6 deletions(-)\r
93 >>\r
94 >> diff --git a/notmuch-search.c b/notmuch-search.c\r
95 >> index 4323201..196934b 100644\r
96 >> --- a/notmuch-search.c\r
97 >> +++ b/notmuch-search.c\r
98 >> @@ -177,7 +177,8 @@ do_search_messages (sprinter_t *format,\r
99 >>                  notmuch_query_t *query,\r
100 >>                  output_t output,\r
101 >>                  int offset,\r
102 >> -                int limit)\r
103 >> +                int limit,\r
104 >> +                int dupe)\r
105 >>  {\r
106 >>      notmuch_message_t *message;\r
107 >>      notmuch_messages_t *messages;\r
108 >> @@ -206,14 +207,17 @@ do_search_messages (sprinter_t *format,\r
109 >>      message = notmuch_messages_get (messages);\r
110 >>  \r
111 >>      if (output == OUTPUT_FILES) {\r
112 >> +        int j;\r
113 >>          filenames = notmuch_message_get_filenames (message);\r
114 >>  \r
115 >> -        for (;\r
116 >> +        for (j = 1;\r
117 >>               notmuch_filenames_valid (filenames);\r
118 >> -             notmuch_filenames_move_to_next (filenames))\r
119 >> +             notmuch_filenames_move_to_next (filenames), j++)\r
120 >>          {\r
121 >> -            format->string (format, notmuch_filenames_get (filenames));\r
122 >> -            format->separator (format);\r
123 >> +            if (dupe < 0 || dupe == j) {\r
124 >> +                format->string (format, notmuch_filenames_get (filenames));\r
125 >> +                format->separator (format);\r
126 >\r
127 > Is it deliberate that dupe == 0 is not covered? If my newest oldest\r
128 > thing above is correct then maybe dupe == 0 could be the all option +N\r
129 > the Nth oldest and -N the Nth newest. This may be not-trivial enough\r
130 > it's not worth doing.\r
131 \r
132 See my answer above. We can do this later if we decide it's worth the\r
133 trouble.\r
134 \r
135 I don't check for 0 because it doesn't match anything. Similarly for\r
136 values < 0.\r
137 \r
138 >\r
139 >> +            }\r
140 >>          }\r
141 >>          \r
142 >>          notmuch_filenames_destroy( filenames );\r
143 >> @@ -303,6 +307,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
144 >>      int offset = 0;\r
145 >>      int limit = -1; /* unlimited */\r
146 >>      int exclude = EXCLUDE_TRUE;\r
147 >> +    int dupe = -1;\r
148 >>      unsigned int i;\r
149 >>  \r
150 >>      enum {\r
151 >> @@ -339,6 +344,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
152 >>                                    { 0, 0 } } },\r
153 >>      { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },\r
154 >>      { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },\r
155 >> +    { NOTMUCH_OPT_INT, &dupe, "duplicate", 'D', 0  },\r
156 >>      { 0, 0, 0, 0, 0 }\r
157 >>      };\r
158 >>  \r
159 >> @@ -424,7 +430,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
160 >>      break;\r
161 >>      case OUTPUT_MESSAGES:\r
162 >>      case OUTPUT_FILES:\r
163 >> -    ret = do_search_messages (format, query, output, offset, limit);\r
164 >> +    ret = do_search_messages (format, query, output, offset, limit, dupe);\r
165 >\r
166 > Should there be an error message if duplicate=x is chosen with\r
167 > output!=files?\r
168 \r
169 I avoided adding checks upon checks, complicating the code, because\r
170 there's no harm in allowing it. Matter of taste I suppose.\r
171 \r
172 Thanks for your comments.\r
173 \r
174 BR,\r
175 Jani.\r
176 \r
177 \r
178 >\r
179 > Best wishes\r
180 >\r
181 > Mark\r
182 >\r
183 >\r
184 >>      break;\r
185 >>      case OUTPUT_TAGS:\r
186 >>      ret = do_search_tags (notmuch, format, query);\r
187 >> -- \r
188 >> 1.7.10.4\r
189 >>\r
190 >> _______________________________________________\r
191 >> notmuch mailing list\r
192 >> notmuch@notmuchmail.org\r
193 >> http://notmuchmail.org/mailman/listinfo/notmuch\r