Re: bash completion error with 0.17
[notmuch-archives.git] / 57 / ca3e8c0fd955a20afcbed8cf4ec95149687e21
1 Return-Path: <bremner@pivot.cs.unb.ca>\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 6A509431FBC\r
6         for <notmuch@notmuchmail.org>; Thu,  3 Dec 2009 05:39:35 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id qamq9D65VHJG for <notmuch@notmuchmail.org>;\r
11         Thu,  3 Dec 2009 05:39:34 -0800 (PST)\r
12 Received: from pivot.cs.unb.ca (pivot.cs.unb.ca [131.202.240.57])\r
13         by olra.theworths.org (Postfix) with ESMTP id C2811431FAE\r
14         for <notmuch@notmuchmail.org>; Thu,  3 Dec 2009 05:39:34 -0800 (PST)\r
15 Received: from localhost ([127.0.0.1] helo=pivot.cs.unb.ca ident=bremner)\r
16         by pivot.cs.unb.ca with esmtp (Exim 4.69)\r
17         (envelope-from <bremner@pivot.cs.unb.ca>) id 1NGBuA-0002jv-4b\r
18         for notmuch@notmuchmail.org; Thu, 03 Dec 2009 09:39:34 -0400\r
19 Date: Thu, 03 Dec 2009 09:39:32 -0400\r
20 Message-ID: <87zl60xjl7.wl%bremner@pivot.cs.unb.ca>\r
21 From: david@tethera.net\r
22 To: notmuch@notmuchmail.org\r
23 User-Agent: EMIKO/1.14.1 (Choanoflagellata) FLIM/1.14.9 (=?UTF-8?B?R29q?=\r
24         =?UTF-8?B?xY0=?=) APEL/10.7 EasyPG/1.0.0 Emacs/23.1 (i486-pc-linux-gnu)\r
25         MULE/6.0 (HANACHIRUSATO)\r
26 MIME-Version: 1.0 (generated by EMIKO 1.14.1 - "Choanoflagellata")\r
27 Content-Type: multipart/mixed; boundary="Multipart_Thu_Dec__3_09:39:32_2009-1"\r
28 X-Sender-Verified: bremner@pivot.cs.unb.ca\r
29 Subject: [notmuch] hack to retag a directory\r
30 X-BeenThere: notmuch@notmuchmail.org\r
31 X-Mailman-Version: 2.1.12\r
32 Precedence: list\r
33 List-Id: "Use and development of the notmuch mail system."\r
34         <notmuch.notmuchmail.org>\r
35 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
36         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
38 List-Post: <mailto:notmuch@notmuchmail.org>\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
40 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
42 X-List-Received-Date: Thu, 03 Dec 2009 13:39:35 -0000\r
43 \r
44 --Multipart_Thu_Dec__3_09:39:32_2009-1\r
45 Content-Type: text/plain; charset=US-ASCII\r
46 \r
47 \r
48 I think this will be obsolete pretty soon when the equivalent is\r
49 built-in to notmuch, but in the mean time, here is a script that\r
50 somebody might find useful: retag a whole directory (recursively). I\r
51 don't claim it is nice in any way, but it seems usable for me, taking\r
52 about 5 seconds to retag a directory containing 1000 messages.\r
53 \r
54 I use it like \r
55 \r
56   tagdir Maildir/.list.debian-devel -inbox +debian +devel\r
57 \r
58 \r
59 --Multipart_Thu_Dec__3_09:39:32_2009-1\r
60 Content-Type: application/octet-stream\r
61 Content-Disposition: attachment; filename="tagdir"\r
62 Content-Transfer-Encoding: 7bit\r
63 \r
64 #!/usr/bin/perl\r
65 # Copyright © David Bremner <david@tethera.net>\r
66 # Distributed under the WTFPL <http://sam.zoy.org/wtfpl/>\r
67 \r
68 # usage: $0 directory tags\r
69 \r
70 use strict;\r
71 \r
72 my $batchsize=200;\r
73 my $count=0;\r
74 my $dir=$ARGV[0];\r
75 shift(@ARGV);\r
76 \r
77 my @tags=@ARGV;\r
78 my @msg_ids=();\r
79 \r
80 open (ID, "grep -h -R '^Message-I[dD]' $dir|") || die "$!";\r
81 while(<ID>){\r
82   chomp();\r
83    s/[\<\>]//g;\r
84    s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'"])/\\$1/g;\r
85    s/^Message-I[dD]: /id:/;\r
86    push(@msg_ids,$_);\r
87    $count++;\r
88    if ($count>=$batchsize){\r
89      $count=0;\r
90      system("notmuch tag ".join(" ",@tags)." ".join(" or ", @msg_ids));\r
91      @msg_ids=();\r
92    }\r
93  }\r
94 system("notmuch tag ".join(" ",@tags)." ".join(" or ", @msg_ids));\r
95 \r
96 \r
97 --Multipart_Thu_Dec__3_09:39:32_2009-1\r
98 Content-Type: text/plain; charset=US-ASCII\r
99 \r
100 \r
101   \r
102 --Multipart_Thu_Dec__3_09:39:32_2009-1--\r