emacs: add support for custom tag changes on message/thread archive

Add support for customization of the tag changes that are applied when
a message or a thread is archived. Instead of hard-coded removal of
the "inbox" tag, the user can now specify a list of tag changes to
perform.
This commit is contained in:
Jani Nikula 2012-09-06 18:32:40 +03:00 committed by David Bremner
parent 2590d94bf0
commit d5dcfc714e
3 changed files with 41 additions and 14 deletions

View file

@ -82,6 +82,20 @@
:type '(alist :key-type string :value-type string) :type '(alist :key-type string :value-type string)
:group 'notmuch-hello) :group 'notmuch-hello)
(defcustom notmuch-archive-tags '("-inbox")
"List of tag changes to apply to a message or a thread when it is archived.
Tags starting with \"+\" (or not starting with either \"+\" or
\"-\") in the list will be added, and tags starting with \"-\"
will be removed from the message or thread being archived.
For example, if you wanted to remove an \"inbox\" tag and add an
\"archived\" tag, you would set:
(\"-inbox\" \"+archived\")"
:type '(repeat string)
:group 'notmuch-search
:group 'notmuch-show)
(defvar notmuch-folders nil (defvar notmuch-folders nil
"Deprecated name for what is now known as `notmuch-saved-searches'.") "Deprecated name for what is now known as `notmuch-saved-searches'.")

View file

@ -1748,18 +1748,20 @@ argument, hide all of the messages."
(defun notmuch-show-archive-thread (&optional unarchive) (defun notmuch-show-archive-thread (&optional unarchive)
"Archive each message in thread. "Archive each message in thread.
Archive each message currently shown by removing the \"inbox\" Archive each message currently shown by applying the tag changes
tag from each. If a prefix argument is given, the messages will in `notmuch-archive-tags' to each (remove the \"inbox\" tag by
be \"unarchived\" (ie. the \"inbox\" tag will be added instead of default). If a prefix argument is given, the messages will be
removed). \"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 Note: This command is safe from any race condition of new messages
being delivered to the same thread. It does not archive the 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 "P") (interactive "P")
(let ((op (if unarchive "+" "-"))) (when notmuch-archive-tags
(notmuch-show-tag-all (concat op "inbox")))) (notmuch-show-tag-all
(notmuch-tag-change-list notmuch-archive-tags unarchive))))
(defun notmuch-show-archive-thread-then-next () (defun notmuch-show-archive-thread-then-next ()
"Archive all messages in the current buffer, then show next thread from search." "Archive all messages in the current buffer, then show next thread from search."
@ -1774,14 +1776,17 @@ buffer."
(notmuch-show-next-thread)) (notmuch-show-next-thread))
(defun notmuch-show-archive-message (&optional unarchive) (defun notmuch-show-archive-message (&optional unarchive)
"Archive the current message (remove \"inbox\" tag). "Archive the current message.
If a prefix argument is given, the message will be Archive the current message by applying the tag changes in
\"unarchived\" (ie. the \"inbox\" tag will be added instead of `notmuch-archive-tags' to it (remove the \"inbox\" tag by
removed)." default). If a prefix argument is given, the message will be
\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
will be reversed."
(interactive "P") (interactive "P")
(let ((op (if unarchive "+" "-"))) (when notmuch-archive-tags
(notmuch-show-tag-message (concat op "inbox")))) (apply 'notmuch-show-tag-message
(notmuch-tag-change-list notmuch-archive-tags unarchive))))
(defun notmuch-show-archive-message-then-next-or-exit () (defun notmuch-show-archive-message-then-next-or-exit ()
"Archive the current message, then show the next open message in the current thread. "Archive the current message, then show the next open message in the current thread.

View file

@ -594,11 +594,19 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."
(notmuch-search-tag "-")) (notmuch-search-tag "-"))
(defun notmuch-search-archive-thread () (defun notmuch-search-archive-thread ()
"Archive the currently selected thread (remove its \"inbox\" tag). "Archive the currently selected thread.
Archive each message in the currently selected thread by applying
the tag changes in `notmuch-archive-tags' to each (remove the
\"inbox\" tag by default). If a prefix argument is given, the
messages will be \"unarchived\" (i.e. the tag changes in
`notmuch-archive-tags' will be reversed).
This function advances the next thread when finished." This function advances the next thread when finished."
(interactive) (interactive)
(notmuch-search-tag '("-inbox")) (when notmuch-archive-tags
(notmuch-search-tag
(notmuch-tag-change-list notmuch-archive-tags)))
(notmuch-search-next-thread)) (notmuch-search-next-thread))
(defun notmuch-search-update-result (result &optional pos) (defun notmuch-search-update-result (result &optional pos)