unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive
Date: Sun,  2 Sep 2012 22:58:03 +0300	[thread overview]
Message-ID: <0907a84d74600df18b8663c28c26f9f7bc2f31c2.1346614915.git.jani@nikula.org> (raw)
In-Reply-To: <cover.1346614915.git.jani@nikula.org>
In-Reply-To: <cover.1346614915.git.jani@nikula.org>

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.
---
 emacs/notmuch-lib.el  |   14 ++++++++++++++
 emacs/notmuch-show.el |   29 +++++++++++++++++------------
 emacs/notmuch.el      |   12 ++++++++++--
 3 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 900235b..20d990d 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -82,6 +82,20 @@
   :type '(alist :key-type string :value-type string)
   :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
   "Deprecated name for what is now known as `notmuch-saved-searches'.")
 
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ce5ea6f..e701aec 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1748,18 +1748,20 @@ argument, hide all of the messages."
 (defun notmuch-show-archive-thread (&optional unarchive)
   "Archive each message in thread.
 
-Archive each message currently shown by removing the \"inbox\"
-tag from each.  If a prefix argument is given, the messages will
-be \"unarchived\" (ie. the \"inbox\" tag will be added instead of
-removed).
+Archive each message currently shown 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.
 
 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")
-  (let ((op (if unarchive "+" "-")))
-    (notmuch-show-tag-all (concat op "inbox"))))
+  (when notmuch-archive-tags
+    (notmuch-show-tag-all
+     (notmuch-tag-change-list notmuch-archive-tags unarchive))))
 
 (defun notmuch-show-archive-thread-then-next ()
   "Archive all messages in the current buffer, then show next thread from search."
@@ -1774,14 +1776,17 @@ buffer."
   (notmuch-show-next-thread))
 
 (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
-\"unarchived\" (ie. the \"inbox\" tag will be added instead of
-removed)."
+Archive the current message by applying the tag changes in
+`notmuch-archive-tags' to it (remove the \"inbox\" tag by
+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")
-  (let ((op (if unarchive "+" "-")))
-    (notmuch-show-tag-message (concat op "inbox"))))
+  (when notmuch-archive-tags
+    (apply 'notmuch-show-tag-message
+	   (notmuch-tag-change-list notmuch-archive-tags unarchive))))
 
 (defun notmuch-show-archive-message-then-next-or-exit ()
   "Archive the current message, then show the next open message in the current thread.
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 1c43d3e..64caa3e 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -594,11 +594,19 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."
   (notmuch-search-tag "-"))
 
 (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."
   (interactive)
-  (notmuch-search-tag '("-inbox"))
+  (when notmuch-archive-tags
+    (notmuch-search-tag
+     (notmuch-tag-change-list notmuch-archive-tags)))
   (notmuch-search-next-thread))
 
 (defun notmuch-search-update-result (result &optional pos)
-- 
1.7.9.5

  parent reply	other threads:[~2012-09-02 19:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-02 19:57 [PATCH 0/6] emacs: customization for tag changes on archive Jani Nikula
2012-09-02 19:58 ` [PATCH 1/6] emacs: add helper for tag change list manipulation Jani Nikula
2012-09-03 11:33   ` Michal Nazarewicz
2012-09-03 12:06     ` Jani Nikula
2012-09-06 14:30       ` Tomi Ollila
2012-09-06 15:35         ` Jani Nikula
2012-09-02 19:58 ` [PATCH 2/6] emacs: fix notmuch-message-replied-tags defcustom type Jani Nikula
2012-09-02 19:58 ` [PATCH 3/6] emacs: use new tag change helper to mark messages as replied Jani Nikula
2012-09-02 19:58 ` Jani Nikula [this message]
2012-09-03 11:39   ` [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive Michal Nazarewicz
2012-09-03 12:08     ` Jani Nikula
2012-09-03 13:31       ` Michal Nazarewicz
2012-09-02 19:58 ` [PATCH 5/6] emacs: add support for reversing notmuch-search-archive-thread tag changes Jani Nikula
2012-09-02 19:58 ` [PATCH 6/6] emacs: add support for reversing notmuch-show-mark-read " Jani Nikula
2012-09-03 11:41 ` [PATCH 0/6] emacs: customization for tag changes on archive Michal Nazarewicz
2012-09-04  7:02 ` Mark Walters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0907a84d74600df18b8663c28c26f9f7bc2f31c2.1346614915.git.jani@nikula.org \
    --to=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).