]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Make notmuch-show-next-thread return nil on failure
authorLeo Okawa Ericson <git@relevant-information.com>
Thu, 9 Jun 2022 15:18:22 +0000 (17:18 +0200)
committerDavid Bremner <david@tethera.net>
Mon, 13 Jun 2022 11:06:51 +0000 (08:06 -0300)
Having notmuch-show-next-thread return non-nil on success and nil on
failure makes it easier for users to interact with notmuch via elisp.

This commit changes notmuch-search-show-thread too since the return
value of notmuch-show-next-thread depends on notmuch-search-show-thread.

Amended by db: fix whitespace in T450-emacs-show

emacs/notmuch-show.el
emacs/notmuch.el
test/T450-emacs-show.sh

index 203ca7f07bfa3e099a0d2dc54031c9937685dff8..aded1ee745e8f4fe065245053010b83e21e970f0 100644 (file)
@@ -2227,7 +2227,9 @@ argument, hide all of the messages."
 If SHOW is non-nil, open the next item in a show
 buffer. Otherwise just highlight the next item in the search
 buffer. If PREVIOUS is non-nil, move to the previous item in the
-search results instead."
+search results instead.
+
+Return non-nil on success."
   (interactive "P")
   (let ((parent-buffer notmuch-show-parent-buffer))
     (notmuch-bury-or-kill-this-buffer)
index c9cf80dc619e2a60f96473abee13beca23236d69..01a929973bd4499ec9697e90c4e3b378bd55b63f 100644 (file)
@@ -520,7 +520,9 @@ no messages in the region then return nil."
 
 With a prefix argument, invert the default value of
 `notmuch-show-only-matching-messages' when displaying the
-thread."
+thread.
+
+Return non-nil on success."
   (interactive "P")
   (let ((thread-id (notmuch-search-find-thread-id)))
     (if thread-id
@@ -532,7 +534,8 @@ thread."
                      (format "*%s*" (truncate-string-to-width
                                      (notmuch-search-find-subject)
                                      30 nil nil t)))
-      (message "End of search results."))))
+      (message "End of search results.")
+      nil)))
 
 (defun notmuch-tree-from-search-current-query ()
   "Tree view of current query."
index 678efd8b02a503a0e2559fff2c23a0b8f8259f8c..0c1f620497df724c2ee41ddfd547505af6e45406 100755 (executable)
@@ -62,6 +62,17 @@ test_emacs '(let ((notmuch-crypto-process-mime nil))
        (test-visible-output))'
 test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-on OUTPUT
 
+test_begin_subtest "notmuch-search-show-thread returns non-nil on success"
+test_emacs_expect_t  '(notmuch-search "id:20091117203301.GV3165@dottiness.seas.harvard.edu")
+                     (notmuch-test-wait)
+                     (and (notmuch-search-show-thread)
+                          (not (notmuch-show-next-thread)))'
+
+test_begin_subtest "notmuch-search-show-thread returns nil when there are no messages"
+test_emacs_expect_t  '(notmuch-search "id:non-existing-id")
+                     (notmuch-test-wait)
+                     (not (notmuch-search-show-thread))'
+
 test_begin_subtest "notmuch-show: don't elide non-matching messages"
 test_emacs '(let ((notmuch-show-only-matching-messages nil))
        (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")