1 Return-Path: <zack@upsilon.cc>
\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 B1000429E52
\r
6 for <notmuch@notmuchmail.org>; Sun, 15 Feb 2015 04:39:26 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=2.338 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled
\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 xra-Ckl5x7Sk for <notmuch@notmuchmail.org>;
\r
17 Sun, 15 Feb 2015 04:39:23 -0800 (PST)
\r
18 Received: from upsilon.cc (upsilon.cc [178.32.142.91])
\r
19 by olra.theworths.org (Postfix) with ESMTP id A7E6B431FDB
\r
20 for <notmuch@notmuchmail.org>; Sun, 15 Feb 2015 04:39:22 -0800 (PST)
\r
21 Received: from timira.takhisis.invalid (unknown [78.194.69.54])
\r
22 by upsilon.cc (Postfix) with ESMTPSA id 91C9010E6B;
\r
23 Sun, 15 Feb 2015 13:39:20 +0100 (CET)
\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=upsilon.cc; s=mail;
\r
25 t=1424003960; bh=Est5Ya7UcbOQdLIWcVleB3ZNQtr1stGCiE/bwF671ls=;
\r
26 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
\r
27 b=a8gwLM+nHi0gx0TZSiLDpB3nKHwRIKxv1mhucrFZ+qIjcFIagfSYxzhFzqxln/O/c
\r
28 D3qhOKJs96togZwn3pNoxpXQbtNUHJVTNxh8k3NXTKWgmg3y1yIMDrNkIpaaV6TQaV
\r
29 sOx1A+WCDiyybr4ET80oSX7YoBPRM0S3mimwB9l8=
\r
30 Received: by timira.takhisis.invalid (Postfix, from userid 1000)
\r
31 id E5FDF600E0; Sun, 15 Feb 2015 13:39:19 +0100 (CET)
\r
32 From: Stefano Zacchiroli <zack@upsilon.cc>
\r
33 To: notmuch@notmuchmail.org
\r
34 Subject: [PATCH 3/3] notmuch-mutt: support for messages that lack Message-ID
\r
36 Date: Sun, 15 Feb 2015 13:39:08 +0100
\r
37 Message-Id: <1424003948-17642-4-git-send-email-zack@upsilon.cc>
\r
38 X-Mailer: git-send-email 2.1.4
\r
39 In-Reply-To: <1424003948-17642-1-git-send-email-zack@upsilon.cc>
\r
40 References: <m2twyvyx41.fsf@guru.guru-group.fi>
\r
41 <1424003948-17642-1-git-send-email-zack@upsilon.cc>
\r
43 X-BeenThere: notmuch@notmuchmail.org
\r
44 X-Mailman-Version: 2.1.13
\r
46 List-Id: "Use and development of the notmuch mail system."
\r
47 <notmuch.notmuchmail.org>
\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
51 List-Post: <mailto:notmuch@notmuchmail.org>
\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
55 X-List-Received-Date: Sun, 15 Feb 2015 12:39:27 -0000
\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 accumulate header lines,
\r
62 parse them to check for Message-ID, and fallback to SHA1 computation
\r
63 if it is not present.
\r
66 - Jan N. Klug for preliminary versions of this patch
\r
67 - Tomi Ollila for suggesting an elegant implementation
\r
69 contrib/notmuch-mutt/README | 4 +++-
\r
70 contrib/notmuch-mutt/notmuch-mutt | 30 +++++++++++++++++++++++++-----
\r
71 2 files changed, 28 insertions(+), 6 deletions(-)
\r
73 diff --git a/contrib/notmuch-mutt/README b/contrib/notmuch-mutt/README
\r
74 index c661447..9c3379e 100644
\r
75 --- a/contrib/notmuch-mutt/README
\r
76 +++ b/contrib/notmuch-mutt/README
\r
77 @@ -33,9 +33,11 @@ Requirements
\r
79 To *run* notmuch-mutt you will need Perl with the following libraries:
\r
81 +- Digest::SHA <https://metacpan.org/release/Digest-SHA>
\r
82 + (Debian package: libdigest-sha-perl)
\r
83 - Mail::Box <https://metacpan.org/pod/Mail::Box>
\r
84 (Debian package: libmail-box-perl)
\r
85 -- Mail::Internet <https://metacpan.org/pod/Mail::Internet>
\r
86 +- Mail::Header <https://metacpan.org/pod/Mail::Header>
\r
87 (Debian package: libmailtools-perl)
\r
88 - String::ShellQuote <https://metacpan.org/pod/String::ShellQuote>
\r
89 (Debian package: libstring-shellquote-perl)
\r
90 diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
\r
91 index 6d4d60c..126cbf4 100755
\r
92 --- a/contrib/notmuch-mutt/notmuch-mutt
\r
93 +++ b/contrib/notmuch-mutt/notmuch-mutt
\r
94 @@ -13,11 +13,12 @@ use warnings;
\r
97 use Getopt::Long qw(:config no_getopt_compat);
\r
98 -use Mail::Internet;
\r
100 use Mail::Box::Maildir;
\r
102 use String::ShellQuote;
\r
103 use Term::ReadLine;
\r
107 my $xdg_cache_dir = "$ENV{HOME}/.cache";
\r
108 @@ -75,10 +76,29 @@ sub prompt($$) {
\r
111 sub get_message_id() {
\r
112 - my $mail = Mail::Internet->new(\*STDIN);
\r
113 - my $mid = $mail->head->get("message-id") or return undef;
\r
114 - $mid =~ /^<(.*)>$/; # get message-id value
\r
117 + my @headers = ();
\r
119 + while (<STDIN>) { # collect header lines in @headers
\r
120 + push(@headers, $_);
\r
121 + last if $_ =~ /^$/;
\r
123 + my $head = Mail::Header->new(\@headers);
\r
124 + $mid = $head->get("message-id") or undef;
\r
126 + if ($mid) { # Message-ID header found
\r
127 + $mid =~ /^<(.*)>$/; # extract message id
\r
129 + } else { # Message-ID header not found, synthesize a message id
\r
130 + # based on SHA1, as notmuch would do. See:
\r
131 + # http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c
\r
132 + my $sha = Digest::SHA->new(1);
\r
133 + $sha->add($_) foreach(@headers);
\r
134 + $sha->addfile(\*STDIN);
\r
135 + $mid = 'notmuch-sha1-' . $sha->hexdigest;
\r
141 sub search_action($$$@) {
\r