nottoomuch-addresses-1.5.sh nottoomuch-addresses-1.6.sh
11# $ nottoomuch-addresses.sh $11# $ nottoomuch-addresses.sh $
12#12#
13# Created: Thu 27 Oct 2011 17:38:46 EEST too13# Created: Thu 27 Oct 2011 17:38:46 EEST too
14# Last modified: Thu 22 Dec 2011 22:20:32 EET too14# Last modified: Thu 29 Dec 2011 08:42:42 EET too
1515
16# Add this to your notmuch elisp configuration file:16# Add this to your notmuch elisp configuration file:
17#17#
25# line 2625# line 26
2626
27# HISTORY27# HISTORY
28#
29# Version 1.6 2011-12-29 06:42:42 UTC
30# * Fixed 'encoded-text' regognization and concatenations, and underscore
31# to space replacements. Now quite RFC 2047 "compliant".
28#32#
29# Version 1.5 2011-12-22 20:20:32 UTC33# Version 1.5 2011-12-22 20:20:32 UTC
30# * Changed search to exit with zero value (also) if no match found.34# * Changed search to exit with zero value (also) if no match found.
31# * Changed addresses file header (v3) to use \t as separator. Addresses35# * Changed addresses file header (v3) to use \t as separator. Addresses
32# file containing previous version header (v2) can also be read.36# file containing previous version header (v2) can also be read.
37# * Removed outdated information about sorting in ASCII order.
33#38#
34# Version 1.4 2011-12-14 19:24:28 UTC39# Version 1.4 2011-12-14 19:24:28 UTC
35# * Changed to run notmuch search --sort=newest-first --output=files ...40# * Changed to run notmuch search --sort=newest-first --output=files ...
252 # --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--257 # --8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
253258
254 s/[ \t]+/ /g;259 s/[ \t]+/ /g;
260 s/\?= =\?/\?==\?/g;
255 my (@mailboxes) = (/$mailbox/go);261 my (@mailboxes) = (/$mailbox/go);
256 foreach (@mailboxes) {262 foreach (@mailboxes) {
257 next if $seen{$_};263 next if $seen{$_};
268 }274 }
269275
270 sub decode_data () {276 sub decode_data () {
271 local $_ = $1;277 my $t = lc $2;
272 if (s/^utf-8\?(q|b)\?//i) {278 my $s;
273 return (lc $1 eq 'q')? decode_qp($_): decode_base64($_);279 if ($t eq 'b') { $s = decode_base64($3); }
280 elsif ($t eq 'q') { $s = decode_qp($3); }
281 else {
282 return "=?$1?$2?$3?=";
274 }283 }
275 if (s/^([\w-]+)\?(q|b)\?//i) {284 $s =~ tr/_/ /;
276 my $t = lc $2;285
286 return $s if lc $1 eq 'utf-8';
287
277 my $o = find_encoding($1);288 my $o = find_encoding($1);
278 if (ref $o) {289 return "=?$1?$2?$3?=" unless ref $o;
279 my $s = ($t eq 'q')? decode_qp($_): decode_base64($_);
280 # Encode(3p) is fuzzy whether encode_utf8 is needed...
281 return encode_utf8($o->decode($s));290 return encode_utf8($o->decode($s));
282 }
283 }
284 return "=?$_?=";
285 }291 }
286292
287 my @phrase = /($display_name)/o;293 my @phrase = /($display_name)/o;
288 $phrase[0] =~ s/=\?(.+?)\?=/decode_data/ge if @phrase;294 $phrase[0]=~ s/=\?([^?]+)\?(\w)\?(.*?)\?=/decode_data/ge if @phrase;
289295
290 for ( @phrase, $host, $user, @comments ) {296 for ( @phrase, $host, $user, @comments ) {
291 next unless defined $_;297 next unless defined $_;
298304
299 for (@phrase) { # to get the only one aliased to $_305 for (@phrase) { # to get the only one aliased to $_
300 next unless defined $_; # previous loop may undefine this.306 next unless defined $_; # previous loop may undefine this.
301 # if it's encoded -- rjbs, 2007-02-28
302 unless (/\A=\?.+\?=\z/) {
303 #s/\A"(.+)"\z/$1/;307 #s/\A"(.+)"\z/$1/;
304 tr/\\//d; ## 20111124 too308 tr/\\//d; ## 20111124 too
305 tr/_/ / unless /@/; ## 20111130 too
306 s/\"/\\"/g;309 s/\"/\\"/g;
307 $_ = '"'.$_.'"';310 $_ = '"'.$_.'"';
308 }
309 }311 }
310 my $userhost = lc "<$user\@$host>";312 my $userhost = lc "<$user\@$host>";
311 #my $userhost = "<$user\@$host>";313 #my $userhost = "<$user\@$host>";
312 @comments = grep { defined or return 0;314 @comments = grep { defined or return 0;
313 s/=\?(.+?)\?=/decode_data/ge;315 s/=\?([^?]+)\?(\w)\?(.*?)\?=/decode_data/ge; 1;
314 tr/_/ / unless /@/; 1; } @comments;316 } @comments;
315 #@comments = grep { defined } @comments;317 #@comments = grep { defined } @comments;
316318
317 @phrase = () unless defined $phrase[0];319 @phrase = () unless defined $phrase[0];
367369
368=head1 VERSION370=head1 VERSION
369371
3701.5 (2011-12-22)3721.6 (2011-12-29)
371373
372=head1 OPTIONS374=head1 OPTIONS
373375

Generated by htmldiff.sh