nottoomuch-addresses-1.4.sh nottoomuch-addresses-1.5.sh
33
4case $* in ''|--*) exec perl -x "$0" "$@" ;;4case $* in ''|--*) exec perl -x "$0" "$@" ;;
5 ???*)5 ???*)
6 exec grep -aiF "$*" "${XDG_CONFIG_HOME:-$HOME/.config}/nottoomuch/addresses"6 grep -aiF "$*" "${XDG_CONFIG_HOME:-$HOME/.config}/nottoomuch/addresses"
7esac7esac
8case $? in 0|1) exit 0; esac
8exit 09exit $?
910
10# $ nottoomuch-addresses.sh $11# $ nottoomuch-addresses.sh $
11#12#
12# Created: Thu 27 Oct 2011 17:38:46 EEST too13# Created: Thu 27 Oct 2011 17:38:46 EEST too
13# Last modified: Wed 14 Dec 2011 21:24:28 EET too14# Last modified: Thu 22 Dec 2011 22:20:32 EET too
1415
15# Add this to your notmuch elisp configuration file:16# Add this to your notmuch elisp configuration file:
16#17#
21# Documentation at the end. Encoding: utf-8.22# Documentation at the end. Encoding: utf-8.
2223
23#!perl24#!perl
24# line 2525# line 26
2526
26# HISTORY27# HISTORY
28#
29# Version 1.5 2011-12-22 20:20:32 UTC
30# * Changed search to exit with zero value (also) if no match found.
31# * Changed addresses file header (v3) to use \t as separator. Addresses
32# file containing previous version header (v2) can also be read.
27#33#
28# Version 1.4 2011-12-14 19:24:28 UTC34# Version 1.4 2011-12-14 19:24:28 UTC
29# * Changed to run notmuch search --sort=newest-first --output=files ...35# * Changed to run notmuch search --sort=newest-first --output=files ...
107 if (-s $adbpath) {113 if (-s $adbpath) {
108 die "Cannot open '$adbpath': $!\n" unless open I, '<', $adbpath;114 die "Cannot open '$adbpath': $!\n" unless open I, '<', $adbpath;
109 sysread I, $_, 18;115 sysread I, $_, 18;
110 # new header: "v2/dd/dd/dd/dd/dd/" where / == '\n'116 # new header: "v3/dd/dd/dd/dd/dd\n" where / == '\t' (but match also v2)
111 if (/^v2\n(\d\d)\n(\d\d)\n(\d\d)\n(\d\d)\n(\d\d)\n$/) {117 if (/^v[23]\s(\d\d)\s(\d\d)\s(\d\d)\s(\d\d)\s(\d\d)\n$/) {
112 $sstr = "$1$2$3$4$5" - 86400 * 7; # one week extra to (re)look.118 $sstr = "$1$2$3$4$5" - 86400 * 7; # one week extra to (re)look.
113 $sstr = 0 if $sstr < 0;119 $sstr = 0 if $sstr < 0;
114 }120 }
134140
135 my $sometime = time;141 my $sometime = time;
136 die "Cannot open '$adbpath.new': $!\n" unless open O, '>', $adbpath.'.new';142 die "Cannot open '$adbpath.new': $!\n" unless open O, '>', $adbpath.'.new';
137 $_ = $sometime; s/(..)/$1\n/g;143 $_ = $sometime; s/(..)\B/$1\t/g;
138 print O "v2\n$_";144 print O "v3\t$_\n";
139145
140 # The following code block is from Email::Address, almost verbatim.146 # The following code block is from Email::Address, almost verbatim.
141 # The reasons to snip code I instead of just 'use Email::Address' are:147 # The reasons to snip code I instead of just 'use Email::Address' are:
361367
362=head1 VERSION368=head1 VERSION
363369
3641.4 (2011-12-14)3701.5 (2011-12-22)
365371
366=head1 OPTIONS372=head1 OPTIONS
367373
386arguments are used as fixed search string. Search goes through all392arguments are used as fixed search string. Search goes through all
387email addresses in database and outputs every address (separated by393email addresses in database and outputs every address (separated by
388newline) where a substring match with the given search string is394newline) where a substring match with the given search string is
389found. No wildcard of regular expression matching is used. Output is395found. No wildcard of regular expression matching is used.
390sorted in ASCII order.
391396
392Search is not done unless there is at least 3 octets in search string.397Search is not done unless there is at least 3 octets in search string.
393398

Generated by htmldiff.sh