* [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree
@ 2019-11-28 16:13 William Casarin
2019-11-28 16:13 ` [PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread William Casarin
` (8 more replies)
0 siblings, 9 replies; 15+ messages in thread
From: William Casarin @ 2019-11-28 16:13 UTC (permalink / raw
To: notmuch
These patches bring notmuch-tree more in line with the user experience
of notmuch-show by adding the x/X bindings.
v2:
- fix a bug when moving between open messages
- include M-RET keybinding patch from id:20191113225752.26502-1-jb55@jb55.com
v1: id:20191117222929.1064-1-jb55@jb55.com
William Casarin (8):
emacs/tree: return true if a thread was found in next-thread
emacs/tree: add notmuch-tree-goto-matching-message
emacs/tree: add notmuch-tree-matching-message
emacs/tree: add kill-both prefix argument to notmuch-tree-quit
emacs/tree: add notmuch-tree-archive-message-than-next-or-exit
emacs/tree: add notmuch-tree-archive-thread-then-exit
emacs/tree: add x/X bindings
emacs: bind M-RET to notmuch-tree-from-search-thread
emacs/notmuch-tree.el | 72 +++++++++++++++++++++++++++++++------------
emacs/notmuch.el | 1 +
2 files changed, 53 insertions(+), 20 deletions(-)
Range-diff:
1: 04f7138f = 1: 16972fa8 emacs/tree: return true if a thread was found in next-thread
2: c1f58bf3 = 2: 54e166a9 emacs/tree: add notmuch-tree-goto-matching-message
3: ef6d5da3 = 3: d68d2050 emacs/tree: add notmuch-tree-matching-message
4: 777ea3eb = 4: 8432bc9a emacs/tree: add kill-both prefix argument to notmuch-tree-quit
5: fc2497ad ! 5: 0c3f996d emacs/tree: add notmuch-tree-archive-message-than-next-or-exit
@@ emacs/notmuch-tree.el: nil otherwise."
- (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)))
++ (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))))
6: bf3107fa = 6: 17545910 emacs/tree: add notmuch-tree-archive-thread-then-exit
7: 9fea4f9e = 7: fbcb3ee0 emacs/tree: add x/X bindings
-: -------- > 8: ac0f03a2 emacs: bind M-RET to notmuch-tree-from-search-thread
base-commit: 7ad7cfbff232431377562271901ee00202bf0bd0
--
2.23.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
@ 2019-11-28 16:13 ` William Casarin
2019-11-28 16:24 ` David Edmondson
2019-11-28 16:13 ` [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
` (7 subsequent siblings)
8 siblings, 1 reply; 15+ messages in thread
From: William Casarin @ 2019-11-28 16:13 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>
---
emacs/notmuch-tree.el | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index c00315e8..4bc05160 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -620,10 +620,14 @@ 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)))
+ (let (end)
+ (while (not (or (notmuch-tree-get-prop :first) (setq end (eobp))))
+ (forward-line 1))
+ (not end)))
(defun notmuch-tree-thread-mapcar (function)
"Iterate through all messages in the current thread
--
2.23.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
2019-11-28 16:13 ` [PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread William Casarin
@ 2019-11-28 16:13 ` William Casarin
2019-11-28 16:25 ` David Edmondson
2019-11-28 16:13 ` [PATCH v2 3/8] emacs/tree: add notmuch-tree-matching-message William Casarin
` (6 subsequent siblings)
8 siblings, 1 reply; 15+ messages in thread
From: William Casarin @ 2019-11-28 16:13 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 | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 4bc05160..9f2d87b5 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -577,12 +577,22 @@ 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 (last)
+ (while (and (not (setq last (if prev (bobp) (eobp))))
+ (not (notmuch-tree-get-match)))
+ (forward-line (if prev -1 nil)))
+ (not last)))
+
(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)))
@@ -590,8 +600,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.23.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 3/8] emacs/tree: add notmuch-tree-matching-message
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
2019-11-28 16:13 ` [PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread William Casarin
2019-11-28 16:13 ` [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
@ 2019-11-28 16:13 ` William Casarin
2019-11-28 16:13 ` [PATCH v2 4/8] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
` (5 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2019-11-28 16:13 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 9f2d87b5..b9173790 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -588,21 +588,23 @@ nil otherwise."
(forward-line (if prev -1 nil)))
(not last)))
+(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 ()
"Refresh view."
--
2.23.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 4/8] emacs/tree: add kill-both prefix argument to notmuch-tree-quit
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
` (2 preceding siblings ...)
2019-11-28 16:13 ` [PATCH v2 3/8] emacs/tree: add notmuch-tree-matching-message William Casarin
@ 2019-11-28 16:13 ` William Casarin
2019-11-28 16:13 ` [PATCH v2 5/8] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
` (4 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2019-11-28 16:13 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 v2 5/8] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
` (3 preceding siblings ...)
2019-11-28 16:13 ` [PATCH v2 4/8] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
@ 2019-11-28 16:13 ` William Casarin
2019-11-28 16:13 ` [PATCH v2 6/8] emacs/tree: add notmuch-tree-archive-thread-then-exit William Casarin
` (3 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2019-11-28 16:13 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 367b10c4..8e596459 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 (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 ()
"Refresh view."
--
2.23.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 6/8] emacs/tree: add notmuch-tree-archive-thread-then-exit
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
` (4 preceding siblings ...)
2019-11-28 16:13 ` [PATCH v2 5/8] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
@ 2019-11-28 16:13 ` William Casarin
2019-11-28 16:14 ` [PATCH v2 7/8] emacs/tree: add x/X bindings William Casarin
` (2 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2019-11-28 16:13 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 8e596459..40838487 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -563,6 +563,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.23.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 7/8] emacs/tree: add x/X bindings
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
` (5 preceding siblings ...)
2019-11-28 16:13 ` [PATCH v2 6/8] emacs/tree: add notmuch-tree-archive-thread-then-exit William Casarin
@ 2019-11-28 16:14 ` William Casarin
2019-11-28 16:14 ` [PATCH v2 8/8] emacs: bind M-RET to notmuch-tree-from-search-thread William Casarin
2019-12-04 17:01 ` [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree Teemu Likonen
8 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2019-11-28 16:14 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 40838487..bdf0d832 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -277,7 +277,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.23.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 8/8] emacs: bind M-RET to notmuch-tree-from-search-thread
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
` (6 preceding siblings ...)
2019-11-28 16:14 ` [PATCH v2 7/8] emacs/tree: add x/X bindings William Casarin
@ 2019-11-28 16:14 ` William Casarin
2019-12-04 17:01 ` [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree Teemu Likonen
8 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2019-11-28 16:14 UTC (permalink / raw
To: notmuch
This is an unbound function that is quite useful. It opens a selected
thread in notmuch-tree from the current search query.
Signed-off-by: William Casarin <jb55@jb55.com>
---
emacs/notmuch.el | 1 +
1 file changed, 1 insertion(+)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 773d1206..0d68d123 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -188,6 +188,7 @@ there will be called at other points of notmuch execution."
(define-key map "-" 'notmuch-search-remove-tag)
(define-key map "+" 'notmuch-search-add-tag)
(define-key map (kbd "RET") 'notmuch-search-show-thread)
+ (define-key map (kbd "M-RET") 'notmuch-tree-from-search-thread)
(define-key map "Z" 'notmuch-tree-from-search-current-query)
map)
"Keymap for \"notmuch search\" buffers.")
--
2.23.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread
2019-11-28 16:13 ` [PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread William Casarin
@ 2019-11-28 16:24 ` David Edmondson
2019-12-04 19:14 ` William Casarin
0 siblings, 1 reply; 15+ messages in thread
From: David Edmondson @ 2019-11-28 16:24 UTC (permalink / raw
To: William Casarin, notmuch
On Thursday, 2019-11-28 at 08:13:54 -08, William Casarin wrote:
> 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>
> ---
> emacs/notmuch-tree.el | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index c00315e8..4bc05160 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -620,10 +620,14 @@ 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)))
> + (let (end)
> + (while (not (or (notmuch-tree-get-prop :first) (setq end (eobp))))
> + (forward-line 1))
> + (not end)))
Does using the variable add much value here? It makes the code look more
strange and removing it would add the cost of just one more call to
`eobp'.
>
> (defun notmuch-tree-thread-mapcar (function)
> "Iterate through all messages in the current thread
> --
> 2.23.0
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
dme.
--
But uh oh, I love her because, she moves in her own way.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message
2019-11-28 16:13 ` [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
@ 2019-11-28 16:25 ` David Edmondson
2019-12-04 19:15 ` William Casarin
0 siblings, 1 reply; 15+ messages in thread
From: David Edmondson @ 2019-11-28 16:25 UTC (permalink / raw
To: William Casarin, notmuch
On Thursday, 2019-11-28 at 08:13:55 -08, William Casarin wrote:
> 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 | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index 4bc05160..9f2d87b5 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -577,12 +577,22 @@ 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 (last)
> + (while (and (not (setq last (if prev (bobp) (eobp))))
> + (not (notmuch-tree-get-match)))
> + (forward-line (if prev -1 nil)))
A function scope variable to store the direction would save testing
`prev' every time around the loop.
Same question about the local variable as for the last patch.
> + (not last)))
> +
> (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)))
>
> @@ -590,8 +600,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.23.0
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
dme.
--
Oh by the way, which one's Pink?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
` (7 preceding siblings ...)
2019-11-28 16:14 ` [PATCH v2 8/8] emacs: bind M-RET to notmuch-tree-from-search-thread William Casarin
@ 2019-12-04 17:01 ` Teemu Likonen
2019-12-04 19:18 ` William Casarin
8 siblings, 1 reply; 15+ messages in thread
From: Teemu Likonen @ 2019-12-04 17:01 UTC (permalink / raw
To: William Casarin, notmuch
[-- Attachment #1: Type: text/plain, Size: 779 bytes --]
William Casarin [2019-11-28T08:13:53-08] wrote:
> These patches bring notmuch-tree more in line with the user experience
> of notmuch-show by adding the x/X bindings.
>
> v2:
> - fix a bug when moving between open messages
> - include M-RET keybinding patch from id:20191113225752.26502-1-jb55@jb55.com
A minor inconvenience: In "show" mode X key
(notmuch-show-archive-thread-then-exit) archives, exits and moves the
cursor above the next thread in the list. In "tree" mode this new X key
(notmuch-tree-archive-thread-then-exit) does not move the cursor to the
next thread.
--
/// OpenPGP key: 4E1055DC84E9DFF613D78557719D69D324539450
// https://keys.openpgp.org/search?q=tlikonen@iki.fi
/ https://keybase.io/tlikonen https://github.com/tlikonen
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 694 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread
2019-11-28 16:24 ` David Edmondson
@ 2019-12-04 19:14 ` William Casarin
0 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2019-12-04 19:14 UTC (permalink / raw
To: David Edmondson, notmuch
David Edmondson <dme@dme.org> writes:
> On Thursday, 2019-11-28 at 08:13:54 -08, William Casarin wrote:
>
>> 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>
>> ---
>> emacs/notmuch-tree.el | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
>> index c00315e8..4bc05160 100644
>> --- a/emacs/notmuch-tree.el
>> +++ b/emacs/notmuch-tree.el
>> @@ -620,10 +620,14 @@ 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)))
>> + (let (end)
>> + (while (not (or (notmuch-tree-get-prop :first) (setq end (eobp))))
>> + (forward-line 1))
>> + (not end)))
>
> Does using the variable add much value here? It makes the code look more
> strange and removing it would add the cost of just one more call to
> `eobp'.
agreed, will update this in the next version
>
>>
>> (defun notmuch-tree-thread-mapcar (function)
>> "Iterate through all messages in the current thread
>> --
>> 2.23.0
>>
>> _______________________________________________
>> notmuch mailing list
>> notmuch@notmuchmail.org
>> https://notmuchmail.org/mailman/listinfo/notmuch
>
> dme.
> --
> But uh oh, I love her because, she moves in her own way.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message
2019-11-28 16:25 ` David Edmondson
@ 2019-12-04 19:15 ` William Casarin
0 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2019-12-04 19:15 UTC (permalink / raw
To: David Edmondson, notmuch
David Edmondson <dme@dme.org> writes:
> On Thursday, 2019-11-28 at 08:13:55 -08, William Casarin wrote:
>
>> 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 | 17 +++++++++++++----
>> 1 file changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
>> index 4bc05160..9f2d87b5 100644
>> --- a/emacs/notmuch-tree.el
>> +++ b/emacs/notmuch-tree.el
>> @@ -577,12 +577,22 @@ 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 (last)
>> + (while (and (not (setq last (if prev (bobp) (eobp))))
>> + (not (notmuch-tree-get-match)))
>> + (forward-line (if prev -1 nil)))
>
> A function scope variable to store the direction would save testing
> `prev' every time around the loop.
>
> Same question about the local variable as for the last patch.
yup I believe this makes sense, I send out a new version in a bit.
>
>> + (not last)))
>> +
>> (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)))
>>
>> @@ -590,8 +600,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.23.0
>>
>> _______________________________________________
>> notmuch mailing list
>> notmuch@notmuchmail.org
>> https://notmuchmail.org/mailman/listinfo/notmuch
>
> dme.
> --
> Oh by the way, which one's Pink?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree
2019-12-04 17:01 ` [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree Teemu Likonen
@ 2019-12-04 19:18 ` William Casarin
0 siblings, 0 replies; 15+ messages in thread
From: William Casarin @ 2019-12-04 19:18 UTC (permalink / raw
To: Teemu Likonen, notmuch
Teemu Likonen <tlikonen@iki.fi> writes:
> William Casarin [2019-11-28T08:13:53-08] wrote:
>
>> These patches bring notmuch-tree more in line with the user experience
>> of notmuch-show by adding the x/X bindings.
>>
>> v2:
>> - fix a bug when moving between open messages
>> - include M-RET keybinding patch from id:20191113225752.26502-1-jb55@jb55.com
>
> A minor inconvenience: In "show" mode X key
> (notmuch-show-archive-thread-then-exit) archives, exits and moves the
> cursor above the next thread in the list. In "tree" mode this new X key
> (notmuch-tree-archive-thread-then-exit) does not move the cursor to the
> next thread.
I didn't even realize notmuch-show does this, I never noticed it before.
I'll see if there's a quick fix.
Another thing I noticed is that X won't work if it moves past the last
message. This is a minor inconvenience, perhaps I can make it so it
doesn't move down a line if there are no more messages.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2019-12-04 19:18 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-28 16:13 [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree William Casarin
2019-11-28 16:13 ` [PATCH v2 1/8] emacs/tree: return true if a thread was found in next-thread William Casarin
2019-11-28 16:24 ` David Edmondson
2019-12-04 19:14 ` William Casarin
2019-11-28 16:13 ` [PATCH v2 2/8] emacs/tree: add notmuch-tree-goto-matching-message William Casarin
2019-11-28 16:25 ` David Edmondson
2019-12-04 19:15 ` William Casarin
2019-11-28 16:13 ` [PATCH v2 3/8] emacs/tree: add notmuch-tree-matching-message William Casarin
2019-11-28 16:13 ` [PATCH v2 4/8] emacs/tree: add kill-both prefix argument to notmuch-tree-quit William Casarin
2019-11-28 16:13 ` [PATCH v2 5/8] emacs/tree: add notmuch-tree-archive-message-than-next-or-exit William Casarin
2019-11-28 16:13 ` [PATCH v2 6/8] emacs/tree: add notmuch-tree-archive-thread-then-exit William Casarin
2019-11-28 16:14 ` [PATCH v2 7/8] emacs/tree: add x/X bindings William Casarin
2019-11-28 16:14 ` [PATCH v2 8/8] emacs: bind M-RET to notmuch-tree-from-search-thread William Casarin
2019-12-04 17:01 ` [PATCH v2 0/8] Port notmuch-show's x/X bindings to notmuch-tree Teemu Likonen
2019-12-04 19:18 ` 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).