On Mon, Feb 08 2016, Mark Walters <markwalters1009@gmail.com> wrote: > On Sat, 06 Feb 2016, David Edmondson <dme@dme.org> wrote: >> 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. > > Hi > > First this is a clear improvement on the current behaviour, an I am > happy with it as is. > > However, I wonder if we actually want an error at all in this case, > rather than just a "message". I think some people run with > debug-on-error enabled and it might be annoying in that case (though > clearly less annoying than the current situation). Actually I got the same when testing (notmuch-show "id:nonexistent") M-x eval-print-last-sexp instead of M-x eval-last-sexp (C-j in lisp-interaction buffer, instead of c-x c-e) ... I agree that if we handle the situation, perhaps throwing an error is not the best way... > [If anyone cares the current error comes from the marking read code in > the post-command hook which assumes the buffer has a message] > > Best wishes > > Mark > > >> --- >> 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