1 Return-Path: <jani@nikula.org>
\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 308ED431FCB
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Jan 2015 06:59:14 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=1.738 tagged_above=-999 required=5
\r
12 tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7]
\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 ugZr0UO0qINb for <notmuch@notmuchmail.org>;
\r
17 Sat, 24 Jan 2015 06:59:08 -0800 (PST)
\r
18 Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com
\r
19 [74.125.82.42]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
20 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
21 9B5FD431FAE for <notmuch@notmuchmail.org>; Sat, 24 Jan 2015 06:59:08 -0800
\r
23 Received: by mail-wg0-f42.google.com with SMTP id x13so2264140wgg.1
\r
24 for <notmuch@notmuchmail.org>; Sat, 24 Jan 2015 06:59:05 -0800 (PST)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=1e100.net; s=20130820;
\r
27 h=x-gm-message-state:from:to:cc:subject:in-reply-to:references
\r
28 :user-agent:date:message-id:mime-version:content-type;
\r
29 bh=b0rU/F6AF8BJxNe2rwNUZyH2GY1Ut/fPsdwt2Wmb73g=;
\r
30 b=Y1/UM3cqJ36qJb7w8kBtezjsnnfiMWbYvxmm6FiiHOD4OXn1GZXIO6fEYmN2xhGop6
\r
31 iTRUSCIIDs5swT6RyhkPD0Ev1sH52lmkmDR9qnUZq/aYLFW+Ngozqgv7O8dL8qHiPBdl
\r
32 oONbkuN+eGGKU0qXb7lbsPelRx6raNp+6/BfY/cO/OBPX0xQZPcUWsBf7cWu16ZA3IcB
\r
33 4CEZBk38gqPQtR66D78788j1dIzoTPa28O82oBodbUWLDjzjNAC6fg7oKsKkR08DAUzX
\r
34 zq0wMTHvxJ18vS6TUcrz7t7fW8WWPYvOS5Jzi2nDZJAdMH2a/m5L+DtNg3KsOW5b5K1x
\r
37 ALoCoQn0tOqcunzBpigPPu6drAdJ451I+DsCaU5YaNzguKXOJWwR6i5bJ4iT+gGpcpui7omkW0PM
\r
38 X-Received: by 10.194.19.197 with SMTP id h5mr6107389wje.109.1422111545210;
\r
39 Sat, 24 Jan 2015 06:59:05 -0800 (PST)
\r
40 Received: from localhost (mobile-internet-bcee98-87.dhcp.inet.fi.
\r
41 [188.238.152.87]) by mx.google.com with ESMTPSA id
\r
42 dz10sm6154906wib.17.2015.01.24.06.59.03
\r
43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
44 Sat, 24 Jan 2015 06:59:04 -0800 (PST)
\r
45 From: Jani Nikula <jani@nikula.org>
\r
46 To: Stefano Zacchiroli <zack@upsilon.cc>, notmuch@notmuchmail.org
\r
47 Subject: Re: [PATCH 2/3] notmuch-mutt: support for messages that lack
\r
49 In-Reply-To: <1422090701-19385-3-git-send-email-zack@upsilon.cc>
\r
50 References: <1422090701-19385-1-git-send-email-zack@upsilon.cc>
\r
51 <1422090701-19385-3-git-send-email-zack@upsilon.cc>
\r
52 User-Agent: Notmuch/0.19+37~g290dc80 (http://notmuchmail.org) Emacs/24.4.1
\r
53 (x86_64-pc-linux-gnu)
\r
54 Date: Sat, 24 Jan 2015 16:59:16 +0200
\r
55 Message-ID: <871tmkql6j.fsf@nikula.org>
\r
57 Content-Type: text/plain
\r
58 Cc: "Jan N. Klug" <jan.n.klug@rub.de>, Stefano Zacchiroli <zack@upsilon.cc>
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Sat, 24 Jan 2015 14:59:14 -0000
\r
73 On Sat, 24 Jan 2015, Stefano Zacchiroli <zack@upsilon.cc> wrote:
\r
74 > From: "Jan N. Klug" <jan.n.klug@rub.de>
\r
76 > For those messages, compute a synthetic Message-ID based on the SHA1
\r
77 > of the whole message, in the same way that notmuch would do. See:
\r
78 > http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c
\r
80 As I said on IRC, I think this is a notmuch implementation detail, and
\r
81 we don't make any promises about always generating missing message-ids
\r
82 the same way. That said, I don't see any reason why we'd change this
\r
83 anytime soon, so the solution is probably good enough for now.
\r
85 > To do the above, rewrite get_message_id() to scan the current message
\r
86 > line by line, incrementally computing a SHA1. As a consequence, drop
\r
87 > the dependency on Mail::Internet.
\r
89 I am not so sure this is a good idea however, see below.
\r
91 > Signed-off-by: Stefano Zacchiroli <zack@upsilon.cc>
\r
93 > contrib/notmuch-mutt/README | 4 ++--
\r
94 > contrib/notmuch-mutt/notmuch-mutt | 23 ++++++++++++++++++-----
\r
95 > 2 files changed, 20 insertions(+), 7 deletions(-)
\r
97 > diff --git a/contrib/notmuch-mutt/README b/contrib/notmuch-mutt/README
\r
98 > index c661447..0013ed0 100644
\r
99 > --- a/contrib/notmuch-mutt/README
\r
100 > +++ b/contrib/notmuch-mutt/README
\r
101 > @@ -33,10 +33,10 @@ Requirements
\r
103 > To *run* notmuch-mutt you will need Perl with the following libraries:
\r
105 > +- Digest::SHA <https://metacpan.org/release/Digest-SHA>
\r
106 > + (Debian package: libdigest-sha-perl)
\r
107 > - Mail::Box <https://metacpan.org/pod/Mail::Box>
\r
108 > (Debian package: libmail-box-perl)
\r
109 > -- Mail::Internet <https://metacpan.org/pod/Mail::Internet>
\r
110 > - (Debian package: libmailtools-perl)
\r
111 > - String::ShellQuote <https://metacpan.org/pod/String::ShellQuote>
\r
112 > (Debian package: libstring-shellquote-perl)
\r
113 > - Term::ReadLine::Gnu <https://metacpan.org/pod/Term::ReadLine::Gnu>
\r
114 > diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
\r
115 > index 4969e4b..4d30b0b 100755
\r
116 > --- a/contrib/notmuch-mutt/notmuch-mutt
\r
117 > +++ b/contrib/notmuch-mutt/notmuch-mutt
\r
118 > @@ -13,11 +13,11 @@ use warnings;
\r
121 > use Getopt::Long qw(:config no_getopt_compat);
\r
122 > -use Mail::Internet;
\r
123 > use Mail::Box::Maildir;
\r
125 > use String::ShellQuote;
\r
126 > use Term::ReadLine;
\r
127 > +use Digest::SHA;
\r
130 > my $xdg_cache_dir = "$ENV{HOME}/.cache";
\r
131 > @@ -75,10 +75,23 @@ sub prompt($$) {
\r
134 > sub get_message_id() {
\r
135 > - my $mail = Mail::Internet->new(\*STDIN);
\r
136 > - my $mid = $mail->head->get("message-id") or return undef;
\r
137 > - $mid =~ /^<(.*)>$/; # get message-id value
\r
139 > + my $mid = undef;
\r
140 > + my $sha = Digest::SHA->new(1); # SHA1 hashing
\r
142 > + while(<STDIN>) { # scan message line by line, looking for mid
\r
143 > + if ($_ =~ /^Message-ID:\s*<(.*)>$/i) {
\r
145 This doesn't take into account header folding or end of headers. There's
\r
146 probably a bunch of other things to consider in the relevant RFCs. I
\r
147 think you really should use Mail::Internet for the common case, and only
\r
148 fallback to generating the message-id when that fails.
\r
154 > + last; # message-id found, abort scan
\r
156 > + $sha->add($_); # update hash
\r
159 > + # Generate message-id from hash if none was found, in the same way
\r
160 > + # that notmuch would do.
\r
161 > + # See: http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c
\r
162 > + $mid ||= "notmuch-sha1-".$sha->hexdigest;
\r
167 > sub search_action($$$@) {
\r
171 > _______________________________________________
\r
172 > notmuch mailing list
\r
173 > notmuch@notmuchmail.org
\r
174 > http://notmuchmail.org/mailman/listinfo/notmuch
\r