unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit
  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 ` William Casarin
  0 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2019-11-17 22:29 UTC (permalink / raw)
  To: notmuch

This allows us to close both windows at the same time.

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

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index b9173790..367b10c4 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -530,10 +530,10 @@ Shows in split pane or whole window according to value of
   (when (notmuch-tree-scroll-message-window)
     (notmuch-tree-next-matching-message)))
 
-(defun notmuch-tree-quit ()
+(defun notmuch-tree-quit (&optional kill-both)
   "Close the split view or exit tree."
-  (interactive)
-  (unless (notmuch-tree-close-message-window)
+  (interactive "P")
+  (when (or (not (notmuch-tree-close-message-window)) kill-both)
     (kill-buffer (current-buffer))))
 
 (defun notmuch-tree-close-message-window ()
-- 
2.23.0

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

* [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread
@ 2020-04-04 20:41 William Casarin
  2020-04-04 20:41 ` [PATCH 2/7] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
                   ` (11 more replies)
  0 siblings, 12 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

This will allow us to pop back to parent buffers when there are no
more threads to jump to.

Signed-off-by: William Casarin <jb55@jb55.com>
---

 This is as rebased version of id:20191228150124.20630-1-jb55@jb55.com
 as requested in id:87v9mg3gut.fsf@tethera.net 

 emacs/notmuch-tree.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 9a83292c..1bcf6cf9 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -679,10 +679,13 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-thread-top))
 
 (defun notmuch-tree-next-thread ()
+  "Get the next thread in the current tree. Returns t if a thread was
+found or nil if not."
   (interactive)
   (forward-line 1)
   (while (not (or (notmuch-tree-get-prop :first) (eobp)))
-    (forward-line 1)))
+    (forward-line 1))
+  (not (eobp)))
 
 (defun notmuch-tree-thread-mapcar (function)
   "Iterate through all messages in the current thread
-- 
2.25.1

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

* [PATCH 2/7] emacs/tree: add notmuch-tree-goto-matching-message
  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 ` William Casarin
  2020-04-04 20:41 ` [PATCH 3/7] emacs/tree: add notmuch-tree-matching-message William Casarin
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

This function captures some common logic when jumping to matching
messages in notmuch-tree mode.

We also add a new return value (t or nil), that indicates if there was
a next matching message in the thread to show.

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

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 1bcf6cf9..7f68efba 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -631,12 +631,23 @@ message will be \"unarchived\", i.e. the tag changes in
   (when (window-live-p notmuch-tree-message-window)
     (notmuch-tree-show-message-in)))
 
+(defun notmuch-tree-goto-matching-message (&optional prev)
+  "Move to the next or previous matching message.
+
+Returns t if there was a next matching message in the thread to show,
+nil otherwise."
+  (let ((dir (if prev -1 nil))
+	(eobfn (if prev #'bobp #'eobp)))
+    (while (and (not (funcall eobfn))
+		(not (notmuch-tree-get-match)))
+      (forward-line dir))
+    (not (funcall eobfn))))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
   (forward-line -1)
-  (while (and (not (bobp)) (not (notmuch-tree-get-match)))
-    (forward-line -1))
+  (notmuch-tree-goto-matching-message t)
   (when (window-live-p notmuch-tree-message-window)
     (notmuch-tree-show-message-in)))
 
@@ -644,8 +655,7 @@ message will be \"unarchived\", i.e. the tag changes in
   "Move to next matching message."
   (interactive)
   (forward-line)
-  (while (and (not (eobp)) (not (notmuch-tree-get-match)))
-    (forward-line))
+  (notmuch-tree-goto-matching-message)
   (when (window-live-p notmuch-tree-message-window)
     (notmuch-tree-show-message-in)))
 
-- 
2.25.1

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

* [PATCH 3/7] emacs/tree: add notmuch-tree-matching-message
  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 2/7] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
@ 2020-04-04 20:41 ` William Casarin
  2020-04-04 20:41 ` [PATCH 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

This functions removes some duplicate logic between
notmuch-tree-{next,prev}-matching-message

We do this because we will be adding some additional logic similar to
the notmuch-show-next-open-message function, and it will help if this
logic is all in one place.

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

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 7f68efba..e6a6e67f 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -643,21 +643,23 @@ nil otherwise."
       (forward-line dir))
     (not (funcall eobfn))))
 
+(defun notmuch-tree-matching-message (&optional prev)
+  "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)))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
-  (forward-line -1)
-  (notmuch-tree-goto-matching-message t)
-  (when (window-live-p notmuch-tree-message-window)
-    (notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message t))
 
 (defun notmuch-tree-next-matching-message ()
   "Move to next matching message."
   (interactive)
-  (forward-line)
-  (notmuch-tree-goto-matching-message)
-  (when (window-live-p notmuch-tree-message-window)
-    (notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message))
 
 (defun notmuch-tree-refresh-view (&optional view)
   "Refresh view."
-- 
2.25.1

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

* [PATCH 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit
  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 2/7] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
  2020-04-04 20:41 ` [PATCH 3/7] emacs/tree: add notmuch-tree-matching-message William Casarin
@ 2020-04-04 20:41 ` William Casarin
  2020-04-04 20:41 ` [PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

This allows us to close both windows at the same time.

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

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index e6a6e67f..b405e9e3 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -584,10 +584,10 @@ Shows in split pane or whole window according to value of
   (when (notmuch-tree-scroll-message-window)
     (notmuch-tree-next-matching-message)))
 
-(defun notmuch-tree-quit ()
+(defun notmuch-tree-quit (&optional kill-both)
   "Close the split view or exit tree."
-  (interactive)
-  (unless (notmuch-tree-close-message-window)
+  (interactive "P")
+  (when (or (not (notmuch-tree-close-message-window)) kill-both)
     (kill-buffer (current-buffer))))
 
 (defun notmuch-tree-close-message-window ()
-- 
2.25.1

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

* [PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit
  2020-04-04 20:41 [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
                   ` (2 preceding siblings ...)
  2020-04-04 20:41 ` [PATCH 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
@ 2020-04-04 20:41 ` William Casarin
  2020-04-04 20:41 ` [PATCH v4 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

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 b405e9e3..02bdd1ee 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -617,6 +617,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)
@@ -643,23 +652,24 @@ nil otherwise."
       (forward-line dir))
     (not (funcall eobfn))))
 
-(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 (not (notmuch-tree-goto-matching-message prev)) pop-at-end)
+      (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 (&optional view)
   "Refresh view."
-- 
2.25.1

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

* [PATCH v4 1/7] emacs/tree: return true if a thread was found in next-thread
  2020-04-04 20:41 [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
                   ` (3 preceding siblings ...)
  2020-04-04 20:41 ` [PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
@ 2020-04-04 20:41 ` William Casarin
  2020-04-04 20:41 ` [PATCH v4 2/7] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

This will allow us to pop back to parent buffers when there are no
more threads to jump to.

Signed-off-by: William Casarin <jb55@jb55.com>
---

This is just a rebased version of v3 id:20191228150124.20630-1-jb55@jb55.com
as requested in id:87v9mg3gut.fsf@tethera.net 

 emacs/notmuch-tree.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 9a83292c..1bcf6cf9 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -679,10 +679,13 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-thread-top))
 
 (defun notmuch-tree-next-thread ()
+  "Get the next thread in the current tree. Returns t if a thread was
+found or nil if not."
   (interactive)
   (forward-line 1)
   (while (not (or (notmuch-tree-get-prop :first) (eobp)))
-    (forward-line 1)))
+    (forward-line 1))
+  (not (eobp)))
 
 (defun notmuch-tree-thread-mapcar (function)
   "Iterate through all messages in the current thread

base-commit: 144cf30e2c71d57795b5fbdec10af0ef73aa01ff
-- 
2.25.1

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

* [PATCH v4 2/7] emacs/tree: add notmuch-tree-goto-matching-message
  2020-04-04 20:41 [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
                   ` (4 preceding siblings ...)
  2020-04-04 20:41 ` [PATCH v4 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
@ 2020-04-04 20:41 ` William Casarin
  2020-04-04 20:41 ` [PATCH v4 3/7] emacs/tree: add notmuch-tree-matching-message William Casarin
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

This function captures some common logic when jumping to matching
messages in notmuch-tree mode.

We also add a new return value (t or nil), that indicates if there was
a next matching message in the thread to show.

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

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 1bcf6cf9..7f68efba 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -631,12 +631,23 @@ message will be \"unarchived\", i.e. the tag changes in
   (when (window-live-p notmuch-tree-message-window)
     (notmuch-tree-show-message-in)))
 
+(defun notmuch-tree-goto-matching-message (&optional prev)
+  "Move to the next or previous matching message.
+
+Returns t if there was a next matching message in the thread to show,
+nil otherwise."
+  (let ((dir (if prev -1 nil))
+	(eobfn (if prev #'bobp #'eobp)))
+    (while (and (not (funcall eobfn))
+		(not (notmuch-tree-get-match)))
+      (forward-line dir))
+    (not (funcall eobfn))))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
   (forward-line -1)
-  (while (and (not (bobp)) (not (notmuch-tree-get-match)))
-    (forward-line -1))
+  (notmuch-tree-goto-matching-message t)
   (when (window-live-p notmuch-tree-message-window)
     (notmuch-tree-show-message-in)))
 
@@ -644,8 +655,7 @@ message will be \"unarchived\", i.e. the tag changes in
   "Move to next matching message."
   (interactive)
   (forward-line)
-  (while (and (not (eobp)) (not (notmuch-tree-get-match)))
-    (forward-line))
+  (notmuch-tree-goto-matching-message)
   (when (window-live-p notmuch-tree-message-window)
     (notmuch-tree-show-message-in)))
 
-- 
2.25.1

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

* [PATCH v4 3/7] emacs/tree: add notmuch-tree-matching-message
  2020-04-04 20:41 [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
                   ` (5 preceding siblings ...)
  2020-04-04 20:41 ` [PATCH v4 2/7] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
@ 2020-04-04 20:41 ` William Casarin
  2020-04-04 20:41 ` [PATCH v4 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

This functions removes some duplicate logic between
notmuch-tree-{next,prev}-matching-message

We do this because we will be adding some additional logic similar to
the notmuch-show-next-open-message function, and it will help if this
logic is all in one place.

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

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 7f68efba..e6a6e67f 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -643,21 +643,23 @@ nil otherwise."
       (forward-line dir))
     (not (funcall eobfn))))
 
+(defun notmuch-tree-matching-message (&optional prev)
+  "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)))
+
 (defun notmuch-tree-prev-matching-message ()
   "Move to previous matching message."
   (interactive)
-  (forward-line -1)
-  (notmuch-tree-goto-matching-message t)
-  (when (window-live-p notmuch-tree-message-window)
-    (notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message t))
 
 (defun notmuch-tree-next-matching-message ()
   "Move to next matching message."
   (interactive)
-  (forward-line)
-  (notmuch-tree-goto-matching-message)
-  (when (window-live-p notmuch-tree-message-window)
-    (notmuch-tree-show-message-in)))
+  (notmuch-tree-matching-message))
 
 (defun notmuch-tree-refresh-view (&optional view)
   "Refresh view."
-- 
2.25.1

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

* [PATCH v4 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit
  2020-04-04 20:41 [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
                   ` (6 preceding siblings ...)
  2020-04-04 20:41 ` [PATCH v4 3/7] emacs/tree: add notmuch-tree-matching-message William Casarin
@ 2020-04-04 20:41 ` William Casarin
  2020-04-04 20:41 ` [PATCH v4 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

This allows us to close both windows at the same time.

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

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index e6a6e67f..b405e9e3 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -584,10 +584,10 @@ Shows in split pane or whole window according to value of
   (when (notmuch-tree-scroll-message-window)
     (notmuch-tree-next-matching-message)))
 
-(defun notmuch-tree-quit ()
+(defun notmuch-tree-quit (&optional kill-both)
   "Close the split view or exit tree."
-  (interactive)
-  (unless (notmuch-tree-close-message-window)
+  (interactive "P")
+  (when (or (not (notmuch-tree-close-message-window)) kill-both)
     (kill-buffer (current-buffer))))
 
 (defun notmuch-tree-close-message-window ()
-- 
2.25.1

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

* [PATCH v4 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit
  2020-04-04 20:41 [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
                   ` (7 preceding siblings ...)
  2020-04-04 20:41 ` [PATCH v4 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
@ 2020-04-04 20:41 ` William Casarin
  2020-04-04 20:41 ` [PATCH v4 6/7] emacs/tree: add notmuch-tree-archive-thread-then-exit William Casarin
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

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 b405e9e3..02bdd1ee 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -617,6 +617,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)
@@ -643,23 +652,24 @@ nil otherwise."
       (forward-line dir))
     (not (funcall eobfn))))
 
-(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 (not (notmuch-tree-goto-matching-message prev)) pop-at-end)
+      (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 (&optional view)
   "Refresh view."
-- 
2.25.1

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

* [PATCH v4 6/7] emacs/tree: add notmuch-tree-archive-thread-then-exit
  2020-04-04 20:41 [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
                   ` (8 preceding siblings ...)
  2020-04-04 20:41 ` [PATCH v4 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
@ 2020-04-04 20:41 ` William Casarin
  2020-04-04 20:41 ` [PATCH v4 7/7] emacs/tree: add x/X bindings William Casarin
  2020-04-04 20:44 ` [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

This is the notmuch-tree version of
notmuch-show-archive-thread-then-exit

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

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 02bdd1ee..470cd517 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -617,6 +617,12 @@ message will be \"unarchived\", i.e. the tag changes in
   (notmuch-tree-archive-message unarchive)
   (notmuch-tree-next-matching-message))
 
+(defun notmuch-tree-archive-thread-then-exit ()
+  "Archive all messages in the current buffer, then exit notmuch-tree."
+  (interactive)
+  (notmuch-tree-archive-thread)
+  (notmuch-tree-quit t))
+
 (defun notmuch-tree-archive-message-then-next-or-exit ()
   "Archive current message, then show next open message in current thread.
 
-- 
2.25.1

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

* [PATCH v4 7/7] emacs/tree: add x/X bindings
  2020-04-04 20:41 [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
                   ` (9 preceding siblings ...)
  2020-04-04 20:41 ` [PATCH v4 6/7] emacs/tree: add notmuch-tree-archive-thread-then-exit William Casarin
@ 2020-04-04 20:41 ` William Casarin
  2020-04-04 20:44 ` [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
  11 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:41 UTC (permalink / raw)
  To: notmuch

Add x and X binds to notmuch-tree for functionally that we have in
notmuch-show.

The notmuch-tree-quit binding is somewhat redundant, since it is
handled by notmuch-bury-or-kill-this-buffer which is bound to q.

Signed-off-by: William Casarin <jb55@jb55.com>
---
 emacs/notmuch-tree.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 470cd517..e5c23de2 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -319,7 +319,8 @@ FUNC."
     ;; The main tree view bindings
     (define-key map (kbd "RET") 'notmuch-tree-show-message)
     (define-key map [mouse-1] 'notmuch-tree-show-message)
-    (define-key map "x" 'notmuch-tree-quit)
+    (define-key map "x" 'notmuch-tree-archive-message-then-next-or-exit)
+    (define-key map "X" 'notmuch-tree-archive-thread-then-exit)
     (define-key map "A" 'notmuch-tree-archive-thread)
     (define-key map "a" 'notmuch-tree-archive-message-then-next)
     (define-key map "z" 'notmuch-tree-to-tree)
-- 
2.25.1

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

* Re: [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread
  2020-04-04 20:41 [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
                   ` (10 preceding siblings ...)
  2020-04-04 20:41 ` [PATCH v4 7/7] emacs/tree: add x/X bindings William Casarin
@ 2020-04-04 20:44 ` William Casarin
  2020-04-06 11:26   ` David Bremner
  11 siblings, 1 reply; 15+ messages in thread
From: William Casarin @ 2020-04-04 20:44 UTC (permalink / raw)
  To: notmuch


William Casarin <jb55@jb55.com> writes:

> This will allow us to pop back to parent buffers when there are no
> more threads to jump to.
>
> Signed-off-by: William Casarin <jb55@jb55.com>
> ---
>
>  This is as rebased version of id:20191228150124.20630-1-jb55@jb55.com
>  as requested in id:87v9mg3gut.fsf@tethera.net 

sorry I included some duplicate patches in here, but they should be identical.

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

* Re: [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread
  2020-04-04 20:44 ` [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
@ 2020-04-06 11:26   ` David Bremner
  0 siblings, 0 replies; 15+ messages in thread
From: David Bremner @ 2020-04-06 11:26 UTC (permalink / raw)
  To: William Casarin, notmuch

William Casarin <jb55@jb55.com> writes:

> William Casarin <jb55@jb55.com> writes:
>
>> This will allow us to pop back to parent buffers when there are no
>> more threads to jump to.
>>
>> Signed-off-by: William Casarin <jb55@jb55.com>
>> ---
>>
>>  This is as rebased version of id:20191228150124.20630-1-jb55@jb55.com
>>  as requested in id:87v9mg3gut.fsf@tethera.net 
>
> sorry I included some duplicate patches in here, but they should be identical.

I have pushed the rebased series to master

d

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

end of thread, other threads:[~2020-04-06 11:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 2/7] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
2020-04-04 20:41 ` [PATCH 3/7] emacs/tree: add notmuch-tree-matching-message William Casarin
2020-04-04 20:41 ` [PATCH 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
2020-04-04 20:41 ` [PATCH 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
2020-04-04 20:41 ` [PATCH v4 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
2020-04-04 20:41 ` [PATCH v4 2/7] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
2020-04-04 20:41 ` [PATCH v4 3/7] emacs/tree: add notmuch-tree-matching-message William Casarin
2020-04-04 20:41 ` [PATCH v4 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
2020-04-04 20:41 ` [PATCH v4 5/7] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
2020-04-04 20:41 ` [PATCH v4 6/7] emacs/tree: add notmuch-tree-archive-thread-then-exit William Casarin
2020-04-04 20:41 ` [PATCH v4 7/7] emacs/tree: add x/X bindings William Casarin
2020-04-04 20:44 ` [PATCH 1/7] emacs/tree: return true if a thread was found in next-thread William Casarin
2020-04-06 11:26   ` David Bremner
  -- strict thread matches above, loose matches on Subject: below --
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 4/7] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin

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).