unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [Patch v4 0/3] Add some thread based actions to pick
@ 2013-08-25 19:55 Mark Walters
  2013-08-25 19:55 ` [Patch v4 1/3] contrib: pick: add thread based utility functions Mark Walters
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Mark Walters @ 2013-08-25 19:55 UTC (permalink / raw)
  To: notmuch

This is a rebased version of id:1371195472-441-1-git-send-email-markwalters1009@gmail.com

The only other change is a new patch 3 adding previous/next thread
commands: they are both very simple functions based on the first two
patches.

Best wishes

Mark


Mark Walters (3):
  contrib: pick: add thread based utility functions
  contrib: pick: thread tagging (including archiving) implemented
  contrib: pick: bind M-p and M-n to prev/next thread

 contrib/notmuch-pick/notmuch-pick.el |   64 ++++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)

-- 
1.7.9.1

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

* [Patch v4 1/3] contrib: pick: add thread based utility functions
  2013-08-25 19:55 [Patch v4 0/3] Add some thread based actions to pick Mark Walters
@ 2013-08-25 19:55 ` Mark Walters
  2013-08-25 19:55 ` [Patch v4 2/3] contrib: pick: thread tagging (including archiving) implemented Mark Walters
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Mark Walters @ 2013-08-25 19:55 UTC (permalink / raw)
  To: notmuch

Previously notmuch-pick had no thread based functionality. This adds a
macro to iterate through all messages in a thread. To simplify this it
adds a text-property marker to the first message of each thread.
---
 contrib/notmuch-pick/notmuch-pick.el |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el
index 37dc161..fea118f 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -599,6 +599,29 @@ message will be \"unarchived\", i.e. the tag changes in
 			 target
 			 (get-buffer buffer-name))))
 
+(defun notmuch-pick-thread-top ()
+  (when (notmuch-pick-get-message-properties)
+    (while (not (or (notmuch-pick-get-prop :first) (eobp)))
+      (forward-line -1))))
+
+(defun notmuch-pick-thread-mapcar (function)
+  "Iterate through all messages in the current thread
+ and call FUNCTION for side effects."
+  (save-excursion
+    (notmuch-pick-thread-top)
+    (loop collect (funcall function)
+	  do (forward-line)
+	  while (and (notmuch-pick-get-message-properties)
+		     (not (notmuch-pick-get-prop :first))))))
+
+(defun notmuch-pick-get-messages-ids-thread-search ()
+  "Return a search string for all message ids of messages in the current thread."
+  (mapconcat 'identity
+	     (notmuch-pick-thread-mapcar 'notmuch-pick-get-message-id)
+	     " or "))
+
+;; Functions below here display the pick buffer itself.
+
 (defun notmuch-pick-clean-address (address)
   "Try to clean a single email ADDRESS for display. Return
 AUTHOR_NAME if present, otherwise return AUTHOR_EMAIL. Return
@@ -707,6 +730,7 @@ message together with all its descendents."
 	(push "├" tree-status)))
 
       (push (concat (if replies "┬" "─") "►") tree-status)
+      (plist-put msg :first (and first (eq 0 depth)))
       (notmuch-pick-goto-and-insert-msg (plist-put msg :tree-status tree-status))
       (pop tree-status)
       (pop tree-status)
-- 
1.7.9.1

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

* [Patch v4 2/3] contrib: pick: thread tagging (including archiving) implemented
  2013-08-25 19:55 [Patch v4 0/3] Add some thread based actions to pick Mark Walters
  2013-08-25 19:55 ` [Patch v4 1/3] contrib: pick: add thread based utility functions Mark Walters
@ 2013-08-25 19:55 ` Mark Walters
  2013-08-25 19:55 ` [Patch v4 3/3] contrib: pick: bind M-p and M-n to prev/next thread Mark Walters
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Mark Walters @ 2013-08-25 19:55 UTC (permalink / raw)
  To: notmuch

Previously pick had no actions based on the entire thread: this adds
some. Note in this version '*' is bound to `tag thread' which is not
consistent with search or show. However it still might be the most
natural thing (as it is similar to running * in the show pane).
---
 contrib/notmuch-pick/notmuch-pick.el |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el
index fea118f..258cfc3 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -246,6 +246,7 @@ FUNC."
     ;; The main pick bindings
     (define-key map "q" 'notmuch-pick-quit)
     (define-key map "x" 'notmuch-pick-quit)
+    (define-key map "A" 'notmuch-pick-archive-thread)
     (define-key map "a" 'notmuch-pick-archive-message-then-next)
     (define-key map "=" 'notmuch-pick-refresh-view)
     (define-key map "s" 'notmuch-pick-to-search)
@@ -256,6 +257,7 @@ FUNC."
     (define-key map "P" 'notmuch-pick-prev-message)
     (define-key map "-" 'notmuch-pick-remove-tag)
     (define-key map "+" 'notmuch-pick-add-tag)
+    (define-key map "*" 'notmuch-pick-tag-thread)
     (define-key map " " 'notmuch-pick-scroll-or-next)
     (define-key map "b" 'notmuch-pick-scroll-message-window-back)
     map))
@@ -620,6 +622,31 @@ message will be \"unarchived\", i.e. the tag changes in
 	     (notmuch-pick-thread-mapcar 'notmuch-pick-get-message-id)
 	     " or "))
 
+(defun notmuch-pick-tag-thread (&optional tag-changes)
+  "Tag all messages in the current thread"
+  (interactive)
+  (when (notmuch-pick-get-message-properties)
+    (let ((tag-changes (notmuch-tag (notmuch-pick-get-messages-ids-thread-search) tag-changes)))
+      (notmuch-pick-thread-mapcar
+       (lambda () (notmuch-pick-tag-update-display tag-changes))))))
+
+(defun notmuch-pick-archive-thread (&optional unarchive)
+  "Archive each message in thread.
+
+Archive each message currently shown by applying the tag changes
+in `notmuch-archive-tags' to each. If a prefix argument is given,
+the messages will be \"unarchived\", i.e. the tag changes in
+`notmuch-archive-tags' will be reversed.
+
+Note: This command is safe from any race condition of new messages
+being delivered to the same thread. It does not archive the
+entire thread, but only the messages shown in the current
+buffer."
+  (interactive "P")
+  (when notmuch-archive-tags
+    (notmuch-pick-tag-thread
+     (notmuch-tag-change-list notmuch-archive-tags unarchive))))
+
 ;; Functions below here display the pick buffer itself.
 
 (defun notmuch-pick-clean-address (address)
-- 
1.7.9.1

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

* [Patch v4 3/3] contrib: pick: bind M-p and M-n to prev/next thread
  2013-08-25 19:55 [Patch v4 0/3] Add some thread based actions to pick Mark Walters
  2013-08-25 19:55 ` [Patch v4 1/3] contrib: pick: add thread based utility functions Mark Walters
  2013-08-25 19:55 ` [Patch v4 2/3] contrib: pick: thread tagging (including archiving) implemented Mark Walters
@ 2013-08-25 19:55 ` Mark Walters
  2013-09-02  1:21 ` [Patch v4 0/3] Add some thread based actions to pick David Bremner
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Mark Walters @ 2013-08-25 19:55 UTC (permalink / raw)
  To: notmuch

This adds functions to go to the previous or next thread to
pick. Prev-thread behaves similarly to prev-message in show: if you
are on the top line of a thread it will go to the top of the previous
thread, otherwise it will go to the top of the current thread. Next
thread will always go to the top of the next thread (or the end of
buffer). These are bound to "M-p" and "M-n" by default (matching the
bindings in show).
---
 contrib/notmuch-pick/notmuch-pick.el |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el
index 258cfc3..84d27b3 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -255,6 +255,8 @@ FUNC."
     (define-key map "p" 'notmuch-pick-prev-matching-message)
     (define-key map "N" 'notmuch-pick-next-message)
     (define-key map "P" 'notmuch-pick-prev-message)
+    (define-key map (kbd "M-p") 'notmuch-pick-prev-thread)
+    (define-key map (kbd "M-n") 'notmuch-pick-next-thread)
     (define-key map "-" 'notmuch-pick-remove-tag)
     (define-key map "+" 'notmuch-pick-add-tag)
     (define-key map "*" 'notmuch-pick-tag-thread)
@@ -606,6 +608,17 @@ message will be \"unarchived\", i.e. the tag changes in
     (while (not (or (notmuch-pick-get-prop :first) (eobp)))
       (forward-line -1))))
 
+(defun notmuch-pick-prev-thread ()
+  (interactive)
+  (forward-line -1)
+  (notmuch-pick-thread-top))
+
+(defun notmuch-pick-next-thread ()
+  (interactive)
+  (forward-line 1)
+  (while (not (or (notmuch-pick-get-prop :first) (eobp)))
+    (forward-line 1)))
+
 (defun notmuch-pick-thread-mapcar (function)
   "Iterate through all messages in the current thread
  and call FUNCTION for side effects."
-- 
1.7.9.1

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

* Re: [Patch v4 0/3] Add some thread based actions to pick
  2013-08-25 19:55 [Patch v4 0/3] Add some thread based actions to pick Mark Walters
                   ` (2 preceding siblings ...)
  2013-08-25 19:55 ` [Patch v4 3/3] contrib: pick: bind M-p and M-n to prev/next thread Mark Walters
@ 2013-09-02  1:21 ` David Bremner
  2013-09-02 15:47 ` Tomi Ollila
  2013-09-03  9:20 ` David Bremner
  5 siblings, 0 replies; 7+ messages in thread
From: David Bremner @ 2013-09-02  1:21 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> This is a rebased version of id:1371195472-441-1-git-send-email-markwalters1009@gmail.com
>
> The only other change is a new patch 3 adding previous/next thread
> commands: they are both very simple functions based on the first two
> patches.
>

These look OK to me. I am a bit skeptical about the binding '*' here. I
guess at least it will not cause more havoc than people are expecting.

d

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

* Re: [Patch v4 0/3] Add some thread based actions to pick
  2013-08-25 19:55 [Patch v4 0/3] Add some thread based actions to pick Mark Walters
                   ` (3 preceding siblings ...)
  2013-09-02  1:21 ` [Patch v4 0/3] Add some thread based actions to pick David Bremner
@ 2013-09-02 15:47 ` Tomi Ollila
  2013-09-03  9:20 ` David Bremner
  5 siblings, 0 replies; 7+ messages in thread
From: Tomi Ollila @ 2013-09-02 15:47 UTC (permalink / raw)
  To: Mark Walters, notmuch

On Sun, Aug 25 2013, Mark Walters <markwalters1009@gmail.com> wrote:

> This is a rebased version of id:1371195472-441-1-git-send-email-markwalters1009@gmail.com
>
> The only other change is a new patch 3 adding previous/next thread
> commands: they are both very simple functions based on the first two
> patches.
>
> Best wishes

LGTM. The '*' binding is good -- the functionality is in line
with notmuch-show-tag-all...

> Mark

Tomi


>
>
> Mark Walters (3):
>   contrib: pick: add thread based utility functions
>   contrib: pick: thread tagging (including archiving) implemented
>   contrib: pick: bind M-p and M-n to prev/next thread
>
>  contrib/notmuch-pick/notmuch-pick.el |   64 ++++++++++++++++++++++++++++++++++
>  1 files changed, 64 insertions(+), 0 deletions(-)
>
> -- 
> 1.7.9.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
>

-- 
uussigu

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

* Re: [Patch v4 0/3] Add some thread based actions to pick
  2013-08-25 19:55 [Patch v4 0/3] Add some thread based actions to pick Mark Walters
                   ` (4 preceding siblings ...)
  2013-09-02 15:47 ` Tomi Ollila
@ 2013-09-03  9:20 ` David Bremner
  5 siblings, 0 replies; 7+ messages in thread
From: David Bremner @ 2013-09-03  9:20 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> This is a rebased version of id:1371195472-441-1-git-send-email-markwalters1009@gmail.com
>
> The only other change is a new patch 3 adding previous/next thread
> commands: they are both very simple functions based on the first two
> patches.
>

I pushed this. Does it need some new tests for the new functionality?

d

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

end of thread, other threads:[~2013-09-03  9:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-25 19:55 [Patch v4 0/3] Add some thread based actions to pick Mark Walters
2013-08-25 19:55 ` [Patch v4 1/3] contrib: pick: add thread based utility functions Mark Walters
2013-08-25 19:55 ` [Patch v4 2/3] contrib: pick: thread tagging (including archiving) implemented Mark Walters
2013-08-25 19:55 ` [Patch v4 3/3] contrib: pick: bind M-p and M-n to prev/next thread Mark Walters
2013-09-02  1:21 ` [Patch v4 0/3] Add some thread based actions to pick David Bremner
2013-09-02 15:47 ` Tomi Ollila
2013-09-03  9:20 ` David Bremner

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