aboutsummaryrefslogtreecommitdiffhomepage
path: root/contrib
diff options
context:
space:
mode:
authorGravatar Mark Walters <markwalters1009@gmail.com>2013-08-25 20:55:32 +0100
committerGravatar David Bremner <bremner@debian.org>2013-09-03 06:10:25 -0300
commitf8a8afe5c2760aeec428de9f8d742b4b582c5fef (patch)
treecec2c77d64c9539e4181a1e23d2aeed2908f86f1 /contrib
parentdb465e443f3cd5ef3ba52304ab8b5dc6e0d7e620 (diff)
contrib: pick: add thread based utility functions
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.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/notmuch-pick/notmuch-pick.el24
1 files changed, 24 insertions, 0 deletions
diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el
index 8c499b07..4d32cf06 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -594,6 +594,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
@@ -702,6 +725,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)