--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 1B3BA431FC0\r
+ for <notmuch@notmuchmail.org>; Tue, 11 Feb 2014 17:21:38 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\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 Z9LTdCjKnMat for <notmuch@notmuchmail.org>;\r
+ Tue, 11 Feb 2014 17:21:30 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu\r
+ [18.9.25.13])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 56CB6431FBD\r
+ for <notmuch@notmuchmail.org>; Tue, 11 Feb 2014 17:21:30 -0800 (PST)\r
+X-AuditID: 1209190d-f79776d000000ce9-6e-52facc97d1e1\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 06.21.03305.79CCAF25; Tue, 11 Feb 2014 20:21:27 -0500 (EST)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s1C1LQuZ024038; \r
+ Tue, 11 Feb 2014 20:21:27 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s1C1LNDh001937\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Tue, 11 Feb 2014 20:21:25 -0500\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1WDOVv-0003Ot-Fi; Tue, 11 Feb 2014 20:21:23 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 4/7] emacs: show: mark tags changed since buffer loaded\r
+In-Reply-To: <1390087855-26194-5-git-send-email-markwalters1009@gmail.com>\r
+References: <1390087855-26194-1-git-send-email-markwalters1009@gmail.com>\r
+ <1390087855-26194-5-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Notmuch/0.17~rc2+14~g06f47e0 (http://notmuchmail.org) Emacs/23.4.1\r
+ (i486-pc-linux-gnu)\r
+Date: Tue, 11 Feb 2014 20:21:23 -0500\r
+Message-ID: <87ob2dm8h8.fsf@awakening.csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsUixG6nrjv9zK8ggzPvdC1Wz+WxuH5zJrMD\r
+ k8fOWXfZPZ6tusUcwBTFZZOSmpNZllqkb5fAlXF54luWgvNOFWs7n7E1ML4w6WLk5JAQMJGY\r
+ 8OESC4QtJnHh3no2EFtIYDaTxIWZGl2MXED2RkaJhydPMEE4p5kkGm8fYIZwljBKzLs4hR2k\r
+ hU1AQ2Lb/uWMILaIgKvE02+fmUFsYQFviUu3dzKB2JwCXhI37k1igWhuZ5R4vP8/WEJUIEni\r
+ 9NTfrCA2i4CqxIU558Du4AW6b8q1KawQtqDEyZlPwG5lFtCSuPHvJdMERoFZSFKzkKQWMDKt\r
+ YpRNya3SzU3MzClOTdYtTk7My0st0jXSy80s0UtNKd3ECApJTkneHYzvDiodYhTgYFTi4WXw\r
+ /BUkxJpYVlyZe4hRkoNJSZQ34BhQiC8pP6UyI7E4I76oNCe1+BCjBAezkgiv/gmgHG9KYmVV\r
+ alE+TEqag0VJnLfWAiglkJ5YkpqdmlqQWgSTleHgUJLgvXQKKCtYlJqeWpGWmVOCkGbi4AQZ\r
+ zgM0/A9IDW9xQWJucWY6RP4Uo6KUOO8ckIQASCKjNA+uF5YyXjGKA70izHsYpIoHmG7gul8B\r
+ DWYCGtyfDTa4JBEhJdXAGLLzncau+RUBXMHP5laHR/lGXtO/7JV1sLirsatO6j9L8OL0tneV\r
+ 2z493CswianwQefZi0bzNi5681zRajaLzHYz05zgl/8ufk2f6lwY4Vc5pbc89dac9OkPq1f5\r
+ NJVd2bQu/4pFnkjVVhcuFxX3VtGw2W4Pz+19wmxxRe70Q9Xtf8T26R/YrsRSnJFoqMVcVJwI\r
+ ANZ38p70AgAA\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: Wed, 12 Feb 2014 01:21:38 -0000\r
+\r
+On Sat, 18 Jan 2014, Mark Walters <markwalters1009@gmail.com> wrote:\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
+\r
+I would expect this to be cumulative. That is, I would want added and\r
+deleted tags to have my regular `notmuch-tag-formats' formatting in\r
+addition to extra formatting specified by\r
+`notmuch-tag-{added,deleted}-formats' (especially if, for example, it's\r
+replaced with an image).\r
+\r
+I think this should just be a matter of something like\r
+ (let ((formats\r
+ (append\r
+ (notmuch-tag--get-format tag notmuch-tag-formats)\r
+ (cond ((not (member tag tags))\r
+ (notmuch-tag--get-format tag notmuch-tag-deleted-formats))\r
+ ((not (member tag orig-tags)\r
+ (notmuch-tag--get-format tag notmuch-tag-added-formats)))))))\r
+ ...)\r
+where notmuch-tag--get-format is something I made up to abstract the\r
+assoc (or the regexp lookup). This also has the benefit of reducing the\r
+number of member tests.\r
+\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
+\r
+This may mutate orig-tags. It's not obvious to me that's okay. You\r
+could use remove-duplicates from cl. (I'm surprised I can't find a\r
+uniq-like function in cl, which would save the O(n^2) operation, but I\r
+doubt it matters.)\r
+\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
+\r
+Maybe "For historical reasons, we hide deleted tags by default in the\r
+test suite"?\r
+\r
+> +(setq notmuch-tag-deleted-formats\r
+> + '(("" nil)))\r
+> -- \r
+> 1.7.9.1\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r