1 Return-Path: <tomi.ollila@iki.fi>
\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 5772D431FC2
\r
6 for <notmuch@notmuchmail.org>; Mon, 9 Feb 2015 06:32:28 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5
\r
12 tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id aGDFXdGqY+vX for <notmuch@notmuchmail.org>;
\r
16 Mon, 9 Feb 2015 06:32:23 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 03BA8431FAF
\r
19 for <notmuch@notmuchmail.org>; Mon, 9 Feb 2015 06:32:22 -0800 (PST)
\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])
\r
21 by guru.guru-group.fi (Postfix) with ESMTP id 010B2100051;
\r
22 Mon, 9 Feb 2015 16:31:58 +0200 (EET)
\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
24 To: Stefano Zacchiroli <zack@upsilon.cc>, notmuch@notmuchmail.org
\r
25 Subject: Re: [PATCH 2/2] notmuch-mutt: support for messages that lack
\r
27 In-Reply-To: <1423474890-16972-3-git-send-email-zack@upsilon.cc>
\r
28 References: <1423474890-16972-1-git-send-email-zack@upsilon.cc>
\r
29 <1423474890-16972-3-git-send-email-zack@upsilon.cc>
\r
30 User-Agent: Notmuch/0.19+53~gb45d2f9 (http://notmuchmail.org) Emacs/24.3.1
\r
31 (x86_64-unknown-linux-gnu)
\r
32 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
33 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
34 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
35 Date: Mon, 09 Feb 2015 16:31:58 +0200
\r
36 Message-ID: <m2twyvyx41.fsf@guru.guru-group.fi>
\r
38 Content-Type: text/plain
\r
39 X-BeenThere: notmuch@notmuchmail.org
\r
40 X-Mailman-Version: 2.1.13
\r
42 List-Id: "Use and development of the notmuch mail system."
\r
43 <notmuch.notmuchmail.org>
\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
47 List-Post: <mailto:notmuch@notmuchmail.org>
\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
51 X-List-Received-Date: Mon, 09 Feb 2015 14:32:28 -0000
\r
53 On Mon, Feb 09 2015, Stefano Zacchiroli <zack@upsilon.cc> wrote:
\r
55 > From: "Jan N. Klug" <jan.n.klug@rub.de>
\r
57 > For those messages, compute a synthetic Message-ID based on the SHA1
\r
58 > of the whole message, in the same way that notmuch would do. See:
\r
59 > http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c
\r
61 > To do the above, rewrite get_message_id() to scan the current message
\r
62 > line by line, incrementally computing a SHA1. If a Message-ID is found
\r
63 > the SHA1 computation will be aborted; otherwise used for the synthetic
\r
66 I'd suggest the (something like) following way:
\r
68 First loop through headers, push lines to the array.
\r
70 check for Message-Id (using Mail::Header): if found, return it
\r
72 else message id not found:
\r
74 my $sha = Digest::SHA->new(1);
\r
75 $sha->add($_) foreach(@raw_header);
\r
76 $sha->addfile(\*STDIN);
\r
77 return 'notmuch-sha1-' . $sha->hexdigest;
\r
79 (BTW: the implementation in the patch (below) would check for message-id in
\r
80 @raw_header every time mail has an empty line ?)
\r
86 > Signed-off-by: Stefano Zacchiroli <zack@upsilon.cc>
\r
88 > contrib/notmuch-mutt/README | 4 +++-
\r
89 > contrib/notmuch-mutt/notmuch-mutt | 33 ++++++++++++++++++++++++++++-----
\r
90 > 2 files changed, 31 insertions(+), 6 deletions(-)
\r
92 > diff --git a/contrib/notmuch-mutt/README b/contrib/notmuch-mutt/README
\r
93 > index c661447..9c3379e 100644
\r
94 > --- a/contrib/notmuch-mutt/README
\r
95 > +++ b/contrib/notmuch-mutt/README
\r
96 > @@ -33,9 +33,11 @@ Requirements
\r
98 > To *run* notmuch-mutt you will need Perl with the following libraries:
\r
100 > +- Digest::SHA <https://metacpan.org/release/Digest-SHA>
\r
101 > + (Debian package: libdigest-sha-perl)
\r
102 > - Mail::Box <https://metacpan.org/pod/Mail::Box>
\r
103 > (Debian package: libmail-box-perl)
\r
104 > -- Mail::Internet <https://metacpan.org/pod/Mail::Internet>
\r
105 > +- Mail::Header <https://metacpan.org/pod/Mail::Header>
\r
106 > (Debian package: libmailtools-perl)
\r
107 > - String::ShellQuote <https://metacpan.org/pod/String::ShellQuote>
\r
108 > (Debian package: libstring-shellquote-perl)
\r
109 > diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
\r
110 > index 4969e4b..84af140 100755
\r
111 > --- a/contrib/notmuch-mutt/notmuch-mutt
\r
112 > +++ b/contrib/notmuch-mutt/notmuch-mutt
\r
113 > @@ -13,11 +13,12 @@ use warnings;
\r
116 > use Getopt::Long qw(:config no_getopt_compat);
\r
117 > -use Mail::Internet;
\r
118 > +use Mail::Header;
\r
119 > use Mail::Box::Maildir;
\r
121 > use String::ShellQuote;
\r
122 > use Term::ReadLine;
\r
123 > +use Digest::SHA;
\r
126 > my $xdg_cache_dir = "$ENV{HOME}/.cache";
\r
127 > @@ -75,10 +76,32 @@ sub prompt($$) {
\r
130 > sub get_message_id() {
\r
131 > - my $mail = Mail::Internet->new(\*STDIN);
\r
132 > - my $mid = $mail->head->get("message-id") or return undef;
\r
133 > - $mid =~ /^<(.*)>$/; # get message-id value
\r
135 > + my $mid = undef;
\r
136 > + my $in_header = 1;
\r
137 > + my @raw_header = ();
\r
138 > + my $sha = Digest::SHA->new(1); # SHA1 hash of the whole mail
\r
140 > + while (<STDIN>) { # compute SHA1 as we go
\r
141 > + push(@raw_header, $_) if $in_header; # cache header lines
\r
142 > + if ($_ =~ /^$/) { # end of header, parse it and look for Message-ID
\r
143 > + $in_header = 0;
\r
144 > + my $head = Mail::Header->new(\@raw_header);
\r
145 > + $mid = $head->get("message-id") or undef;
\r
147 > + $mid =~ /^<(.*)>$/; # get message-id value
\r
149 > + last; # stop hashing
\r
152 > + $sha->add($_); # update hash
\r
155 > + # If no message-id was found, generate one-id in the same way that
\r
156 > + # notmuch would do.
\r
157 > + # See: http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c
\r
158 > + $mid ||= "notmuch-sha1-".$sha->hexdigest;
\r
163 > sub search_action($$$@) {
\r
167 > _______________________________________________
\r
168 > notmuch mailing list
\r
169 > notmuch@notmuchmail.org
\r
170 > http://notmuchmail.org/mailman/listinfo/notmuch
\r