Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / eb / 15fd48dd135b5aa695291c048a1381e2cafe99
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 DD3FD431FAF\r
6         for <notmuch@notmuchmail.org>; Sun, 29 Apr 2012 15:48:07 -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 vpA3CRuJJQ73 for <notmuch@notmuchmail.org>;\r
18         Sun, 29 Apr 2012 15:48:07 -0700 (PDT)\r
19 Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com\r
20         [209.85.212.173]) (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 0E6E5431FAE\r
23         for <notmuch@notmuchmail.org>; Sun, 29 Apr 2012 15:48:06 -0700 (PDT)\r
24 Received: by wibhq7 with SMTP id hq7so1840741wib.2\r
25         for <notmuch@notmuchmail.org>; Sun, 29 Apr 2012 15:48:05 -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=oaIUiyCRs6sL/rfiID+f7sP0GJBjAONIWuhpviQcmJo=;\r
29         b=oJXjnokV/Eho6LgbYalIC0UBmZ2myw+Gfxxu67qjuG6NMTYtaOiYiPnb+D0PBnPS6y\r
30         X7rnFRlzo713cP93Bm/k7+JKYWq5Oj/Xo3qzLzF3Xzd9gaftISjQoi0Oqe9prPU8zBp0\r
31         uDmDAApA+nBEwGdM8jBvZNdE5uo/faovoQvR1sAmT2whNClOjgqKAmkzUv2bRRz1FCYw\r
32         oXLGPtKX666bYCtKzwyuFI2OaqMUDAZSX/u4WKqdGHU6Wan9w62/fw/fyO7r2bz6X/aA\r
33         /efUTFy3jEJTnp0RwxPFDoTUaXj3sOCv1pFCOeWDxZKprZXynq3q7TSmwtY/jyLy/cOy\r
34         eaDA==\r
35 Received: by 10.180.24.7 with SMTP id q7mr1545725wif.11.1335739685672;\r
36         Sun, 29 Apr 2012 15:48:05 -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  fz9sm24223990wib.3.2012.04.29.15.48.04 (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sun, 29 Apr 2012 15:48:05 -0700 (PDT)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [Patch v2 1/3] emacs: Move colour line from search to lib\r
44 Date: Sun, 29 Apr 2012 23:48:15 +0100\r
45 Message-Id: <1335739697-8501-2-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 In-Reply-To: <1335739697-8501-1-git-send-email-markwalters1009@gmail.com>\r
48 References: <1335739697-8501-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: Sun, 29 Apr 2012 22:48:08 -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 c6236db..d5f40e2 100644\r
104 --- a/emacs/notmuch.el\r
105 +++ b/emacs/notmuch.el\r
106 @@ -612,20 +612,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