Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 66 / 77238bb8b8bf62df381929bb54908153ab7a4e
1 Return-Path: <keevan@fastmail.fm>\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 7AD99429E50\r
6         for <notmuch@notmuchmail.org>; Wed,  4 Sep 2013 19:14:08 -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.799\r
10 X-Spam-Level: \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 5MAEuF5xbkvK for <notmuch@notmuchmail.org>;\r
17         Wed,  4 Sep 2013 19:14:03 -0700 (PDT)\r
18 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com\r
19         [66.111.4.27])\r
20         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id C0DAF429E4C\r
23         for <notmuch@notmuchmail.org>; Wed,  4 Sep 2013 19:14:02 -0700 (PDT)\r
24 Received: from compute1.internal (compute1.nyi.mail.srv.osa [10.202.2.41])\r
25         by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 89F812113C;\r
26         Wed,  4 Sep 2013 22:06:34 -0400 (EDT)\r
27 Received: from frontend2 ([10.202.2.161])\r
28         by compute1.internal (MEProxy); Wed, 04 Sep 2013 22:06:34 -0400\r
29 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=8t8.us; h=from:to\r
30         :cc:subject:date:message-id:in-reply-to:references; s=mesmtp;\r
31         bh=NwXtEP9eSENBMPi85MxvEbbVmQg=; b=YVisTZ6Ahnge0sY2tXn3DZ4OK0uN\r
32         Hu9OA6kC3JO9Cmf3XXpj/k385rGOCV/H/9dMZhW3stkNSHOmy4NnEJvtcbMjF/bQ\r
33         SVoDuoJfj54J3Pbj2IoK2GVNPxblriNmTSDnWYBfU8F2TFCyyYlCBLJ8nAB21rEj\r
34         4RKvkoogqHeDqXE=\r
35 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=\r
36         messagingengine.com; h=from:to:cc:subject:date:message-id\r
37         :in-reply-to:references; s=smtpout; bh=NwXtEP9eSENBMPi85MxvEbbVm\r
38         Qg=; b=llgO6YCC45vnB/CwRbtiEheD7weA/LdNtUc93121FGu5BY6CpxxMct70N\r
39         XXUvw0E1XmHgVkmXQQeQFvH6GQk80e0/gt3soh+tfNlyKENQ1AGcSsdorMVsVJsG\r
40         O1cKAGNK9oDvIHgFCi9gQM5jeF6dsbgt76S+/Z8BssaUWjdYA4=\r
41 X-Sasl-enc: WE7t0EeN3frTUXWxsuElr80nUavLFJk0cjUDWF1+0LJl 1378346793\r
42 Received: from localhost (unknown [97.125.94.9])\r
43         by mail.messagingengine.com (Postfix) with ESMTPA id 9A7806804FA;\r
44         Wed,  4 Sep 2013 22:06:33 -0400 (EDT)\r
45 From: Kevin McCarthy <kevin@8t8.us>\r
46 To: notmuch@notmuchmail.org\r
47 Subject: [PATCH 1/2] notmuch-mutt: use notmuch --duplicate flag\r
48 Date: Wed,  4 Sep 2013 19:05:50 -0700\r
49 Message-Id: <1378346751-25548-2-git-send-email-kevin@8t8.us>\r
50 X-Mailer: git-send-email 1.8.4.rc3\r
51 In-Reply-To: <1378346751-25548-1-git-send-email-kevin@8t8.us>\r
52 References: <1378346751-25548-1-git-send-email-kevin@8t8.us>\r
53 Cc: zack@upsilon.cc\r
54 X-BeenThere: notmuch@notmuchmail.org\r
55 X-Mailman-Version: 2.1.13\r
56 Precedence: list\r
57 List-Id: "Use and development of the notmuch mail system."\r
58         <notmuch.notmuchmail.org>\r
59 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
61 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
62 List-Post: <mailto:notmuch@notmuchmail.org>\r
63 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
64 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
66 X-List-Received-Date: Thu, 05 Sep 2013 02:14:08 -0000\r
67 \r
68 Change notmuch-mutt to use the new --duplicate=1 flag for duplicate\r
69 removal.  This will remove duplicates based on message-id at the\r
70 notmuch level.  Previously we were using fdupes or generating sha sums\r
71 after the search.\r
72 \r
73 This version will be faster, but will enable the possibility of hiding\r
74 search results due to accidental/malicious duplicate message-ids.\r
75 ---\r
76  contrib/notmuch-mutt/README       |  5 ---\r
77  contrib/notmuch-mutt/notmuch-mutt | 64 +++++++--------------------------------\r
78  2 files changed, 11 insertions(+), 58 deletions(-)\r
79 \r
80 diff --git a/contrib/notmuch-mutt/README b/contrib/notmuch-mutt/README\r
81 index e00035c..382ac91 100644\r
82 --- a/contrib/notmuch-mutt/README\r
83 +++ b/contrib/notmuch-mutt/README\r
84 @@ -41,11 +41,6 @@ To *run* notmuch-mutt you will need Perl with the following libraries:\r
85    (Debian package: libstring-shellquote-perl)\r
86  - Term::ReadLine <http://search.cpan.org/~hayashi/Term-ReadLine-Gnu/>\r
87    (Debian package: libterm-readline-gnu-perl)\r
88 -- File::Which <http://search.cpan.org/dist/File-Which/>\r
89 -  (Debian package: libfile-which-perl)\r
90 -\r
91 -The --remove-dups option will use fdupes <https://code.google.com/p/fdupes/>\r
92 -if it is installed.  Version fdupes-1.50-PR2 or higher is required.\r
93  \r
94  To *build* notmuch-mutt documentation you will need:\r
95  \r
96 diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt\r
97 index 00c5ef8..c69b35c 100755\r
98 --- a/contrib/notmuch-mutt/notmuch-mutt\r
99 +++ b/contrib/notmuch-mutt/notmuch-mutt\r
100 @@ -18,8 +18,6 @@ use Mail::Box::Maildir;\r
101  use Pod::Usage;\r
102  use String::ShellQuote;\r
103  use Term::ReadLine;\r
104 -use Digest::SHA;\r
105 -use File::Which;\r
106  \r
107  \r
108  my $xdg_cache_dir = "$ENV{HOME}/.cache";\r
109 @@ -36,65 +34,22 @@ sub empty_maildir($) {\r
110      $folder->close();\r
111  }\r
112  \r
113 -# Match files by size and SHA-256; then delete duplicates\r
114 -sub builtin_remove_dups($) {\r
115 -    my ($maildir) = @_;\r
116 -    my (%size_to_files, %sha_to_files);\r
117 -\r
118 -    # Group files by matching sizes\r
119 -    foreach my $file (glob("$maildir/cur/*")) {\r
120 -        my $size = -s $file;\r
121 -        push(@{$size_to_files{$size}}, $file) if $size;\r
122 -    }\r
123 -\r
124 -    foreach my $same_size_files (values %size_to_files) {\r
125 -        # Don't run sha unless there is another file of the same size\r
126 -        next if scalar(@$same_size_files) < 2;\r
127 -        %sha_to_files = ();\r
128 -\r
129 -        # Group files with matching sizes by SHA-256\r
130 -        foreach my $file (@$same_size_files) {\r
131 -            open(my $fh, '<', $file) or next;\r
132 -            binmode($fh);\r
133 -            my $sha256hash = Digest::SHA->new(256)->addfile($fh)->hexdigest;\r
134 -            close($fh);\r
135 -\r
136 -            push(@{$sha_to_files{$sha256hash}}, $file);\r
137 -        }\r
138 -\r
139 -        # Remove duplicates\r
140 -        foreach my $same_sha_files (values %sha_to_files) {\r
141 -            next if scalar(@$same_sha_files) < 2;\r
142 -            unlink(@{$same_sha_files}[1..$#$same_sha_files]);\r
143 -        }\r
144 -    }\r
145 -}\r
146 -\r
147 -# Use either fdupes or the built-in scanner to detect and remove duplicate\r
148 -# search results in the maildir\r
149 -sub remove_duplicates($) {\r
150 -    my ($maildir) = @_;\r
151 -\r
152 -    my $fdupes = which("fdupes");\r
153 -    if ($fdupes) {\r
154 -      system("$fdupes --hardlinks --symlinks --delete --noprompt"\r
155 -             . " --quiet $maildir/cur/ > /dev/null");\r
156 -    } else {\r
157 -        builtin_remove_dups($maildir);\r
158 -    }\r
159 -}\r
160 -\r
161  # search($maildir, $remove_dups, $query)\r
162  # search mails according to $query with notmuch; store results in $maildir\r
163  sub search($$$) {\r
164      my ($maildir, $remove_dups, $query) = @_;\r
165 +    my $dup_option = "";\r
166 +\r
167      $query = shell_quote($query);\r
168  \r
169 +    if ($remove_dups) {\r
170 +      $dup_option = "--duplicate=1";\r
171 +    }\r
172 +\r
173      empty_maildir($maildir);\r
174 -    system("notmuch search --output=files $query"\r
175 +    system("notmuch search --output=files $dup_option $query"\r
176            . " | sed -e 's: :\\\\ :g'"\r
177            . " | xargs --no-run-if-empty ln -s -t $maildir/cur/");\r
178 -    remove_duplicates($maildir) if ($remove_dups);\r
179  }\r
180  \r
181  sub prompt($$) {\r
182 @@ -252,7 +207,10 @@ Instead of using command line search terms, prompt the user for them (only for\r
183  \r
184  =item --remove-dups\r
185  \r
186 -Remove duplicates from search results.\r
187 +Remove emails with duplicate message-ids from search results.  (Passes\r
188 +--duplicate=1 to notmuch search command.)  Note this can hide search\r
189 +results if an email accidentally or maliciously uses the same message-id\r
190 +as a different email.\r
191  \r
192  =item -h\r
193  \r
194 -- \r
195 1.8.4.rc3\r
196 \r