--- /dev/null
+Return-Path: <damien.cassou@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 88E16431FC0\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Mar 2013 04:30:15 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, 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 Qet35n9r2b0D for <notmuch@notmuchmail.org>;\r
+ Sat, 23 Mar 2013 04:30:11 -0700 (PDT)\r
+Received: from mail-we0-f176.google.com (mail-we0-f176.google.com\r
+ [74.125.82.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 55E41431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Mar 2013 04:30:11 -0700 (PDT)\r
+Received: by mail-we0-f176.google.com with SMTP id s10so773782wey.21\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Mar 2013 04:30:10 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
+ :references:mime-version:content-type:content-transfer-encoding;\r
+ bh=vsgvWLZ1U+7aYqZ2UvKBsbsvAcnC/pWiFLJfkDXfH4U=;\r
+ b=WcRCr/wcVhDo77BSGi/BU6I4Kk0BNr1S8ihHwIiJdt5tvjSeM3PHbJusqu7DGSyTLg\r
+ 7HqUpWDOx4BSPIlkQ9PtpgVEbW8ckbpLZRLo4rfOZM61ljzwW9RtJIIFrFxoNzVyPe19\r
+ tpDtH/bctEBccXEFQjNAUPEofxuLUi2x47HCSuJd1Y/emobO3YL/Q7ZavU86CRgQzwfI\r
+ ChwUaAI21Elh/0IWBgbyGF7+YXewehouzdIA70L9/spz4uMwkEurPo82VLwIIcMQvf/E\r
+ fbAiuam8avCnE/htxL1mIZunhEnjNuEJ255atB8gpGa28zVIxvIDABPRWKfPvxBRyGzk\r
+ n1QA==\r
+X-Received: by 10.194.7.131 with SMTP id j3mr8244125wja.23.1364038210238;\r
+ Sat, 23 Mar 2013 04:30:10 -0700 (PDT)\r
+Received: from localhost.localdomain (110.195.67.86.rev.sfr.net.\r
+ [86.67.195.110])\r
+ by mx.google.com with ESMTPS id dp5sm16185652wib.1.2013.03.23.04.30.08\r
+ (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);\r
+ Sat, 23 Mar 2013 04:30:09 -0700 (PDT)\r
+From: Damien Cassou <damien.cassou@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] emacs: possibility to customize the rendering of tags\r
+Date: Sat, 23 Mar 2013 12:29:54 +0100\r
+Message-Id: <1364038194-19856-3-git-send-email-damien.cassou@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1364038194-19856-1-git-send-email-damien.cassou@gmail.com>\r
+References: <1364038194-19856-1-git-send-email-damien.cassou@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\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, 23 Mar 2013 11:30:16 -0000\r
+\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
++`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
++ "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
++ </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
++(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
++(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
+-- \r
+1.7.10.4\r
+\r