--- /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 02AE3431FBC\r
+ for <notmuch@notmuchmail.org>; Thu, 14 Feb 2013 00:37:19 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 0Gkb2LB44SyG for <notmuch@notmuchmail.org>;\r
+ Thu, 14 Feb 2013 00:37:16 -0800 (PST)\r
+Received: from upsilon.hackadomia.org (upsilon.hackadomia.org\r
+ [91.121.245.170]) by olra.theworths.org (Postfix) with ESMTP id B04CD431FAF\r
+ for <notmuch@notmuchmail.org>; Thu, 14 Feb 2013 00:37:15 -0800 (PST)\r
+Received: from usha.takhisis.invalid (unknown\r
+ [IPv6:2a01:e34:eecc:42f0:76e5:bff:fea7:56b8])\r
+ by upsilon.hackadomia.org (Postfix) with ESMTPSA id 954487E00D;\r
+ Thu, 14 Feb 2013 09:37:13 +0100 (CET)\r
+Received: by usha.takhisis.invalid (Postfix, from userid 1000)\r
+ id 0ED45680849; Thu, 14 Feb 2013 09:37:13 +0100 (CET)\r
+Date: Thu, 14 Feb 2013 09:37:13 +0100\r
+From: Stefano Zacchiroli <zack@upsilon.cc>\r
+To: Profpatsch <mail@profpatsch.de>\r
+Subject: Re: notmuch-mutt: Use of uninitialized value.\r
+Message-ID: <20130214083713.GA4123@upsilon.cc>\r
+References: <20130212005801.GA8419@soarin> <20130213223535.GA3258@zaogao.lan>\r
+ <20130213233657.GA4489@soarin>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK"\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: 8bit\r
+In-Reply-To: <20130213233657.GA4489@soarin>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+Cc: David Bremner <bremner@unb.ca>, notmuch@notmuchmail.org\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: Thu, 14 Feb 2013 08:37:19 -0000\r
+\r
+\r
+--YZ5djTAD1cGYuMQK\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: 8bit\r
+\r
+On Thu, Feb 14, 2013 at 12:36:58AM +0100, Profpatsch wrote:\r
+> On 13-02-13 02:35pm, Kevin J. McCarthy wrote:\r
+> > A more likely idea is to check whether you have $pipe_decode set.\r
+> \r
+> BRILLIANT!\r
+> So much for copying a basic rc from someone else.\r
+> Of course, that was it and I’m officially an idiot.\r
+\r
+Neat, thanks Kevin for debugging the issue down to $pipe_decode (which\r
+I've never used, mutt never stops to amaze me :-)).\r
+\r
+> And apparently Mail::Internet errors out if there is no Message-ID.\r
+> (Which mentioned in the docs at CPAN…)\r
+> \r
+> Mystery solved.\r
+\r
+Right, but still a more graceful failure model would be nice.\r
+\r
+Please find attached a patch that in such cases should 1) give a\r
+supposedly nice error message explaining what's going on and 2) empty\r
+the results dir to avoid showing you unrelated results. It works for me.\r
+But extra checking never hurts, in particular for the tag action, which\r
+I don't personally use.\r
+\r
+I guess it would also be nice to actually disable $pipe_decode in the\r
+relevant Mutt macros, but I'm not sure about to do that without\r
+interfering with user desired configuration. Kevin: do you know if there\r
+is a common Mutt trick to store the value of a variable before changing\r
+it, and restoring it a posteriori? More isolation for this kind of\r
+things in Mutt would definitely be welcome...\r
+\r
+Cheers.\r
+-- \r
+Stefano Zacchiroli . . . . . . . zack@upsilon.cc . . . . o . . . o . o\r
+Maître de conférences . . . . . http://upsilon.cc/zack . . . o . . . o o\r
+Debian Project Leader . . . . . . @zack on identi.ca . . o o o . . . o .\r
+« the first rule of tautology club is the first rule of tautology club »\r
+\r
+--YZ5djTAD1cGYuMQK\r
+Content-Type: text/x-diff; charset=us-ascii\r
+Content-Disposition: attachment;\r
+ filename="0001-notmuch-mutt-more-graceful-handling-of-missing-Messa.patch"\r
+\r
+>From b67ab95855ce7d279d8c0b3ddcbc20e679afc70b Mon Sep 17 00:00:00 2001\r
+From: Stefano Zacchiroli <zack@upsilon.cc>\r
+Date: Thu, 14 Feb 2013 09:31:37 +0100\r
+Subject: [PATCH] notmuch-mutt: more graceful handling of missing Message-Id\r
+ errors\r
+\r
+in particular:\r
+- the "thread" action would print an error and empty results dir\r
+- the "tag action would print an error\r
+---\r
+ contrib/notmuch-mutt/notmuch-mutt | 8 +++++++-\r
+ 1 file changed, 7 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt\r
+index d14709d..bc97908 100755\r
+--- a/contrib/notmuch-mutt/notmuch-mutt\r
++++ b/contrib/notmuch-mutt/notmuch-mutt\r
+@@ -121,7 +121,8 @@ sub prompt($$) {\r
+ \r
+ sub get_message_id() {\r
+ my $mail = Mail::Internet->new(\*STDIN);\r
+- $mail->head->get("message-id") =~ /^<(.*)>$/; # get message-id\r
++ my $mid = $mail->head->get("message-id") or return undef;\r
++ $mid =~ /^<(.*)>$/; # get message-id value\r
+ return $1;\r
+ }\r
+ \r
+@@ -142,6 +143,10 @@ sub thread_action($$@) {\r
+ my ($results_dir, $remove_dups, @params) = @_;\r
+ \r
+ my $mid = get_message_id();\r
++ if (! defined $mid) {\r
++ empty_maildir($results_dir);\r
++ die "notmuch-mutt: cannot find Message-Id, abort.\n";\r
++ }\r
+ my $search_cmd = 'notmuch search --output=threads ' . shell_quote("id:$mid");\r
+ my $tid = `$search_cmd`; # get thread id\r
+ chomp($tid);\r
+@@ -151,6 +156,7 @@ sub thread_action($$@) {\r
+ \r
+ sub tag_action(@) {\r
+ my $mid = get_message_id();\r
++ defined $mid or die "notmuch-mutt: cannot find Message-Id, abort.\n";\r
+ \r
+ system("notmuch tag "\r
+ . shell_quote(join(' ', @_))\r
+-- \r
+1.7.10.4\r
+\r
+\r
+--YZ5djTAD1cGYuMQK--\r