emacs: break up notmuch-show-archive-thread-internal into two more generally useful functions

Break up notmuch-show-archive-thread-internal into two new functions:

notmuch-show-tag-thread-internal: applies a tag to all messages in
thread.  If option remove flag is t, tags will be removed instead of
added.

notmuch-show-next-thread: moves to the next thread in the search
result.  If given a prefix, will show the next result, otherwise will
just move to it in the search view.

Two new interactive functions, notmuch-show-{add,remove}-tag-thread,
are also added.  Together, these provide a better suit of thread
tagging and navigation tools.

The higher level thread archiving functions are modified to use these
new function.
This commit is contained in:
Jameson Graef Rollins 2012-01-24 16:06:17 -08:00 committed by David Bremner
parent 9b7e0dcb9a
commit 047792102c

View file

@ -1557,20 +1557,38 @@ argument, hide all of the messages."
(interactive) (interactive)
(backward-button 1)) (backward-button 1))
(defun notmuch-show-archive-thread-internal (show-next) (defun notmuch-show-tag-thread-internal (tag &optional remove)
;; Remove the tag from the current set of messages. "Add tag to the current set of messages.
If the remove switch is given, tags will be removed instead of
added."
(goto-char (point-min)) (goto-char (point-min))
(loop do (notmuch-show-remove-tag "inbox") (let ((tag-function (if remove
until (not (notmuch-show-goto-message-next))) 'notmuch-show-remove-tag
;; Move to the next item in the search results, if any. 'notmuch-show-add-tag)))
(loop do (funcall tag-function tag)
until (not (notmuch-show-goto-message-next)))))
(defun notmuch-show-add-tag-thread (tag)
"Add tag to all messages in the current thread."
(interactive)
(notmuch-show-tag-thread-internal tag))
(defun notmuch-show-remove-tag-thread (tag)
"Remove tag from all messages in the current thread."
(interactive)
(notmuch-show-tag-thread-internal tag t))
(defun notmuch-show-next-thread (&optional show-next)
"Move to the next item in the search results, if any."
(interactive "P")
(let ((parent-buffer notmuch-show-parent-buffer)) (let ((parent-buffer notmuch-show-parent-buffer))
(notmuch-kill-this-buffer) (notmuch-kill-this-buffer)
(if parent-buffer (when parent-buffer
(progn
(switch-to-buffer parent-buffer) (switch-to-buffer parent-buffer)
(notmuch-search-next-thread) (notmuch-search-next-thread)
(if show-next (if show-next
(notmuch-search-show-thread)))))) (notmuch-search-show-thread)))))
(defun notmuch-show-archive-thread () (defun notmuch-show-archive-thread ()
"Archive each message in thread, then show next thread from search. "Archive each message in thread, then show next thread from search.
@ -1584,12 +1602,14 @@ being delivered to the same thread. It does not archive the
entire thread, but only the messages shown in the current entire thread, but only the messages shown in the current
buffer." buffer."
(interactive) (interactive)
(notmuch-show-archive-thread-internal t)) (notmuch-show-remove-tag-thread "inbox")
(notmuch-show-next-thread t))
(defun notmuch-show-archive-thread-then-exit () (defun notmuch-show-archive-thread-then-exit ()
"Archive each message in thread, then exit back to search results." "Archive each message in thread, then exit back to search results."
(interactive) (interactive)
(notmuch-show-archive-thread-internal nil)) (notmuch-show-remove-tag-thread "inbox")
(notmuch-show-next-thread))
(defun notmuch-show-stash-cc () (defun notmuch-show-stash-cc ()
"Copy CC field of current message to kill-ring." "Copy CC field of current message to kill-ring."