--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\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 5772D431FC2\r
+ for <notmuch@notmuchmail.org>; Mon, 9 Feb 2015 06:32:28 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.438\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
+ tests=[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 aGDFXdGqY+vX for <notmuch@notmuchmail.org>;\r
+ Mon, 9 Feb 2015 06:32:23 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 03BA8431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 9 Feb 2015 06:32:22 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 010B2100051;\r
+ Mon, 9 Feb 2015 16:31:58 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Stefano Zacchiroli <zack@upsilon.cc>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/2] notmuch-mutt: support for messages that lack\r
+ Message-ID headers\r
+In-Reply-To: <1423474890-16972-3-git-send-email-zack@upsilon.cc>\r
+References: <1423474890-16972-1-git-send-email-zack@upsilon.cc>\r
+ <1423474890-16972-3-git-send-email-zack@upsilon.cc>\r
+User-Agent: Notmuch/0.19+53~gb45d2f9 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Mon, 09 Feb 2015 16:31:58 +0200\r
+Message-ID: <m2twyvyx41.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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 14:32:28 -0000\r
+\r
+On Mon, Feb 09 2015, Stefano Zacchiroli <zack@upsilon.cc> wrote:\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
+I'd suggest the (something like) following way:\r
+\r
+First loop through headers, push lines to the array.\r
+\r
+check for Message-Id (using Mail::Header): if found, return it\r
+\r
+else message id not found:\r
+ \r
+ my $sha = Digest::SHA->new(1);\r
+ $sha->add($_) foreach(@raw_header);\r
+ $sha->addfile(\*STDIN);\r
+ return 'notmuch-sha1-' . $sha->hexdigest;\r
+\r
+(BTW: the implementation in the patch (below) would check for message-id in\r
+@raw_header every time mail has an empty line ?)\r
+\r
+Tomi\r
+\r
+\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
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r