unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v2 1/2] emacs: Make indentation more consistent in notmuch-search-show-thread
@ 2022-05-02 15:18 Leo Okawa Ericson
  2022-05-02 15:18 ` [PATCH v2 2/2] emacs: Make notmuch-show-next-thread return nil on failure Leo Okawa Ericson
  2022-05-03 14:20 ` [PATCH v2 1/2] emacs: Make indentation more consistent in notmuch-search-show-thread Tomi Ollila
  0 siblings, 2 replies; 4+ messages in thread
From: Leo Okawa Ericson @ 2022-05-02 15:18 UTC (permalink / raw)
  To: notmuch

---
 emacs/notmuch.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c9cf80dc..c1ddb06b 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -525,13 +525,13 @@ (defun notmuch-search-show-thread (&optional elide-toggle)
   (let ((thread-id (notmuch-search-find-thread-id)))
     (if thread-id
 	(notmuch-show thread-id
-		      elide-toggle
-		      (current-buffer)
-		      notmuch-search-query-string
-		      ;; Name the buffer based on the subject.
-		      (format "*%s*" (truncate-string-to-width
-				      (notmuch-search-find-subject)
-				      30 nil nil t)))
+	       elide-toggle
+	       (current-buffer)
+	       notmuch-search-query-string
+	       ;; Name the buffer based on the subject.
+	       (format "*%s*" (truncate-string-to-width
+			       (notmuch-search-find-subject)
+			       30 nil nil t)))
       (message "End of search results."))))
 
 (defun notmuch-tree-from-search-current-query ()

base-commit: e3ad0087f3453c89871acac8b11da8bab1ac54df
-- 
2.36.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] emacs: Make notmuch-show-next-thread return nil on failure
  2022-05-02 15:18 [PATCH v2 1/2] emacs: Make indentation more consistent in notmuch-search-show-thread Leo Okawa Ericson
@ 2022-05-02 15:18 ` Leo Okawa Ericson
  2022-05-03 14:20 ` [PATCH v2 1/2] emacs: Make indentation more consistent in notmuch-search-show-thread Tomi Ollila
  1 sibling, 0 replies; 4+ messages in thread
From: Leo Okawa Ericson @ 2022-05-02 15:18 UTC (permalink / raw)
  To: notmuch

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've added docstrings and tests, but I'm not sure if the location I put
the tests in is appropriate.

 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 c1ddb06b..a87d416a 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.GV3165@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.GV3165@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:lars@seas.harvard.edu and subject:\"Maildir storage\"")
-- 
2.36.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] emacs: Make indentation more consistent in notmuch-search-show-thread
  2022-05-02 15:18 [PATCH v2 1/2] emacs: Make indentation more consistent in notmuch-search-show-thread Leo Okawa Ericson
  2022-05-02 15:18 ` [PATCH v2 2/2] emacs: Make notmuch-show-next-thread return nil on failure Leo Okawa Ericson
@ 2022-05-03 14:20 ` Tomi Ollila
  2022-05-03 14:56   ` Leo Okawa Ericson
  1 sibling, 1 reply; 4+ messages in thread
From: Tomi Ollila @ 2022-05-03 14:20 UTC (permalink / raw)
  To: Leo Okawa Ericson, notmuch

On Mon, May 02 2022, Leo Okawa Ericson wrote:

> ---
>  emacs/notmuch.el | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index c9cf80dc..c1ddb06b 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -525,13 +525,13 @@ (defun notmuch-search-show-thread (&optional elide-toggle)
>    (let ((thread-id (notmuch-search-find-thread-id)))
>      (if thread-id
>  	(notmuch-show thread-id
> -		      elide-toggle
> -		      (current-buffer)
> -		      notmuch-search-query-string
> -		      ;; Name the buffer based on the subject.
> -		      (format "*%s*" (truncate-string-to-width
> -				      (notmuch-search-find-subject)
> -				      30 nil nil t)))

To me it looks like this change "breaks" indentation -- the original
where all function (notmuch-show) arguments are aligned vertically,
starting from same column in each line...???

> +	       elide-toggle
> +	       (current-buffer)
> +	       notmuch-search-query-string
> +	       ;; Name the buffer based on the subject.
> +	       (format "*%s*" (truncate-string-to-width
> +			       (notmuch-search-find-subject)
> +			       30 nil nil t)))
>        (message "End of search results."))))
>  
>  (defun notmuch-tree-from-search-current-query ()
>
> base-commit: e3ad0087f3453c89871acac8b11da8bab1ac54df

btw: what is this 'base commit:' line ?

Tomi

> -- 
> 2.36.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] emacs: Make indentation more consistent in notmuch-search-show-thread
  2022-05-03 14:20 ` [PATCH v2 1/2] emacs: Make indentation more consistent in notmuch-search-show-thread Tomi Ollila
@ 2022-05-03 14:56   ` Leo Okawa Ericson
  0 siblings, 0 replies; 4+ messages in thread
From: Leo Okawa Ericson @ 2022-05-03 14:56 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:

> To me it looks like this change "breaks" indentation -- the original
> where all function (notmuch-show) arguments are aligned vertically,
> starting from same column in each line...???
>

Argh, it was me that was stupid.  I had nameless-mode activated which
affects indentation.  Please ignore that commit then (I'll retract it
with the next re-roll) and apologies for the inconvenience.

>>
>> base-commit: e3ad0087f3453c89871acac8b11da8bab1ac54df
>
> btw: what is this 'base commit:' line ?
>

It's included in the patch by git-format-patch.  I think it helps git to
know on which commit to apply these patches to.  Other projects mandated
that option so I have it on by default.

/Leo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-03 14:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-02 15:18 [PATCH v2 1/2] emacs: Make indentation more consistent in notmuch-search-show-thread Leo Okawa Ericson
2022-05-02 15:18 ` [PATCH v2 2/2] emacs: Make notmuch-show-next-thread return nil on failure Leo Okawa Ericson
2022-05-03 14:20 ` [PATCH v2 1/2] emacs: Make indentation more consistent in notmuch-search-show-thread Tomi Ollila
2022-05-03 14:56   ` Leo Okawa Ericson

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).