Re: [PATCH v3] emacs: Make notmuch-show-next-thread return nil on failure

2022-05-26 Thread David Bremner
Leo Okawa Ericson  writes:

> +test_begin_subtest "notmuch-search-show-thread returns non-nil on success"
> +test_emacs_expect_t  '(notmuch-search 
> "id:20091117203301.gv3...@dottiness.seas.harvard.edu")
> +   (when (notmuch-search-show-thread)
> + (error "Expected non-nil when successfully showing a 
> thread"))
> +   (when (notmuch-show-next-thread)
> + (error "Expected nil when there are no more threads"))
> +   t'
> +
> +test_begin_subtest "notmuch-show-next-thread returns non-nil on success"
> +test_emacs_expect_t  '(notmuch-search 
> "id:20091117203301.gv3...@dottiness.seas.harvard.edu")
> +   (when (notmuch-show-next-thread)
> + (error "Expected non-nil when successfully showing a 
> thread"))
> +   (when (notmuch-show-next-thread)
> + (error "Expected nil when there are no more threads"))
> +   t)'
> +

- There are some whitespace issues that git complains about (space
  before tab). That seems fixable with a judicious application of M-x
  tabify. There is also an extra space after test_emacs_expect_t.

- The tests look like there there is some over enthusiastic copy
  pasting, since both test both functions, which makes them duplicate
  tests.

- Not sure why you need to throw errors here, can't you just return t or
  nil?

- the logic of the "when" does not seem to match the string for the
  error. Are you expecting the function calls to succeed or not?

d

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH v3] emacs: Make notmuch-show-next-thread return nil on failure

2022-05-18 Thread Leo Okawa Ericson


Hello,

Is there any update on this?  I think I've fixed all the issues.

/Leo
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH v3] emacs: Make notmuch-show-next-thread return nil on failure

2022-05-05 Thread Leo Okawa Ericson
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.
---

I removed the indentation commit because it was plain wrong.
Otherwise it's the same as the previous patch series.

Previous patch message id: id:20220502151849.6364-1-...@relevant-information.com

 emacs/notmuch-show.el   |  4 +++-
 emacs/notmuch.el|  7 +--
 test/T450-emacs-show.sh | 16 
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7c1f02c9..5a2bbe5c 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -2205,7 +2205,9 @@ (defun notmuch-show-next-thread (&optional show previous)
 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)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c9cf80dc..01a92997 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -520,7 +520,9 @@ (defun notmuch-search-show-thread (&optional elide-toggle)
 
 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 @@ (defun notmuch-search-show-thread (&optional elide-toggle)
  (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."
diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh
index 057ad37e..ee25a403 100755
--- a/test/T450-emacs-show.sh
+++ b/test/T450-emacs-show.sh
@@ -62,6 +62,22 @@ 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.gv3...@dottiness.seas.harvard.edu")
+ (when (notmuch-search-show-thread)
+   (error "Expected non-nil when successfully showing a 
thread"))
+ (when (notmuch-show-next-thread)
+   (error "Expected nil when there are no more threads"))
+ t'
+
+test_begin_subtest "notmuch-show-next-thread returns non-nil on success"
+test_emacs_expect_t  '(notmuch-search 
"id:20091117203301.gv3...@dottiness.seas.harvard.edu")
+ (when (notmuch-show-next-thread)
+   (error "Expected non-nil when successfully showing a 
thread"))
+ (when (notmuch-show-next-thread)
+   (error "Expected nil when there are no more threads"))
+ t)'
+
 test_begin_subtest "notmuch-show: don't elide non-matching messages"
 test_emacs '(let ((notmuch-show-only-matching-messages nil))
(notmuch-search "from:l...@seas.harvard.edu and subject:\"Maildir 
storage\"")

base-commit: b2eb0547e172dd766ccbc062319faa90a9500518
-- 
2.36.0

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org