--- /dev/null
+Return-Path: <zack@upsilon.cc>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 184C3431FC9\r
+ for <notmuch@notmuchmail.org>; Mon, 9 Feb 2015 01:41:47 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.338\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.338 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id KdBz1qqFDXv1 for <notmuch@notmuchmail.org>;\r
+ Mon, 9 Feb 2015 01:41:43 -0800 (PST)\r
+Received: from upsilon.cc (upsilon.cc [178.32.142.91])\r
+ by olra.theworths.org (Postfix) with ESMTP id 01A98431FCF\r
+ for <notmuch@notmuchmail.org>; Mon, 9 Feb 2015 01:41:42 -0800 (PST)\r
+Received: from timira.takhisis.invalid (maths.r-prg.net.univ-paris7.fr\r
+ [81.194.27.158]) by upsilon.cc (Postfix) with ESMTPSA id 3027710E51;\r
+ Mon, 9 Feb 2015 10:41:42 +0100 (CET)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=upsilon.cc; s=mail;\r
+ t=1423474902; bh=RgHHPbGpmwrC43KVLpMI0KL6u7qnoOE81WWVapPJEks=;\r
+ h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\r
+ b=hD9Mm3RoW2N9HRoSUxzajfz4DA1odJMp4dkx37MqniN0N6CdL36P0NfcFAthJ7By8\r
+ hU7pttveu4lZK7/jcyKt8wURYBuWUcY7xtamJhEAFxO4tZtdsytsgsgOlTx74HxEDX\r
+ pmEhk3TntLM6ymfDLRSIykSZy6JoXWHOq8Qv9/iQ=\r
+Received: by timira.takhisis.invalid (Postfix, from userid 1000)\r
+ id BA0A9600E1; Mon, 9 Feb 2015 10:41:41 +0100 (CET)\r
+From: Stefano Zacchiroli <zack@upsilon.cc>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] notmuch-mutt: support for messages that lack Message-ID\r
+ headers\r
+Date: Mon, 9 Feb 2015 10:41:30 +0100\r
+Message-Id: <1423474890-16972-3-git-send-email-zack@upsilon.cc>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1423474890-16972-1-git-send-email-zack@upsilon.cc>\r
+References: <1423474890-16972-1-git-send-email-zack@upsilon.cc>\r
+Cc: zack@upsilon.cc\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 09 Feb 2015 09:41:47 -0000\r
+\r
+From: "Jan N. Klug" <jan.n.klug@rub.de>\r
+\r
+For those messages, compute a synthetic Message-ID based on the SHA1\r
+of the whole message, in the same way that notmuch would do. See:\r
+http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c\r
+\r
+To do the above, rewrite get_message_id() to scan the current message\r
+line by line, incrementally computing a SHA1. If a Message-ID is found\r
+the SHA1 computation will be aborted; otherwise used for the synthetic\r
+Message-ID.\r
+\r
+Signed-off-by: Stefano Zacchiroli <zack@upsilon.cc>\r
+---\r
+ contrib/notmuch-mutt/README | 4 +++-\r
+ contrib/notmuch-mutt/notmuch-mutt | 33 ++++++++++++++++++++++++++++-----\r
+ 2 files changed, 31 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/contrib/notmuch-mutt/README b/contrib/notmuch-mutt/README\r
+index c661447..9c3379e 100644\r
+--- a/contrib/notmuch-mutt/README\r
++++ b/contrib/notmuch-mutt/README\r
+@@ -33,9 +33,11 @@ Requirements\r
+ \r
+ To *run* notmuch-mutt you will need Perl with the following libraries:\r
+ \r
++- Digest::SHA <https://metacpan.org/release/Digest-SHA>\r
++ (Debian package: libdigest-sha-perl)\r
+ - Mail::Box <https://metacpan.org/pod/Mail::Box>\r
+ (Debian package: libmail-box-perl)\r
+-- Mail::Internet <https://metacpan.org/pod/Mail::Internet>\r
++- Mail::Header <https://metacpan.org/pod/Mail::Header>\r
+ (Debian package: libmailtools-perl)\r
+ - String::ShellQuote <https://metacpan.org/pod/String::ShellQuote>\r
+ (Debian package: libstring-shellquote-perl)\r
+diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt\r
+index 4969e4b..84af140 100755\r
+--- a/contrib/notmuch-mutt/notmuch-mutt\r
++++ b/contrib/notmuch-mutt/notmuch-mutt\r
+@@ -13,11 +13,12 @@ use warnings;\r
+ \r
+ use File::Path;\r
+ use Getopt::Long qw(:config no_getopt_compat);\r
+-use Mail::Internet;\r
++use Mail::Header;\r
+ use Mail::Box::Maildir;\r
+ use Pod::Usage;\r
+ use String::ShellQuote;\r
+ use Term::ReadLine;\r
++use Digest::SHA;\r
+ \r
+ \r
+ my $xdg_cache_dir = "$ENV{HOME}/.cache";\r
+@@ -75,10 +76,32 @@ sub prompt($$) {\r
+ }\r
+ \r
+ sub get_message_id() {\r
+- my $mail = Mail::Internet->new(\*STDIN);\r
+- my $mid = $mail->head->get("message-id") or return undef;\r
+- $mid =~ /^<(.*)>$/; # get message-id value\r
+- return $1;\r
++ my $mid = undef;\r
++ my $in_header = 1;\r
++ my @raw_header = ();\r
++ my $sha = Digest::SHA->new(1); # SHA1 hash of the whole mail\r
++\r
++ while (<STDIN>) { # compute SHA1 as we go\r
++ push(@raw_header, $_) if $in_header; # cache header lines\r
++ if ($_ =~ /^$/) { # end of header, parse it and look for Message-ID\r
++ $in_header = 0;\r
++ my $head = Mail::Header->new(\@raw_header);\r
++ $mid = $head->get("message-id") or undef;\r
++ if ($mid) {\r
++ $mid =~ /^<(.*)>$/; # get message-id value\r
++ $mid = $1;\r
++ last; # stop hashing\r
++ }\r
++ }\r
++ $sha->add($_); # update hash\r
++ }\r
++\r
++ # If no message-id was found, generate one-id in the same way that\r
++ # notmuch would do.\r
++ # See: http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c\r
++ $mid ||= "notmuch-sha1-".$sha->hexdigest;\r
++\r
++ return $mid;\r
+ }\r
+ \r
+ sub search_action($$$@) {\r
+-- \r
+2.1.4\r
+\r