From: William Casarin <jb55@jb55.com>
To: notmuch@notmuchmail.org
Cc: Teemu Likonen <tlikonen@iki.fi>, William Casarin <jb55@jb55.com>
Subject: [PATCH v2 2/3] emacs/tree: enable moving to next thread in search results
Date: Tue, 11 Aug 2020 10:36:52 -0700 [thread overview]
Message-ID: <20200811173653.18109-2-jb55@jb55.com> (raw)
In-Reply-To: <20200811173653.18109-1-jb55@jb55.com>
This introduces a new function called
notmuch-tree-next-thread-from-search which is analogous to
notmuch-show-next-thread. It will switch to the next or previous
thread from the parent search results.
We rename notmuch-tree-{prev,next}-thread to a more descriptive
notmuch-tree-{prev,next}-thread-in-tree to reflect the fact that it
only moves to the next thread in the current tree.
notmuch-tree-next-thread now switches to the next thread in the
current tree first, but if there are none, it looks for the next tree
in the search results.
This makes notmuch-tree feel more like notmuch-show when using the
M-Enter, M-n and M-p bindings.
Signed-off-by: William Casarin <jb55@jb55.com>
---
emacs/notmuch-tree.el | 40 +++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 29f64851..bf500b60 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -725,12 +725,14 @@ nil otherwise."
(while (not (or (notmuch-tree-get-prop :first) (eobp)))
(forward-line -1))))
-(defun notmuch-tree-prev-thread ()
+(defun notmuch-tree-prev-thread-in-tree ()
+ "Move to the previous thread in the current tree"
(interactive)
(forward-line -1)
- (notmuch-tree-thread-top))
+ (notmuch-tree-thread-top)
+ (not (bobp)))
-(defun notmuch-tree-next-thread ()
+(defun notmuch-tree-next-thread-in-tree ()
"Get the next thread in the current tree. Returns t if a thread was
found or nil if not."
(interactive)
@@ -739,6 +741,38 @@ found or nil if not."
(forward-line 1))
(not (eobp)))
+(defun notmuch-tree-next-thread-from-search (&optional previous)
+ "Move to the next thread in the parent search results, if any.
+
+If PREVIOUS is non-nil, move to the previous item in the
+search results instead."
+ (interactive "P")
+ (let ((parent-buffer notmuch-tree-parent-buffer))
+ (notmuch-tree-quit t)
+ (when (buffer-live-p parent-buffer)
+ (switch-to-buffer parent-buffer)
+ (if previous
+ (notmuch-search-previous-thread)
+ (notmuch-search-next-thread))
+ (notmuch-tree-from-search-thread))))
+
+(defun notmuch-tree-next-thread (&optional previous)
+ "Move to the next thread in the current tree or parent search
+results
+
+If PREVIOUS is non-nil, move to the previous thread in the tree or
+search results instead."
+ (interactive)
+ (unless (if previous (notmuch-tree-prev-thread-in-tree)
+ (notmuch-tree-next-thread-in-tree))
+ (notmuch-tree-next-thread-from-search previous)))
+
+(defun notmuch-tree-prev-thread ()
+ "Move to the previous thread in the current tree or parent search
+results"
+ (interactive)
+ (notmuch-tree-next-thread t))
+
(defun notmuch-tree-thread-mapcar (function)
"Iterate through all messages in the current thread
and call FUNCTION for side effects."
--
2.28.0
next prev parent reply other threads:[~2020-08-11 17:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-11 17:36 [PATCH v2 1/3] emacs/tree: introduce notmuch-tree-parent-buffer variable William Casarin
2020-08-11 17:36 ` William Casarin [this message]
2020-08-15 12:54 ` [PATCH v2 2/3] emacs/tree: enable moving to next thread in search results David Bremner
2020-08-11 17:36 ` [PATCH v2 3/3] emacs/tree: add notmuch-tree-archive-thread-then-next William Casarin
2020-08-15 12:32 ` [PATCH v2 1/3] emacs/tree: introduce notmuch-tree-parent-buffer variable David Bremner
2020-08-15 12:41 ` David Bremner
2020-08-16 13:59 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200811173653.18109-2-jb55@jb55.com \
--to=jb55@jb55.com \
--cc=notmuch@notmuchmail.org \
--cc=tlikonen@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).