nottoomuch-addresses-1.3.sh nottoomuch-addresses-1.4.sh
10# $ nottoomuch-addresses.sh $10# $ nottoomuch-addresses.sh $
11#11#
12# Created: Thu 27 Oct 2011 17:38:46 EEST too12# Created: Thu 27 Oct 2011 17:38:46 EEST too
13# Last modified: Mon 12 Dec 2011 17:41:05 EET too13# Last modified: Wed 14 Dec 2011 21:24:28 EET too
1414
15# Add this to your notmuch elisp configuration file:15# Add this to your notmuch elisp configuration file:
16#16#
2020
21# Documentation at the end. Encoding: utf-8.21# Documentation at the end. Encoding: utf-8.
2222
23#!perl
24# line 25
25
23# HISTORY26# HISTORY
24#27#
28# Version 1.4 2011-12-14 19:24:28 UTC
29# * Changed to run notmuch search --sort=newest-first --output=files ...
30# (instead of notmuch show ...) and read headers from files internally.
31# * Fixed away joining uninitialized $phrase value to address line.
32#
25# Version 1.3 2011-12-12 15:41:05 UTC33# Version 1.3 2011-12-12 15:41:05 UTC
26# * Changed to store/show addresses in 'newest first' order34# * Changed to store/show addresses in 'newest first' order.
27# * Changed addresses file header to force address file rebuild.35# * Changed addresses file header to force address file rebuild.
28#36#
29# Version 1.2 2011-12-06 18:00:00 UTC37# Version 1.2 2011-12-06 18:00:00 UTC
37# Thanks to Bart Bunting for providing a good bug report.45# Thanks to Bart Bunting for providing a good bug report.
38#46#
39# Version 1.0 2011-11-30 20:56:10 UTC47# Version 1.0 2011-11-30 20:56:10 UTC
40# * Initial release48# * Initial release.
41
42#!perl
43# line 44
4449
45use 5.8.1;50use 5.8.1;
46use strict;51use strict;
208 my $ptime = $sometime + 5;213 my $ptime = $sometime + 5;
209 my $new = 0;214 my $new = 0;
210 $| = 1;215 $| = 1;
211 open P, '-|', qw/notmuch show/, $sstr;216 open P, '-|', qw/notmuch search --sort=newest-first --output=files/, $sstr;
212 while (<P>) {217 while (<P>) {
213 next unless /^From:\s/i or /^To:\s/i or /^Cc:\s/i;218 chomp;
219 open M, '<', $_ or next;
220
221 while (<M>) {
222 last if /^\s*$/;
223 next unless s/^(From|To|Cc|Bcc):\s+//i;
214 s/\s+$//;224 s/\s+$//;
215 s/^.*?:\s+//;225 my @a = ( $_ );
226 while (<M>) {
227 # XXX leaks to body in case empty line is found in this loop...
228 # XXX Note that older code leaked to mail body always...
229 if (s/^\s+// or s/^(From|To|Cc|Bcc):\s+/,/i) {
230 s/\s+$//;
231 push @a, $_;
232 next;
233 }
234 last;
235 }
236 $_ = join ' ', @a;
216237
217 if (time > $ptime) {238 if (time > $ptime) {
218 my $c = qw(/ - \ |)[int ($ptime / 5) % 4];239 my $c = qw(/ - \ |)[int ($ptime / 5) % 4];
287 tr/_/ / unless /@/; 1; } @comments;308 tr/_/ / unless /@/; 1; } @comments;
288 #@comments = grep { defined } @comments;309 #@comments = grep { defined } @comments;
289310
311 @phrase = () unless defined $phrase[0];
290 $_ = join(' ', @phrase, $userhost, @comments) . "\n";312 $_ = join(' ', @phrase, $userhost, @comments) . "\n";
291 next if defined $hash{$_};313 next if defined $hash{$_};
292 print O $_;314 print O $_;
294 $new++;316 $new++;
295 }317 }
296 # --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--318 # --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
319 }
320 close M;
297 }321 }
298 undef %seen;322 undef %seen;
299 close P;323 close P;
337361
338=head1 VERSION362=head1 VERSION
339363
3401.3 (2011-12-12)3641.4 (2011-12-14)
341365
342=head1 OPTIONS366=head1 OPTIONS
343367

Generated by htmldiff.sh