* [PATCH v3 0/2] Add some thread based actions to pick
@ 2013-06-14 7:37 Mark Walters
2013-06-14 7:37 ` [PATCH v3 1/2] contrib: pick: add thread based utility functions Mark Walters
2013-06-14 7:37 ` [PATCH v3 2/2] contrib: pick: thread tagging (including archiving) implemented Mark Walters
0 siblings, 2 replies; 3+ messages in thread
From: Mark Walters @ 2013-06-14 7:37 UTC (permalink / raw)
To: notmuch
Version 2 of this series
id:1371166618-27196-1-git-send-email-markwalters1009@gmail.com has an
error in my rebasing (I forgot to fold a bugfix in and had not
commited one part). Version 1 which had some review is at
id:1354970914-18342-1-git-send-email-markwalters1009@gmail.com
The changes from version 1: rebase on to current master, fix the macro
to be a function, change the mapc into the more natural mapcar which
removes the need for one auxillary function, removed the unnecessary
funcall, tweaked the docstring, changed a setq to a let.
Finally the rebase error (which was a bugfix from v1) is that we make
sure notmuch-pick-thread-top does not go into an infinite loop if
applied to an empty buffer.
Best wishes
Mark
Mark Walters (2):
contrib: pick: add thread based utility functions
contrib: pick: thread tagging (including archiving) implemented
contrib/notmuch-pick/notmuch-pick.el | 51 ++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
--
1.7.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 1/2] contrib: pick: add thread based utility functions
2013-06-14 7:37 [PATCH v3 0/2] Add some thread based actions to pick Mark Walters
@ 2013-06-14 7:37 ` Mark Walters
2013-06-14 7:37 ` [PATCH v3 2/2] contrib: pick: thread tagging (including archiving) implemented Mark Walters
1 sibling, 0 replies; 3+ messages in thread
From: Mark Walters @ 2013-06-14 7:37 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 10a2bf7..af117ba 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -583,6 +583,29 @@ than only the current message."
(message (format "Command '%s' exited abnormally with code %d"
shell-command exit-code)))))))
+(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
@@ -680,6 +703,7 @@ unchanged ADDRESS if parsing fails."
(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] 3+ messages in thread
* [PATCH v3 2/2] contrib: pick: thread tagging (including archiving) implemented
2013-06-14 7:37 [PATCH v3 0/2] Add some thread based actions to pick Mark Walters
2013-06-14 7:37 ` [PATCH v3 1/2] contrib: pick: add thread based utility functions Mark Walters
@ 2013-06-14 7:37 ` Mark Walters
1 sibling, 0 replies; 3+ messages in thread
From: Mark Walters @ 2013-06-14 7:37 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 af117ba..eeb86d9 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -179,6 +179,7 @@
(define-key map "q" 'notmuch-pick-quit)
(define-key map "x" 'notmuch-pick-quit)
(define-key map "?" 'notmuch-help)
+ (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)
@@ -194,6 +195,7 @@
(define-key map "|" 'notmuch-pick-pipe-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))
@@ -604,6 +606,31 @@ than only the current message."
(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] 3+ messages in thread
end of thread, other threads:[~2013-06-14 7:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-14 7:37 [PATCH v3 0/2] Add some thread based actions to pick Mark Walters
2013-06-14 7:37 ` [PATCH v3 1/2] contrib: pick: add thread based utility functions Mark Walters
2013-06-14 7:37 ` [PATCH v3 2/2] contrib: pick: thread tagging (including archiving) implemented Mark Walters
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).