--- /dev/null
+Return-Path: <dme@dme.org>\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 141B1431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 19 May 2014 09:09:28 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 e-OCpqxzafbN for <notmuch@notmuchmail.org>;\r
+ Mon, 19 May 2014 09:09:24 -0700 (PDT)\r
+Received: from mail-we0-f171.google.com (mail-we0-f171.google.com\r
+ [74.125.82.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id C9642431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 19 May 2014 09:09:23 -0700 (PDT)\r
+Received: by mail-we0-f171.google.com with SMTP id w62so5798167wes.16\r
+ for <notmuch@notmuchmail.org>; Mon, 19 May 2014 09:09:19 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:subject:date:message-id;\r
+ bh=6DaI1fcCp1FrHP2fUzpI4hqGpX29SDdZWiXouuu7r68=;\r
+ b=a1yf9f32/6xLtnm4cf5xTXrvjIWbAdPTIV8roujA/3YHuSSXvlRKKqwuY63Ye1rDx4\r
+ 3213AHnsoGFzsR3TCkwEsZRnF1hehOAtYl3ntaaMBJbILjrkxsbXGtIh1h99kLqXNU1+\r
+ ZHdtpDiI8T1OUZMXxtkTEjhrbyzXVdg/1o1toGJhe/r45D8GHD2abFqejZvtD3UNdFjk\r
+ SWYFN51SUQmmZ2hlqffv4WfjYIvOXKZzOUVvRZ7kpz/8SeV3KkCREUipwnLVtk+AXdzZ\r
+ KhWva646ixBSJl2clRLDq0HLAx5U0e/kcXU/yf18hKYEPJh6Q/cOGgsulYyWBq4SPKH8\r
+ 1Tig==\r
+X-Gm-Message-State:\r
+ ALoCoQn0pTjvBNCNDqY0o1OOTG8+2mSSPBwLwX0yrrDJAWZ+qXodtECvviwNf5+qEDnUKNHk8v4C\r
+X-Received: by 10.180.11.196 with SMTP id s4mr3305804wib.34.1400515759536;\r
+ Mon, 19 May 2014 09:09:19 -0700 (PDT)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+ ([2a01:348:1a2:1:a288:b4ff:fe8a:77d8])\r
+ by mx.google.com with ESMTPSA id\r
+ nb8sm15760615wic.18.2014.05.19.09.09.17 for <notmuch@notmuchmail.org>\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Mon, 19 May 2014 09:09:18 -0700 (PDT)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id 8CD9410FF2D; Mon, 19 May 2014 17:09:16 +0100 (BST)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v1] emacs: `notmuch-search-find-stable-query-region' should\r
+ never return an empty query.\r
+Date: Mon, 19 May 2014 17:09:16 +0100\r
+Message-Id: <1400515756-31779-1-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 2.0.0.rc0\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, 19 May 2014 16:09:28 -0000\r
+\r
+`notmuch-search-find-stable-query-region' is expected to examine the\r
+region between `beg' and `end' to generate a query that can be used to\r
+include all threads in that region. If the region contains no threads,\r
+it should throw an error rather than generating an empty query.\r
+---\r
+\r
+Whilst logging calls to 'notmuch' from the UI, I noticed that it would generate\r
+ notmuch tag -inbox -- ()\r
+if I hit 'a' at the very end of a search buffer. That seems at least\r
+useless and possibly bad, so flag an error in this case instead.\r
+\r
+Oh, the first bit is just cleanup.\r
+\r
+ emacs/notmuch.el | 5 ++++-\r
+ 1 file changed, 4 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 8aa0104..74103a6 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -429,12 +429,15 @@ matched and unmatched messages in the current thread."\r
+ \r
+ If ONLY-MATCHED is non-nil, include only matched messages. If it\r
+ is nil, include both matched and unmatched messages."\r
+- (let ((query-list nil) (all (not only-matched)))\r
++ (let ((all (not only-matched))\r
++ query-list)\r
+ (dolist (queries (notmuch-search-properties-in-region :query beg end))\r
+ (when (first queries)\r
+ (push (first queries) query-list))\r
+ (when (and all (second queries))\r
+ (push (second queries) query-list)))\r
++ (unless query-list\r
++ (error "No threads in region."))\r
+ (concat "(" (mapconcat 'identity query-list ") or (") ")")))\r
+ \r
+ (defun notmuch-search-find-authors ()\r
+-- \r
+2.0.0.rc0\r
+\r