unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: William Casarin <jb55@jb55.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit
Date: Sun, 17 Nov 2019 14:29:27 -0800	[thread overview]
Message-ID: <20191117222929.1064-6-jb55@jb55.com> (raw)
In-Reply-To: <20191117222929.1064-1-jb55@jb55.com>

This is the notmuch-tree version of
notmuch-show-archive-message-than-next-or-exit.

Signed-off-by: William Casarin <jb55@jb55.com>
---
 emacs/notmuch-tree.el | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 367b10c4..fd6f9f83 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -563,6 +563,15 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-message-then-next-or-exit ()
+  "Archive current message, then show next open message in current thread.
+
+If at the last open message in the current thread, then exit back
+to search results."
+  (interactive)
+  (notmuch-tree-archive-message)
+  (notmuch-tree-next-matching-message t))
+
 (defun notmuch-tree-next-message ()
   "Move to next message."
   (interactive)
@@ -588,23 +597,24 @@ nil otherwise."
       (forward-line (if prev -1 nil)))
     (not last)))
 
-(defun notmuch-tree-matching-message (&optional prev)
+(defun notmuch-tree-matching-message (&optional prev pop-at-end)
   "Move to the next or previous matching message"
   (interactive "P")
   (forward-line (if prev -1 nil))
-  (notmuch-tree-goto-matching-message prev)
-  (when (window-live-p notmuch-tree-message-window)
-    (notmuch-tree-show-message-in)))
+  (if (and pop-at-end (not (notmuch-tree-goto-matching-message prev)))
+      (notmuch-tree-quit pop-at-end)
+    (when (window-live-p notmuch-tree-message-window)
+      (notmuch-tree-show-message-in))))
 
-(defun notmuch-tree-prev-matching-message ()
+(defun notmuch-tree-prev-matching-message (&optional pop-at-end)
   "Move to previous matching message."
-  (interactive)
-  (notmuch-tree-matching-message t))
+  (interactive "P")
+  (notmuch-tree-matching-message t pop-at-end))
 
-(defun notmuch-tree-next-matching-message ()
+(defun notmuch-tree-next-matching-message (&optional pop-at-end)
   "Move to next matching message."
-  (interactive)
-  (notmuch-tree-matching-message))
+  (interactive "P")
+  (notmuch-tree-matching-message nil pop-at-end))
 
 (defun notmuch-tree-refresh-view ()
   "Refresh view."
-- 
2.23.0

  parent reply	other threads:[~2019-11-17 22:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-17 22:29 [PATCH 0/7] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
2019-11-17 22:29 ` [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
2019-11-17 22:29 ` [PATCH 2/7] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
2019-11-17 22:29 ` [PATCH 3/7] emacs/tree: add notmuch-tree-matching-message William Casarin
2019-11-17 22:29 ` [PATCH 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
2019-11-17 22:29 ` William Casarin [this message]
2019-11-17 23:17   ` [PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
2019-11-18 14:49     ` David Edmondson
2019-11-18 15:21       ` William Casarin
2019-11-17 22:29 ` [PATCH 6/7] emacs/tree: add notmuch-tree-archive-thread-then-exit William Casarin
2019-11-17 22:29 ` [PATCH 7/7] emacs/tree: add x/X bindings William Casarin
2019-11-20  8:10 ` [PATCH 0/7] Port notmuch-show's x/X bindings to notmuch-tree Teemu Likonen
2019-11-27 19:01   ` Teemu Likonen
  -- strict thread matches above, loose matches on Subject: below --
2020-04-04 20:41 [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
2020-04-04 20:41 ` [PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin

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=20191117222929.1064-6-jb55@jb55.com \
    --to=jb55@jb55.com \
    --cc=notmuch@notmuchmail.org \
    /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).