[PATCH 1/3] emacs: Move colour line from search to lib
[notmuch-archives.git] / 2a / 84f96ad568a07c0afb2bb686e8d3f069c5923b
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id AD84C431FC2\r
6         for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 12:21:42 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id eEopK5ZF17UI for <notmuch@notmuchmail.org>;\r
18         Sat, 14 Apr 2012 12:21:41 -0700 (PDT)\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
20         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id F1C28431FAF\r
23         for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 12:21:40 -0700 (PDT)\r
24 Received: by werm13 with SMTP id m13so3020360wer.26\r
25         for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 12:21:39 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=y0hdnGd29PSJx+eMW5RDnHZNH17Jv6GTzMVLCfLdID4=;\r
29         b=kQMgCgwXogN0Ed6oPe+vSiEQVUgN92r3tIVPaYk8H/vzeStFnexZfPPyTHiCvqx/7e\r
30         cuE4RHYB6gcFO3c5giapDNokeQRfe/iNmjGo9AsNyLaoVPhUrG7S/0kMlsNAZtd8cMxl\r
31         jqujyis2i33qmcMFJgwrpM+M+A3b13wW4/rcgwbV7RfjvsFOZpsIPT7WDpCE4qfLjvSp\r
32         fNCNtrOiI0Y5dMNGrNBKLvRTXzGrxDg2YMxzS+To8ewLhuK4WdeLHW+djt8hWr9NwHSH\r
33         zx7TWotRhgAA0TxvSBdWjaM2tBPNNLnl0rs3kUAuAPHMQTc4nUYv2Z8feYNdS6hzaFyC\r
34         ABPQ==\r
35 Received: by 10.216.208.21 with SMTP id p21mr3543264weo.12.1334431299625;\r
36         Sat, 14 Apr 2012 12:21:39 -0700 (PDT)\r
37 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
38  [94.192.233.223])      by mx.google.com with ESMTPS id\r
39  h8sm10637596wix.4.2012.04.14.12.21.38  (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sat, 14 Apr 2012 12:21:39 -0700 (PDT)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH 1/3] emacs: Move colour line from search to lib\r
44 Date: Sat, 14 Apr 2012 20:21:39 +0100\r
45 Message-Id: <1334431301-27303-2-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 In-Reply-To: <1334431301-27303-1-git-send-email-markwalters1009@gmail.com>\r
48 References: <1334431301-27303-1-git-send-email-markwalters1009@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sat, 14 Apr 2012 19:21:43 -0000\r
62 \r
63 This patch moves the overlay/colouring from notmuch.el to\r
64 notmuch-lib.el. This is in preparation for its use by notmuch-show in\r
65 the next patch. This is just a rebased version of the emacs/notmuch.el\r
66 and emacs/notmuch-lib.el parts of David Edmondson's patch (see\r
67 id:"1325006003-27152-1-git-send-email-dme@dme.org")\r
68 ---\r
69  emacs/notmuch-lib.el |   18 ++++++++++++++++++\r
70  emacs/notmuch.el     |   15 +--------------\r
71  2 files changed, 19 insertions(+), 14 deletions(-)\r
72 \r
73 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
74 index 6907a5f..c8a9351 100644\r
75 --- a/emacs/notmuch-lib.el\r
76 +++ b/emacs/notmuch-lib.el\r
77 @@ -148,6 +148,24 @@ the user hasn't set this variable with the old or new value."\r
78    "Return a query that matches the message with id ID."\r
79    (concat "id:\"" (replace-regexp-in-string "\"" "\"\"" id t t) "\""))\r
80  \r
81 +(defun notmuch-color-line (start end line-tag-list spec)\r
82 +  "Colorize a line based on tags."\r
83 +  ;; Create the overlay only if the message has tags which match one\r
84 +  ;; of those specified in `spec'.\r
85 +  (let (overlay)\r
86 +    (mapc (lambda (elem)\r
87 +           (let ((tag (car elem))\r
88 +                 (attributes (cdr elem)))\r
89 +             (when (member tag line-tag-list)\r
90 +               (when (not overlay)\r
91 +                 (setq overlay (make-overlay start end))\r
92 +                 (overlay-put overlay 'priority 5))\r
93 +               ;; Merge the specified properties with any already\r
94 +               ;; applied from an earlier match.\r
95 +               (overlay-put overlay 'face\r
96 +                            (append (overlay-get overlay 'face) attributes)))))\r
97 +         spec)))\r
98 +\r
99  ;;\r
100  \r
101  (defun notmuch-common-do-stash (text)\r
102 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
103 index ba833e6..09f6c50 100644\r
104 --- a/emacs/notmuch.el\r
105 +++ b/emacs/notmuch.el\r
106 @@ -728,20 +728,7 @@ foreground and blue background."\r
107  \r
108  (defun notmuch-search-color-line (start end line-tag-list)\r
109    "Colorize lines in `notmuch-show' based on tags."\r
110 -  ;; Create the overlay only if the message has tags which match one\r
111 -  ;; of those specified in `notmuch-search-line-faces'.\r
112 -  (let (overlay)\r
113 -    (mapc (lambda (elem)\r
114 -           (let ((tag (car elem))\r
115 -                 (attributes (cdr elem)))\r
116 -             (when (member tag line-tag-list)\r
117 -               (when (not overlay)\r
118 -                 (setq overlay (make-overlay start end)))\r
119 -               ;; Merge the specified properties with any already\r
120 -               ;; applied from an earlier match.\r
121 -               (overlay-put overlay 'face\r
122 -                            (append (overlay-get overlay 'face) attributes)))))\r
123 -         notmuch-search-line-faces)))\r
124 +  (notmuch-color-line start end line-tag-list notmuch-search-line-faces))\r
125  \r
126  (defun notmuch-search-author-propertize (authors)\r
127    "Split `authors' into matching and non-matching authors and\r
128 -- \r
129 1.7.9.1\r
130 \r