From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <markwalters1009@gmail.com>
Received: from localhost (localhost [127.0.0.1])
 by arlo.cworth.org (Postfix) with ESMTP id 58F6B6DE110A
 for <notmuch@notmuchmail.org>; Sun, 18 Sep 2016 10:04:43 -0700 (PDT)
X-Virus-Scanned: Debian amavisd-new at cworth.org
X-Spam-Flag: NO
X-Spam-Score: -0.368
X-Spam-Level: 
X-Spam-Status: No, score=-0.368 tagged_above=-999 required=5 tests=[AWL=0.202, 
 DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,
 RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled
Received: from arlo.cworth.org ([127.0.0.1])
 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id BS60LetCt7rp for <notmuch@notmuchmail.org>;
 Sun, 18 Sep 2016 10:04:42 -0700 (PDT)
Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68])
 by arlo.cworth.org (Postfix) with ESMTPS id 4EB8B6DE1104
 for <notmuch@notmuchmail.org>; Sun, 18 Sep 2016 10:04:41 -0700 (PDT)
Received: by mail-wm0-f68.google.com with SMTP id w84so4233635wmg.0
 for <notmuch@notmuchmail.org>; Sun, 18 Sep 2016 10:04:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=from:to:cc:subject:date:message-id:in-reply-to:references;
 bh=04j85LD9ZgXSrRNQjSwgWwXm5B6o0t3QZ8yWQr4a2WM=;
 b=X7jOHeosNx14hNSCmExK3eZmgHc1iAfG07P07Fzcs9tNQCebwSWANB1AZAtksUaENp
 nOOYDFKvg8e2RU+swhuX22IWAJhrS0Ul/clH/pG0qchI6f58yTu6wqneh74zxGAPe1X6
 Q3Bopje3x7K6tWGh9yQkN5Awu2o10kYu7NZrAGRgVh7hIx9uOvNmKe6XYn3maV8ZJz+N
 lO3d7Cadlh82oYK1WJWFFtdoRf1RFZpR1CgpShaHcjzsGDoFBXTesIUA6d+2Nn65sVEh
 09xL+vQSdds3VyRSdijsdPfIFIrGmJn3uXvL0OuT/7J6Qrv11dJP2POqainpDBLdnrBb
 7fKA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references;
 bh=04j85LD9ZgXSrRNQjSwgWwXm5B6o0t3QZ8yWQr4a2WM=;
 b=Ie7QiS9yecGcAmGrsXwRu/fLrBxv9DK+CXm6zBHWXnO7EdWzdg35eYmi5F6k7ujSL7
 whd1TmKRp8iaBtxvEWlF4272fVVRZtPLV5HWLdWX6qwrDvKxRttT/hnSWP0w5KWBBEIR
 q4ICg8YioOvs3PB9nZvq3nYxNz85SpXz5evcHCgL0cDTaPscJdfXMBTeS1eCLbJBSuH7
 eggMBKrrWsGQvfky3fIJw1Gmnp4vjmSCBPJ29QUM0Uy0LeuUSut7lIwRu0XAlFvZyBK0
 FXifoY522GIh1dzChWNe3CtbYjBxGf0lZQxiHzwLwhaUvLoxaxwsYxZP+mOkM/zA1H/r
 KHWQ==
X-Gm-Message-State: AE9vXwNoocFWmOUHBecpp/88eRhvLyHa8Nu4GVfk3ayFkDJEtK9qM7e8W0C/liWJs32xQw==
X-Received: by 10.195.20.33 with SMTP id gz1mr20511636wjd.75.1474218279915;
 Sun, 18 Sep 2016 10:04:39 -0700 (PDT)
Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])
 by smtp.gmail.com with ESMTPSA id 190sm17707581wmk.13.2016.09.18.10.04.39
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 18 Sep 2016 10:04:39 -0700 (PDT)
From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH v2 2/2] emacs: tag: allow non-automatically-reversible tag
 operations
Date: Sun, 18 Sep 2016 18:04:31 +0100
Message-Id: <1474218271-8312-3-git-send-email-markwalters1009@gmail.com>
X-Mailer: git-send-email 2.1.4
In-Reply-To: <1474218271-8312-1-git-send-email-markwalters1009@gmail.com>
References: <1474218271-8312-1-git-send-email-markwalters1009@gmail.com>
X-BeenThere: notmuch@notmuchmail.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: "Use and development of the notmuch mail system."
 <notmuch.notmuchmail.org>
List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
List-Post: <mailto:notmuch@notmuchmail.org>
List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
X-List-Received-Date: Sun, 18 Sep 2016 17:04:43 -0000

This lets the user specify some tag changes as #tag or =tag which mean
the same as +tag and -tag except the reverse changes are not applied
when reversing the operation.
---
 emacs/notmuch-tag.el | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 2fdccb6..b18dbf0 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -50,7 +50,7 @@
     (,(kbd "u") notmuch-show-mark-read-tags "Mark read")
     (,(kbd "f") ("+flagged") "Flag")
     (,(kbd "s") ("+spam" "-inbox") "Mark as spam")
-    (,(kbd "d") ("+deleted" "-inbox") "Delete"))
+    (,(kbd "d") ("+deleted" "=inbox") "Delete"))
   "A list of keys and corresponding tagging operations
 
 For each key (or key sequence) you can specify a sequence of
@@ -463,14 +463,27 @@ notmuch-after-tag-hook will be run."
 
 Add a \"+\" prefix to any tag in TAGS list that doesn't already
 begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all
-\"+\" prefixes with \"-\" and vice versa in the result."
-  (mapcar (lambda (str)
-	    (let ((s (if (string-match "^[+-]" str) str (concat "+" str))))
-	      (if reverse
-		  (concat (if (= (string-to-char s) ?-) "+" "-")
-			  (substring s 1))
-		s)))
-	  tags))
+\"+\" prefixes with \"-\" and vice versa in the result.
+
+Tags may also start with \"#\" or \"=\" which mean the same as +
+or - (respectively) when the forward operation is done, but are
+dropped when REVERSE is non-nil."
+  (remove-if 'null
+	     (mapcar (lambda (str)
+		       (let* ((s (if (string-match "^[+#=-]" str)
+				     str
+				   (concat "+" str)))
+			      (change (string-to-char s))
+			      (tag (substring s 1)))
+			 ;; we have a no-op if reverse and # or =
+			 (unless (and reverse (or (= change ?#) (= change ?=)))
+			   (let ((real-change (if reverse
+						  (if (= change ?-) "+" "-")
+						(case change
+						  ((?+ ?#) "+")
+						  ((?- ?=) "-")))))
+			     (concat real-change tag)))))
+		     tags)))
 
 (defun notmuch-tag-jump (reverse)
   (interactive "P")
@@ -486,7 +499,7 @@ begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all
 				   (second binding)))
 	     (tag-change (if reverse
 			     (notmuch-tag-change-list forward-tag-change 't)
-			   forward-tag-change))
+			   (notmuch-tag-change-list forward-tag-change)))
 	     (name (or (and (not (string= (third binding) ""))
 			    (third binding))
 		       (and (symbolp (second binding))
-- 
2.1.4