From: Jani Nikula Date: Sun, 2 Sep 2012 19:58:03 +0000 (+0300) Subject: [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=2f0b10c299804a673cbacf9da91e1cbc70e5f0bb;p=notmuch-archives.git [PATCH 4/6] emacs: add support for custom tag changes on message/thread archive --- diff --git a/d6/2514b60d301ba9d088fd30579d7e205d689763 b/d6/2514b60d301ba9d088fd30579d7e205d689763 new file mode 100644 index 000000000..ce447d0d7 --- /dev/null +++ b/d6/2514b60d301ba9d088fd30579d7e205d689763 @@ -0,0 +1,188 @@ +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 D6104431FB6 + for ; Sun, 2 Sep 2012 12:58:24 -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 n-NGdqxOU7Py for ; + Sun, 2 Sep 2012 12:58:22 -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 81F5D431FC2 + for ; Sun, 2 Sep 2012 12:58:22 -0700 (PDT) +Received: by mail-lb0-f181.google.com with SMTP id gk1so2402453lbb.26 + for ; Sun, 02 Sep 2012 12:58:22 -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=Ka5jiLe0O5HL1adLVZ1eBpPoTnA5y9WpXWZstnb3B971VaPOSTFrd3ORRvyUrhfKFn + fcIxBE1QY+7SbBnp8EfTFsBRwPifVoqY+cTnpfXFH2AnrmUrKqlT+qxVSBjUl1x65FEt + acGmPZVcP0yuP+BVTrmwALJ0/sBMcImJJ3xWO8PoeVvlKQxKvcd5/fR62xAnYHMI9lgs + M1xu7Yx2horVJdU+5P8pv7WKyUfmlbq0U2KFSViTK854zbU8qTix7xO12ETjkQ3nPKi4 + 06Ih06qpnQW8OSPytWn+hhQ2biR0mijJ8/9KT2mIONXM1ELDXv67dlCGZ/s6+OJ0q5rd + zjBA== +Received: by 10.152.131.68 with SMTP id ok4mr12081943lab.47.1346615902161; + Sun, 02 Sep 2012 12:58:22 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. + [80.223.81.27]) + by mx.google.com with ESMTPS id ly17sm11378265lab.2.2012.09.02.12.58.20 + (version=SSLv3 cipher=OTHER); Sun, 02 Sep 2012 12:58:21 -0700 (PDT) +From: Jani Nikula +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 +Message-Id: + <0907a84d74600df18b8663c28c26f9f7bc2f31c2.1346614915.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: + ALoCoQkjQv3B4VwBwpb5TliQ0kvPnQCFnWH1bGo2l8OYmZaCgsPoKnf98rQLXU1oGazXL47teNIe +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: Sun, 02 Sep 2012 19:58:25 -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 +