--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 AC06C431FC0\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Jan 2014 15:31:20 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ 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 mRTZ69c1NQ0F for <notmuch@notmuchmail.org>;\r
+ Sat, 18 Jan 2014 15:31:16 -0800 (PST)\r
+Received: from mail-we0-f175.google.com (mail-we0-f175.google.com\r
+ [74.125.82.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 537C6431FC3\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Jan 2014 15:31:09 -0800 (PST)\r
+Received: by mail-we0-f175.google.com with SMTP id p61so5865409wes.34\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Jan 2014 15:31:08 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=XNlkJB/eL2hkcgKfVUr+8iTpujrtWB720nEZ6rZBjSk=;\r
+ b=NVWRi/HOaWfMrOZazygGZbGFJEy3wPnREy2CRjX/Twzuula1ehiGwDkP15DR14V/J4\r
+ rSiah0HZlmRvxKzVjpz6mFh3g0iJ8eMzialbMVYsF6SMMuXHyXtOdvsL4VmE0xep2BFh\r
+ FpqTr2e25xb0T5S9Nu1ls+pFl9k7hvSCqeT40le4fxIqzPGcHmH0mcM3MbMUmJ50mdAA\r
+ VRuO+NPNm/wM+dsyigMbTusvBfZ8Rcj6QEqvO0ws+uUqX2g+K3qp1u6zXkdISOcIJR1D\r
+ Wdb4ANOiVFfWuNLefp1HwWIWAiWq1UpJyhYUSjbADA6esXpC9MFXncQLmWzE4ju5+Kl3\r
+ /ZXA==\r
+X-Received: by 10.180.7.227 with SMTP id m3mr3970915wia.59.1390087868244;\r
+ Sat, 18 Jan 2014 15:31:08 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id p1sm10987743wie.1.2014.01.18.15.31.07\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 18 Jan 2014 15:31:07 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 4/7] emacs: show: mark tags changed since buffer loaded\r
+Date: Sat, 18 Jan 2014 23:30:52 +0000\r
+Message-Id: <1390087855-26194-5-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1390087855-26194-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1390087855-26194-1-git-send-email-markwalters1009@gmail.com>\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: Sat, 18 Jan 2014 23:31:20 -0000\r
+\r
+This allows (and requires) the original-tags to be passed along with\r
+the current-tags to be passed to notmuch-tag-format-tags. This allows\r
+the tag formatting to show added and deleted tags.By default a removed\r
+tag is displayed with strike-through in red (if strike-through is not\r
+available, eg on a terminal, inverse video is used instead) and an\r
+added tag is displayed underlined in green.\r
+\r
+If the caller does not wish to use the new feature it can pass\r
+current-tags for both arguments and, at this point, we do exactly that\r
+in the three callers of this function.\r
+\r
+Note, we cannot tidily allow original-tags to be optional because we would\r
+need to distinguish nil meaning "we are not specifying original-tags"\r
+from nil meaning there were no original-tags (an empty list).\r
+\r
+We use this in subsequent patches to make it clear when a message was\r
+unread when you first loaded a show buffer (previously the unread tag\r
+could be removed before a user realised that it had been unread).\r
+\r
+The code adds into the existing tag formatting code. The user can\r
+specify exactly how a tag should be displayed normally, when deleted,\r
+or when added. For convenience an entry for the empty string in the\r
+notmuch-tag-formats (and the corresponding notmuch-tag-deleted-formats\r
+notmuch-tag-added-formats) is applied to all tags which do not have an\r
+explicit match.\r
+\r
+This means that a user can tell notmuch not to show deleted tags at\r
+all by setting notmuch-tag-deleted-formats to\r
+'(("" nil))\r
+or not to show any deleted tags except "unread" by setting it to\r
+'(("" nil)\r
+ ("unread" (propertize tag 'face '(strike-through "red"))))\r
+\r
+All the variables are customizable; however, more complicated cases\r
+like changing the face depending on the type of display will require\r
+custom lisp.\r
+\r
+Currently this overrides notmuch-tag-deleted-formats for the tests\r
+setting it to '(("" nil)) so that they get removed from the display\r
+and, thus, all tests still pass.\r
+---\r
+ emacs/notmuch-show.el | 4 ++--\r
+ emacs/notmuch-tag.el | 32 +++++++++++++++++++++++++-------\r
+ emacs/notmuch-tree.el | 2 +-\r
+ emacs/notmuch.el | 2 +-\r
+ test/test-lib.el | 4 ++++\r
+ 5 files changed, 33 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 1ac80ca..1ce56f9 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -344,7 +344,7 @@ operation on the contents of the current buffer."\r
+ (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)\r
+ (let ((inhibit-read-only t))\r
+ (replace-match (concat "("\r
+- (notmuch-tag-format-tags tags)\r
++ (notmuch-tag-format-tags tags tags)\r
+ ")"))))))\r
+ \r
+ (defun notmuch-clean-address (address)\r
+@@ -423,7 +423,7 @@ message at DEPTH in the current thread."\r
+ " ("\r
+ date\r
+ ") ("\r
+- (notmuch-tag-format-tags tags)\r
++ (notmuch-tag-format-tags tags tags)\r
+ ")\n")\r
+ (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))\r
+ \r
+diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
+index 9757a0e..6bc47fb 100644\r
+--- a/emacs/notmuch-tag.el\r
++++ b/emacs/notmuch-tag.el\r
+@@ -164,10 +164,25 @@ This can be used with `notmuch-tag-format-image-data'."\r
+ </g>\r
+ </svg>")\r
+ \r
+-(defun notmuch-tag-format-tag (tag)\r
+- "Format TAG by looking into `notmuch-tag-formats'."\r
+- (let ((formats (or (assoc tag notmuch-tag-formats)\r
+- (assoc "" notmuch-tag-formats))))\r
++(defun notmuch-tag-format-tag (tags orig-tags tag)\r
++ "Format TAG by looking into `notmuch-tag-formats'.\r
++\r
++TAGS and ORIG-TAGS are lists of the current tags and the original\r
++tags; tags which have been deleted (i.e., are in ORIG-TAGS but\r
++are not in TAGS) are shown using formats from\r
++`notmuch-tag-deleted-formats'; tags which have been added (i.e.,\r
++are in TAGS but are not in ORIG-TAGS) are shown using formats\r
++from `notmuch-tag-added-formats' and tags which have not been\r
++changed (the normal case) are shown using formats from\r
++`notmuch-tag-formats'"\r
++ (let* ((status-formats (cond ((and (member tag tags) (member tag orig-tags))\r
++ notmuch-tag-formats)\r
++ ((not (member tag tags))\r
++ notmuch-tag-deleted-formats)\r
++ ((not (member tag orig-tags))\r
++ notmuch-tag-added-formats)))\r
++ (formats (or (assoc tag status-formats)\r
++ (assoc "" status-formats))))\r
+ (cond\r
+ ((null formats) ;; - Tag not in `notmuch-tag-formats',\r
+ tag) ;; the format is the tag itself.\r
+@@ -178,13 +193,16 @@ This can be used with `notmuch-tag-format-image-data'."\r
+ (dolist (format (cdr formats) tag)\r
+ (setq tag (eval format))))))))\r
+ \r
+-(defun notmuch-tag-format-tags (tags &optional face)\r
++(defun notmuch-tag-format-tags (tags orig-tags &optional face)\r
+ "Return a string representing formatted TAGS."\r
+- (let ((face (or face 'notmuch-tag-face)))\r
++ (let ((face (or face 'notmuch-tag-face))\r
++ (all-tags (sort (delete-dups (append tags orig-tags)) #'string<)))\r
+ (notmuch-combine-face-text-property-string\r
+ (mapconcat #'identity\r
+ ;; nil indicated that the tag was deliberately hidden\r
+- (delq nil (mapcar #'notmuch-tag-format-tag tags))\r
++ (delq nil (mapcar\r
++ (apply-partially #'notmuch-tag-format-tag tags orig-tags)\r
++ all-tags))\r
+ " ")\r
+ face\r
+ t)))\r
+diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el\r
+index 4f2ac02..b37e2cd 100644\r
+--- a/emacs/notmuch-tree.el\r
++++ b/emacs/notmuch-tree.el\r
+@@ -704,7 +704,7 @@ unchanged ADDRESS if parsing fails."\r
+ (face (if match\r
+ 'notmuch-tree-match-tag-face\r
+ 'notmuch-tree-no-match-tag-face)))\r
+- (format format-string (notmuch-tag-format-tags tags face)))))))\r
++ (format format-string (notmuch-tag-format-tags tags tags face)))))))\r
+ \r
+ (defun notmuch-tree-format-field-list (field-list msg)\r
+ "Format fields of MSG according to FIELD-LIST and return string"\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 0471750..1436e5a 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -754,7 +754,7 @@ non-authors is found, assume that all of the authors match."\r
+ \r
+ ((string-equal field "tags")\r
+ (let ((tags (plist-get result :tags)))\r
+- (insert (format format-string (notmuch-tag-format-tags tags)))))))\r
++ (insert (format format-string (notmuch-tag-format-tags tags tags)))))))\r
+ \r
+ (defun notmuch-search-show-result (result &optional pos)\r
+ "Insert RESULT at POS or the end of the buffer if POS is null."\r
+diff --git a/test/test-lib.el b/test/test-lib.el\r
+index 37fcb3d..6cbd57c 100644\r
+--- a/test/test-lib.el\r
++++ b/test/test-lib.el\r
+@@ -165,3 +165,7 @@ nothing."\r
+ \r
+ (t\r
+ (notmuch-test-report-unexpected output expected)))))\r
++\r
++;; hide deleted tags\r
++(setq notmuch-tag-deleted-formats\r
++ '(("" nil)))\r
+-- \r
+1.7.9.1\r
+\r