[PATCH v1] emacs: Report a lack of matches when calling `notmuch-show'.

Subject: [PATCH v1] emacs: Report a lack of matches when calling `notmuch-show'.

Date: Sat, 6 Feb 2016 18:21:32 +0000

To: notmuch@notmuchmail.org

Cc:

From: David Edmondson


If the basic query passed to `notmuch-show' generates no results,
throw an error and inform the user that no messages matched the query
rather than displaying an empty buffer and showing an obscure error.
---
 emacs/notmuch-show.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 3345878..335992e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1248,7 +1248,13 @@ function is used."
 	(when (and (eq (buffer-size) 0)
 		   notmuch-show-query-context)
 	  (notmuch-show-insert-forest
-	   (notmuch-query-get-threads (append cli-args basic-args)))))
+	   (notmuch-query-get-threads (append cli-args basic-args))))
+
+	;; If there are still no results, kill the buffer and throw an
+	;; error.
+	(when (eq (buffer-size) 0)
+	  (kill-buffer (current-buffer))
+	  (error "No messages matched the query.")))
 
       (jit-lock-register #'notmuch-show-buttonise-links)
 
-- 
2.1.4


Thread: