[PATCH v2 4/6] emacs: add support for custom tag changes on message/thread archive
authorJani Nikula <jani@nikula.org>
Thu, 6 Sep 2012 15:32:40 +0000 (18:32 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:25 +0000 (09:49 -0800)
4a/a02d997c314bc76834151d7897f384854a5a74 [new file with mode: 0644]

diff --git a/4a/a02d997c314bc76834151d7897f384854a5a74 b/4a/a02d997c314bc76834151d7897f384854a5a74
new file mode 100644 (file)
index 0000000..a2546af
--- /dev/null
@@ -0,0 +1,189 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id B511A431FAE\r
+       for <notmuch@notmuchmail.org>; Thu,  6 Sep 2012 08:33:00 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 8TByU1CfzxsP for <notmuch@notmuchmail.org>;\r
+       Thu,  6 Sep 2012 08:32:59 -0700 (PDT)\r
+Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com\r
+       [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 4F814431FDA\r
+       for <notmuch@notmuchmail.org>; Thu,  6 Sep 2012 08:32:59 -0700 (PDT)\r
+Received: by mail-lb0-f181.google.com with SMTP id gk1so1344042lbb.26\r
+       for <notmuch@notmuchmail.org>; Thu, 06 Sep 2012 08:32:58 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
+       :in-reply-to:references:x-gm-message-state;\r
+       bh=KvsPlCuF3X1Mzei7UwbBUt4hBv7Iv6yroufjbejmM9Q=;\r
+       b=gP807FpEBBI+R4pOxLEsDD0R7b/Xh9WEnoWY8nxGrQfrnxrEGh4L9ztS7LG7byaQ+s\r
+       kxKtCgNYocFV5GMnLUCFdFdaf6G045djKVIM1EgYZuuvEOdY/r4XhTFTL7PIw6GkeaLL\r
+       esIcIOI6svgVk1WYYnTAvAHD/G17niuLdcP8bc565Otjoj5UArISGYGLUvIe32wyBWNe\r
+       4vQxy8LG5vVNVJvVfRCOVoDpzvW3LTWzHteB265HZjSM5xTM1J3ClZi57B77ggQTGESx\r
+       Ah9kk9mUz3G20WvI+cYDLVH5kP4NtINxRSI/7s+A4YQz3O/q4p2eLgTerNLF7Wq+oBUw\r
+       d3kQ==\r
+Received: by 10.152.135.147 with SMTP id ps19mr2317442lab.52.1346945578883;\r
+       Thu, 06 Sep 2012 08:32:58 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.\r
+       [80.223.81.27])\r
+       by mx.google.com with ESMTPS id o7sm678046lbg.4.2012.09.06.08.32.56\r
+       (version=SSLv3 cipher=OTHER); Thu, 06 Sep 2012 08:32:57 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 4/6] emacs: add support for custom tag changes on\r
+       message/thread archive\r
+Date: Thu,  6 Sep 2012 18:32:40 +0300\r
+Message-Id:\r
+ <6158e4e4866e1ba5d77a09e30b1540098a0cd000.1346945257.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.9.5\r
+In-Reply-To: <cover.1346945257.git.jani@nikula.org>\r
+References: <cover.1346945257.git.jani@nikula.org>\r
+In-Reply-To: <cover.1346945257.git.jani@nikula.org>\r
+References: <cover.1346945257.git.jani@nikula.org>\r
+X-Gm-Message-State:\r
+ ALoCoQlVzOXnlwb3GUkmEOpWVfdxYLjDYJsQVYftSRsienmGQZWHpr0OgFZK/VLxN90sMnm1qiam\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 06 Sep 2012 15:33:01 -0000\r
+\r
+Add support for customization of the tag changes that are applied when\r
+a message or a thread is archived. Instead of hard-coded removal of\r
+the "inbox" tag, the user can now specify a list of tag changes to\r
+perform.\r
+---\r
+ emacs/notmuch-lib.el  |   14 ++++++++++++++\r
+ emacs/notmuch-show.el |   29 +++++++++++++++++------------\r
+ emacs/notmuch.el      |   12 ++++++++++--\r
+ 3 files changed, 41 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 900235b..20d990d 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -82,6 +82,20 @@\r
+   :type '(alist :key-type string :value-type string)\r
+   :group 'notmuch-hello)\r
\r
++(defcustom notmuch-archive-tags '("-inbox")\r
++  "List of tag changes to apply to a message or a thread when it is archived.\r
++\r
++Tags starting with \"+\" (or not starting with either \"+\" or\r
++\"-\") in the list will be added, and tags starting with \"-\"\r
++will be removed from the message or thread being archived.\r
++\r
++For example, if you wanted to remove an \"inbox\" tag and add an\r
++\"archived\" tag, you would set:\r
++    (\"-inbox\" \"+archived\")"\r
++  :type '(repeat string)\r
++  :group 'notmuch-search\r
++  :group 'notmuch-show)\r
++\r
+ (defvar notmuch-folders nil\r
+   "Deprecated name for what is now known as `notmuch-saved-searches'.")\r
\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index ce5ea6f..e701aec 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1748,18 +1748,20 @@ argument, hide all of the messages."\r
+ (defun notmuch-show-archive-thread (&optional unarchive)\r
+   "Archive each message in thread.\r
\r
+-Archive each message currently shown by removing the \"inbox\"\r
+-tag from each.  If a prefix argument is given, the messages will\r
+-be \"unarchived\" (ie. the \"inbox\" tag will be added instead of\r
+-removed).\r
++Archive each message currently shown by applying the tag changes\r
++in `notmuch-archive-tags' to each (remove the \"inbox\" tag by\r
++default). If a prefix argument is given, the messages will be\r
++\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'\r
++will be reversed.\r
\r
+ Note: This command is safe from any race condition of new messages\r
+ being delivered to the same thread. It does not archive the\r
+ entire thread, but only the messages shown in the current\r
+ buffer."\r
+   (interactive "P")\r
+-  (let ((op (if unarchive "+" "-")))\r
+-    (notmuch-show-tag-all (concat op "inbox"))))\r
++  (when notmuch-archive-tags\r
++    (notmuch-show-tag-all\r
++     (notmuch-tag-change-list notmuch-archive-tags unarchive))))\r
\r
+ (defun notmuch-show-archive-thread-then-next ()\r
+   "Archive all messages in the current buffer, then show next thread from search."\r
+@@ -1774,14 +1776,17 @@ buffer."\r
+   (notmuch-show-next-thread))\r
\r
+ (defun notmuch-show-archive-message (&optional unarchive)\r
+-  "Archive the current message (remove \"inbox\" tag).\r
++  "Archive the current message.\r
\r
+-If a prefix argument is given, the message will be\r
+-\"unarchived\" (ie. the \"inbox\" tag will be added instead of\r
+-removed)."\r
++Archive the current message by applying the tag changes in\r
++`notmuch-archive-tags' to it (remove the \"inbox\" tag by\r
++default). If a prefix argument is given, the message will be\r
++\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'\r
++will be reversed."\r
+   (interactive "P")\r
+-  (let ((op (if unarchive "+" "-")))\r
+-    (notmuch-show-tag-message (concat op "inbox"))))\r
++  (when notmuch-archive-tags\r
++    (apply 'notmuch-show-tag-message\r
++         (notmuch-tag-change-list notmuch-archive-tags unarchive))))\r
\r
+ (defun notmuch-show-archive-message-then-next-or-exit ()\r
+   "Archive the current message, then show the next open message in the current thread.\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 1c43d3e..64caa3e 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -594,11 +594,19 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."\r
+   (notmuch-search-tag "-"))\r
\r
+ (defun notmuch-search-archive-thread ()\r
+-  "Archive the currently selected thread (remove its \"inbox\" tag).\r
++  "Archive the currently selected thread.\r
++\r
++Archive each message in the currently selected thread by applying\r
++the tag changes in `notmuch-archive-tags' to each (remove the\r
++\"inbox\" tag by default). If a prefix argument is given, the\r
++messages will be \"unarchived\" (i.e. the tag changes in\r
++`notmuch-archive-tags' will be reversed).\r
\r
+ This function advances the next thread when finished."\r
+   (interactive)\r
+-  (notmuch-search-tag '("-inbox"))\r
++  (when notmuch-archive-tags\r
++    (notmuch-search-tag\r
++     (notmuch-tag-change-list notmuch-archive-tags)))\r
+   (notmuch-search-next-thread))\r
\r
+ (defun notmuch-search-update-result (result &optional pos)\r
+-- \r
+1.7.9.5\r
+\r