[notmuch] [PATCH] notmuch.el: colorize lines in notmuch-search based on thread tags.
authorJameson Rollins <jrollins@finestructure.net>
Thu, 4 Feb 2010 12:07:26 +0000 (07:07 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:06 +0000 (09:36 -0800)
da/4f461bf6d1c1bae5c8d373355c7d0a2aaec9ae [new file with mode: 0644]

diff --git a/da/4f461bf6d1c1bae5c8d373355c7d0a2aaec9ae b/da/4f461bf6d1c1bae5c8d373355c7d0a2aaec9ae
new file mode 100644 (file)
index 0000000..a51d1a8
--- /dev/null
@@ -0,0 +1,155 @@
+Return-Path: <jrollins@finestructure.net>\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 DE76C431FBD\r
+       for <notmuch@notmuchmail.org>; Thu,  4 Feb 2010 04:07:42 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -3.612\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-3.612 tagged_above=-999 required=5 tests=[AWL=0.387,\r
+       BAYES_50=0.001, RCVD_IN_DNSWL_MED=-4] autolearn=ham\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 mNoOE7EJzArN for <notmuch@notmuchmail.org>;\r
+       Thu,  4 Feb 2010 04:07:42 -0800 (PST)\r
+Received: from brinza.cc.columbia.edu (brinza.cc.columbia.edu [128.59.29.8])\r
+       by olra.theworths.org (Postfix) with ESMTP id 11869431FAE\r
+       for <notmuch@notmuchmail.org>; Thu,  4 Feb 2010 04:07:42 -0800 (PST)\r
+Received: from servo.finestructure.net (cpe-72-227-128-66.nyc.res.rr.com\r
+       [72.227.128.66])\r
+       (user=jgr2110 author=jrollins@finestructure.net mech=PLAIN bits=0)\r
+       by brinza.cc.columbia.edu (8.14.3/8.14.3) with ESMTP id o14C7VaZ009976\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT)\r
+       for <notmuch@notmuchmail.org>; Thu, 4 Feb 2010 07:07:36 -0500 (EST)\r
+Received: from jrollins by servo.finestructure.net with local (Exim 4.71)\r
+       (envelope-from <jrollins@finestructure.net>) id 1Nd0Ud-0004a8-R2\r
+       for notmuch@notmuchmail.org; Thu, 04 Feb 2010 07:07:31 -0500\r
+From: Jameson Rollins <jrollins@finestructure.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Date: Thu, 04 Feb 2010 07:07:26 -0500\r
+Message-ID: <87aavpb3wh.fsf@servo.finestructure.net>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="=-=-=";\r
+       micalg=pgp-sha256; protocol="application/pgp-signature"\r
+X-No-Spam-Score: Local\r
+X-Scanned-By: MIMEDefang 2.68 on 128.59.29.8\r
+Subject: [notmuch] [PATCH] notmuch.el: colorize lines in notmuch-search\r
+       based on thread tags.\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: Thu, 04 Feb 2010 12:07:43 -0000\r
+\r
+--=-=-=\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+Arbitrary font faces can be specified for given thread tags.  By\r
+default, no coloring is applied.  To specify coloring, place something\r
+like this in your .emacs:\r
+\r
+(setq notmuch-search-line-faces '(("delete" . '(:foreground "red"))\r
+                                  ("unread" . '(:foreground "green"))))\r
+\r
+Order matters: line faces listed first will take precedence (in the\r
+example above, a thread tagged both "delete" and "unread" will be\r
+colored red, since the "delete" face is listed before the "unread").\r
+=2D--\r
+ notmuch.el |   33 ++++++++++++++++++++++++++++++++-\r
+ 1 files changed, 32 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/notmuch.el b/notmuch.el\r
+index a21c6a6..4f8840a 100644\r
+=2D-- a/notmuch.el\r
++++ b/notmuch.el\r
+@@ -1203,6 +1203,35 @@ This function advances the next thread when finished=\r
+."\r
+                           (insert (format " (process returned %d)" exit-status)))\r
+                       (insert "\n"))))))))))\r
+=20\r
++(defcustom notmuch-search-line-faces nil\r
++  "Tag/face mapping for line highlighting in notmuch-search.\r
++\r
++Here is an example of how to color search results based on tags.\r
++(the following text would be placed in your ~/.emacs file):\r
++\r
++(setq notmuch-search-line-faces '((\"delete\" . '(:foreground \"red\"))\r
++                                (\"unread\" . '(:foreground \"green\"))))\r
++\r
++Order matters: for lines with multiple tags, the the first\r
++matching will be applied."\r
++  :type '(alist :key-type (string) :value-type (list))\r
++  :group 'notmuch)\r
++\r
++(defun notmuch-search-color-line (start end line-tag-list)\r
++  "Colorize lines in notmuch-show based on tags"\r
++  (if notmuch-search-line-faces\r
++      (let ((overlay (make-overlay start end))\r
++          (tags-faces (copy-alist notmuch-search-line-faces)))\r
++      (while tags-faces\r
++        (let* ((tag-face (car tags-faces))\r
++               (tag (car tag-face))\r
++               (face (cdr tag-face)))\r
++          (cond ((member tag line-tag-list)\r
++                 (overlay-put overlay 'face face)\r
++                 (setq tags-faces nil))\r
++                (t\r
++                 (setq tags-faces (cdr tags-faces)))))))))\r
++\r
+ (defun notmuch-search-process-filter (proc string)\r
+   "Process and filter the output of \"notmuch search\""\r
+   (let ((buffer (process-buffer proc)))\r
+@@ -1220,12 +1249,14 @@ This function advances the next thread when finishe=\r
+d."\r
+                          (authors (match-string 4 string))\r
+                          (authors-length (length authors))\r
+                          (subject (match-string 5 string))\r
+=2D                       (tags (match-string 6 string)))\r
++                         (tags (match-string 6 string))\r
++                         (tag-list (if tags (save-match-data (split-string tags)))))\r
+                     (if (> authors-length 40)\r
+                         (set 'authors (concat (substring authors 0 (- 40 3)) "...")))\r
+                     (goto-char (point-max))\r
+                     (let ((beg (point-marker)))\r
+                       (insert (format "%s %-7s %-40s %s (%s)\n" date count authors subject ta=\r
+gs))\r
++                      (notmuch-search-color-line beg (point-marker) tag-list)\r
+                       (put-text-property beg (point-marker) 'notmuch-search-thread-id thread-=\r
+id)\r
+                       (put-text-property beg (point-marker) 'notmuch-search-authors authors)\r
+                       (put-text-property beg (point-marker) 'notmuch-search-subject subject))\r
+=2D-=20\r
+1.6.5\r
+\r
+\r
+--=-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.10 (GNU/Linux)\r
+\r
+iQIcBAEBCAAGBQJLarh+AAoJEO00zqvie6q86cAP/1ZRLQUNWqNfiem5zX+vxeqV\r
+UzrtRZoIhWPZdyxKs1ty0K7AZD/lYySHrpS/sYkkQFEVOzxwdN4oNxU8FulZjGBe\r
+mp3bKAgTxqAx2zKNuXFxgKdrnAMfhaAlTtYj2Tsm55XZgiEa7Cf+3Mjuy3Rr1ABO\r
+uRjDCggCGkLaZpLIuSe9ZjcnKC2fFnnkKcxhsebdpgoTbVtxVkU6LpAeoWonQiQT\r
+DAXIVi1uBcTynr8r/xZkPT7OL09D28eLHJGKMnh427a+l5u1kW+yb9qsPGkLmKcT\r
+uBgJctsu4zqVAdmLHqCYJW625wfeQji8Zw0Btwc7n8x9uCdUhzaFnGmVde3NFt/F\r
+LkVPQzoJIU/Y7Me6bHp64CUr/BZiWkZsFYwcvQlB5E1NDTQH4663p+IBgGECVwbJ\r
+8MOhuQnqZj3lBW7a3mv+s93jxzaQ/Bh4SmqRE3KiajEGQXfcGJY21Pb0GooEB0m2\r
+He9pdEIjVDcAUjXopv2VdAro6DQBdBVv26Yht48MSk0TyljB1GtOtiRy2EzhxEqE\r
+xFZgN2zuBSSPGLUX+nqSbKTvdLjlf72pR2vUBU/dQxywfsPQaqJyR5Inq8R4a/1k\r
+GE/UMxwwPB4e7j1reD88J24EevxBD90fYzb/Kz7oQ6+V1lFxIIP8gpEABViroAg5\r
+oQ8nP2fGHJaEzDK/LHRI\r
+=PXBd\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r