Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B511A431FAE for ; Thu, 6 Sep 2012 08:33:00 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8TByU1CfzxsP for ; Thu, 6 Sep 2012 08:32:59 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 4F814431FDA for ; Thu, 6 Sep 2012 08:32:59 -0700 (PDT) Received: by mail-lb0-f181.google.com with SMTP id gk1so1344042lbb.26 for ; Thu, 06 Sep 2012 08:32:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references:x-gm-message-state; bh=KvsPlCuF3X1Mzei7UwbBUt4hBv7Iv6yroufjbejmM9Q=; b=gP807FpEBBI+R4pOxLEsDD0R7b/Xh9WEnoWY8nxGrQfrnxrEGh4L9ztS7LG7byaQ+s kxKtCgNYocFV5GMnLUCFdFdaf6G045djKVIM1EgYZuuvEOdY/r4XhTFTL7PIw6GkeaLL esIcIOI6svgVk1WYYnTAvAHD/G17niuLdcP8bc565Otjoj5UArISGYGLUvIe32wyBWNe 4vQxy8LG5vVNVJvVfRCOVoDpzvW3LTWzHteB265HZjSM5xTM1J3ClZi57B77ggQTGESx Ah9kk9mUz3G20WvI+cYDLVH5kP4NtINxRSI/7s+A4YQz3O/q4p2eLgTerNLF7Wq+oBUw d3kQ== Received: by 10.152.135.147 with SMTP id ps19mr2317442lab.52.1346945578883; Thu, 06 Sep 2012 08:32:58 -0700 (PDT) Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id o7sm678046lbg.4.2012.09.06.08.32.56 (version=SSLv3 cipher=OTHER); Thu, 06 Sep 2012 08:32:57 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v2 4/6] emacs: add support for custom tag changes on message/thread archive Date: Thu, 6 Sep 2012 18:32:40 +0300 Message-Id: <6158e4e4866e1ba5d77a09e30b1540098a0cd000.1346945257.git.jani@nikula.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQlVzOXnlwb3GUkmEOpWVfdxYLjDYJsQVYftSRsienmGQZWHpr0OgFZK/VLxN90sMnm1qiam Cc: Tomi Ollila X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2012 15:33:01 -0000 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