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