--- /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 2D568431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 25 Mar 2013 07:22:43 -0700 (PDT)\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 C5fm8VpjgJun for <notmuch@notmuchmail.org>;\r
+ Mon, 25 Mar 2013 07:22:42 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
+ [18.7.68.36])\r
+ by olra.theworths.org (Postfix) with ESMTP id C2E21431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 25 Mar 2013 07:22:41 -0700 (PDT)\r
+X-AuditID: 12074424-b7f936d0000008eb-11-51505db11670\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+ by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 32.13.02283.1BD50515; Mon, 25 Mar 2013 10:22:41 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11])\r
+ by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r2PEMd3d002348; \r
+ Mon, 25 Mar 2013 10:22:40 -0400\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 r2PEMbLa025826\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Mon, 25 Mar 2013 10:22:38 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1UK8IH-0005in-BZ; Mon, 25 Mar 2013 10:22:37 -0400\r
+Date: Mon, 25 Mar 2013 10:22:37 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Damien Cassou <damien.cassou@gmail.com>\r
+Subject: Re: [PATCH 2/2] emacs: possibility to customize the rendering of tags\r
+Message-ID: <20130325142237.GB32584@mit.edu>\r
+References: <1364038194-19856-1-git-send-email-damien.cassou@gmail.com>\r
+ <1364038194-19856-3-git-send-email-damien.cassou@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=iso-8859-1\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: 8bit\r
+In-Reply-To: <1364038194-19856-3-git-send-email-damien.cassou@gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFlrOKsWRmVeSWpSXmKPExsUixG6norsxNiDQ4ON2Lotdd7cyWVy/OZPZ\r
+ gclj56y77B7PVt1iDmCK4rJJSc3JLEst0rdL4MrYdKyk4E5IxaPmMywNjG+cuxg5OSQETCTu\r
+ XN/OBmGLSVy4tx7I5uIQEtjHKHHzTwMzhLORUeLdrHksEM5pJol58yYzQThLGCUu7V0C1s8i\r
+ oCox68UDRhCbTUBDYtv+5WC2iIC2xJulHawgNrOAtMS3381MILawgJ/Ewx8nwWxeAR2J49ef\r
+ MoPYQgKtjBI791lBxAUlTs58wgLRqyOxc+sdoF0cYHOW/+OACMtLNG+dDdbKKeAhcefCPbBV\r
+ ogIqElNObmObwCg8C8mkWUgmzUKYNAvJpAWMLKsYZVNyq3RzEzNzilOTdYuTE/PyUot0zfVy\r
+ M0v0UlNKNzGC48BFZQdj8yGlQ4wCHIxKPLwbggMChVgTy4orcw8xSnIwKYnyloYDhfiS8lMq\r
+ MxKLM+KLSnNSiw8xSnAwK4nwagkB5XhTEiurUovyYVLSHCxK4rzXU276CwmkJ5akZqemFqQW\r
+ wWRlODiUJHg/xgA1ChalpqdWpGXmlCCkmTg4QYbzAA1/DVLDW1yQmFucmQ6RP8Woy/F13udX\r
+ jEIsefl5qVLivOdBigRAijJK8+DmwNLXK0ZxoLeEef+AVPEAUx/cpFdAS5iAlkz96w+ypCQR\r
+ ISXVwGiwlkMr6NXa1p/bw2fLlFtGPd17aXKEZ07X9mOmj6K+c/zgttrHsNig4XO8BIPuqfMC\r
+ 5myq54MXbYpzPzr1hafZpm7f+AWTtXbMmT0tKc/kvn7wNiaDzQFnyh+vadPQLHrw+kb3eYvp\r
+ E1fdemgQEtd/JfXaHyf2Tb/npi0N8+2Q7IwM/lT5fp4SS3FGoqEWc1FxIgAgBc4/OgMAAA==\r
+Cc: notmuch@notmuchmail.org\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: Mon, 25 Mar 2013 14:22:43 -0000\r
+\r
+Series LGTM. I noticed a few things below that would be fine to tweak\r
+in a follow-up trivial patch or two.\r
+\r
+Quoth Damien Cassou on Mar 23 at 12:29 pm:\r
+> This patch extracts the rendering of tags in notmuch-show to\r
+> the notmuch-tag file.\r
+> \r
+> This file introduces a `notmuch-tag-formats' variable that associates\r
+> each tag to a particular format. This variable can be customized\r
+> thanks to the work of Austin Clements. For example,\r
+> \r
+> '(("unread" (propertize tag 'face '(:foreground "red")))\r
+> ("flagged" (notmuch-tag-format-image tag "star.svg")))\r
+> \r
+> associates a red foreground to the "unread" tag and a star picture to\r
+> the "flagged" tag.\r
+> \r
+> Signed-off-by: Damien Cassou <damien.cassou@gmail.com>\r
+> ---\r
+> emacs/notmuch-show.el | 6 +--\r
+> emacs/notmuch-tag.el | 136 ++++++++++++++++++++++++++++++++++++++++++++++++-\r
+> emacs/notmuch.el | 5 +-\r
+> 3 files changed, 139 insertions(+), 8 deletions(-)\r
+> \r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index acaef8e..a4d2c12 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -362,8 +362,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
+> - (propertize (mapconcat 'identity tags " ")\r
+> - 'face 'notmuch-tag-face)\r
+> + (notmuch-tag-format-tags tags)\r
+> ")"))))))\r
+> \r
+> (defun notmuch-clean-address (address)\r
+> @@ -441,8 +440,7 @@ message at DEPTH in the current thread."\r
+> " ("\r
+> date\r
+> ") ("\r
+> - (propertize (mapconcat 'identity tags " ")\r
+> - 'face 'notmuch-tag-face)\r
+> + (notmuch-tag-format-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 4fce3a9..75a438b 100644\r
+> --- a/emacs/notmuch-tag.el\r
+> +++ b/emacs/notmuch-tag.el\r
+> @@ -1,5 +1,6 @@\r
+> ;; notmuch-tag.el --- tag messages within emacs\r
+> ;;\r
+> +;; Copyright © Damien Cassou\r
+> ;; Copyright © Carl Worth\r
+> ;;\r
+> ;; This file is part of Notmuch.\r
+> @@ -18,11 +19,144 @@\r
+> ;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.\r
+> ;;\r
+> ;; Authors: Carl Worth <cworth@cworth.org>\r
+> +;; Damien Cassou <damien.cassou@gmail.com>\r
+> +;;\r
+> +;;; Code:\r
+> +;;\r
+> \r
+> -(eval-when-compile (require 'cl))\r
+> +(require 'cl)\r
+> (require 'crm)\r
+> (require 'notmuch-lib)\r
+> \r
+> +(defcustom notmuch-tag-formats\r
+> + '(("unread" (propertize tag 'face '(:foreground "red")))\r
+> + ("flagged" (notmuch-tag-format-image-data tag (notmuch-tag-star-icon))))\r
+> + "Custom formats for individual tags.\r
+> +\r
+> +This gives a list that maps from tag names to lists of formatting\r
+> +expressions. The car of each element gives a tag name and the\r
+> +cdr gives a list of Elisp expressions that modify the tag. If\r
+> +the list is empty, the tag will simply be hidden. Otherwise,\r
+> +each expression will be evaluated in order: for the first\r
+> +expression, the variable `tag' will be bound to the tag name; for\r
+> +each later expression, the variable `tag' will be bound to the\r
+> +result of the previous expression. In this way, each expression\r
+> +can build on the formatting performed by the previous expression.\r
+> +The result of the last expression will displayed in place of the\r
+> +tag.\r
+> +\r
+> +For example, to replace a tag with another string, simply use\r
+> +that string as a formatting expression. To change the foreground\r
+> +of a tag to red, use the expression\r
+> + (propertize tag 'face '(:foreground \"red\"))\r
+> +\r
+> +See also `notmuch-tag-format-image', which can help replace tags\r
+> +with images."\r
+> +\r
+> + :group 'notmuch-search\r
+> + :group 'notmuch-show\r
+> + :type '(alist :key-type (string :tag "Tag")\r
+> + :extra-offset -3\r
+> + :value-type\r
+> + (radio :format "%v"\r
+> + (const :tag "Hidden" nil)\r
+> + (set :tag "Modified"\r
+> + (string :tag "Display as")\r
+> + (list :tag "Face" :extra-offset -4\r
+> + (const :format "" :inline t\r
+> + (propertize tag 'face))\r
+> + (list :format "%v"\r
+> + (const :format "" quote)\r
+> + custom-face-edit))\r
+> + (list :format "%v" :extra-offset -4\r
+> + (const :format "" :inline t\r
+> + (notmuch-tag-format-image-data tag))\r
+> + (choice :tag "Image"\r
+> + (const :tag "Star"\r
+> + (notmuch-tag-star-icon))\r
+> + (const :tag "Empty star"\r
+> + (notmuch-tag-star-empty-icon))\r
+> + (const :tag "Tag"\r
+> + (notmuch-tag-tag-icon))\r
+> + (string :tag "Custom")))\r
+> + (sexp :tag "Custom")))))\r
+> +\r
+> +(defun notmuch-tag-format-image-data (tag data)\r
+> + "Replace TAG with image DATA, if available.\r
+> +\r
+> +This function returns a propertized string that will display image\r
+> +DATA in place of TAG.This is designed for use in\r
+\r
+Missing spaces after the period.\r
+\r
+> +`notmuch-tag-formats'.\r
+> +\r
+> +DATA is the content of an SVG picture (e.g., as returned by\r
+> +`notmuch-tag-star-icon')."\r
+> + (propertize tag 'display\r
+> + `(image :type svg\r
+> + :data ,data\r
+> + :ascent center\r
+> + :mask heuristic)))\r
+> +\r
+> +(defun notmuch-tag-star-icon ()\r
+\r
+Should these be notmuch-tag-icon-{star,star-empty,tag}? That would\r
+better match standard naming conventions (most general term to least\r
+general term) and would avoid the awkward notmuch-tag-tag-icon.\r
+\r
+> + "Return SVG data representing a star icon.\r
+> +This can be used with `notmuch-tag-format-image-data'."\r
+> +"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r
+> +<svg version=\"1.1\" width=\"16\" height=\"16\">\r
+> + <g transform=\"translate(-242.81601,-315.59635)\">\r
+> + <path\r
+> + d=\"m 290.25762,334.31206 -17.64143,-11.77975 -19.70508,7.85447 5.75171,-20.41814 -13.55925,-16.31348 21.19618,-0.83936 11.325,-17.93675 7.34825,19.89939 20.55849,5.22795 -16.65471,13.13786 z\"\r
+> + transform=\"matrix(0.2484147,-0.02623394,0.02623394,0.2484147,174.63605,255.37691)\"\r
+> + style=\"fill:#ffff00;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\" />\r
+\r
+Here's an even simpler equivalent SVG:\r
+\r
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<svg version="1.1" width="16" height="16">\r
+ <path\r
+ d="M 12.69462,15.21399 8.00320,12.75053 3.31422,15.21864 4.20739,9.99558 0.41110,6.29879 5.65452,5.53422 7.99727,0.78137 10.34472,5.53189 15.58890,6.29126 11.79629,9.99182 z"\r
+ style="fill:#ffff00;stroke:#000000;stroke-width:0.25" />\r
+</svg>\r
+\r
+I pre-applied the transformations and removed the style attributes\r
+that had default or unimportant values. (The script to do the path\r
+math is attached.)\r
+\r
+> + </g>\r
+> +</svg>")\r
+> +\r
+> +(defun notmuch-tag-star-empty-icon ()\r
+> + "Return SVG data representing an empty star icon.\r
+> +This can be used with `notmuch-tag-format-image-data'."\r
+> + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r
+> +<svg version=\"1.1\" width=\"16\" height=\"16\">\r
+> + <g transform=\"translate(-242.81601,-315.59635)\">\r
+> + <path\r
+> + d=\"m 290.25762,334.31206 -17.64143,-11.77975 -19.70508,7.85447 5.75171,-20.41814 -13.55925,-16.31348 21.19618,-0.83936 11.325,-17.93675 7.34825,19.89939 20.55849,5.22795 -16.65471,13.13786 z\"\r
+> + transform=\"matrix(0.2484147,-0.02623394,0.02623394,0.2484147,174.63605,255.37691)\"\r
+> + style=\"fill:#d6d6d1;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\" />\r
+> + </g>\r
+> +</svg>")\r
+\r
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<svg version="1.1" width="16" height="16">\r
+ <path\r
+ d="M 12.69462,15.21399 8.00320,12.75053 3.31422,15.21864 4.20739,9.99558 0.41110,6.29879 5.65452,5.53422 7.99727,0.78137 10.34472,5.53189 15.58890,6.29126 11.79629,9.99182 z"\r
+ style="fill:#d6d6d1;stroke:#000000;stroke-width:0.25" />\r
+</svg>\r
+\r
+> +\r
+> +(defun notmuch-tag-tag-icon ()\r
+> + "Return SVG data representing a tag icon.\r
+> +This can be used with `notmuch-tag-format-image-data'."\r
+> + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r
+> +<svg version=\"1.1\" width=\"16\" height=\"16\">\r
+> + <g transform=\"translate(0,-1036.3622)\">\r
+> + <path\r
+> + d=\"m 0.44642857,1040.9336 12.50000043,0 2.700893,3.6161 -2.700893,3.616 -12.50000043,0 z\"\r
+> + style=\"fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1\" />\r
+> + </g>\r
+> +</svg>")\r
+\r
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<svg version="1.1" width="16" height="16">\r
+ <path\r
+ d="M 0.44643,4.57140 12.94643,4.57140 15.64732,8.18750 12.94643,11.80350 0.44643,11.80350 z"\r
+ style="fill:#ffff00;stroke:#000000;stroke-width:0.25" />\r
+</svg>\r
+\r
+> +\r
+> +(defun notmuch-tag-format-tag (tag)\r
+> + "Format TAG by looking into `notmuch-tag-formats'."\r
+> + (let ((formats (assoc tag notmuch-tag-formats)))\r
+> + (cond\r
+> + ((null formats) ;; - Tag not in `notmuch-tag-formats',\r
+> + tag) ;; the format is the tag itself.\r
+> + ((null (cdr formats)) ;; - Tag was deliberately hidden,\r
+> + nil) ;; no format must be returned\r
+> + (t ;; - Tag was found and has formats,\r
+> + (let ((tag tag)) ;; we must apply all the formats.\r
+> + (dolist (format (cdr formats) tag)\r
+> + (setq tag (eval format))))))))\r
+> +\r
+> +(defun notmuch-tag-format-tags (tags)\r
+> + "Return a string representing formatted TAGS."\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
+> + " ")\r
+> + 'notmuch-tag-face\r
+> + t))\r
+> +\r
+> (defcustom notmuch-before-tag-hook nil\r
+> "Hooks that are run before tags of a message are modified.\r
+> \r
+> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> index c98a4fe..e58c51d 100644\r
+> --- a/emacs/notmuch.el\r
+> +++ b/emacs/notmuch.el\r
+> @@ -797,9 +797,8 @@ non-authors is found, assume that all of the authors match."\r
+> (notmuch-search-insert-authors format-string (plist-get result :authors)))\r
+> \r
+> ((string-equal field "tags")\r
+> - (let ((tags-str (mapconcat 'identity (plist-get result :tags) " ")))\r
+> - (insert (propertize (format format-string tags-str)\r
+> - 'face 'notmuch-tag-face))))))\r
+> + (let ((tags (plist-get result :tags)))\r
+> + (insert (format format-string (notmuch-tag-format-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