[PATCH 06/10] cli: Introduce "notmuch address" command
[notmuch-archives.git] / ed / a8a79b2285c29a9e1678e2bcdd799c37e92e6e
1 Return-Path: <dme@dme.org>\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 0BDA24196F0\r
6         for <notmuch@notmuchmail.org>; Mon,  7 Jun 2010 07:35:24 -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: -1.9\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9] autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id HfsdZFNOMXnl for <notmuch@notmuchmail.org>;\r
16         Mon,  7 Jun 2010 07:35:13 -0700 (PDT)\r
17 Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
18         [74.125.82.181])\r
19         by olra.theworths.org (Postfix) with ESMTP id 9D5E6431FC1\r
20         for <notmuch@notmuchmail.org>; Mon,  7 Jun 2010 07:35:13 -0700 (PDT)\r
21 Received: by wyb35 with SMTP id 35so2855988wyb.26\r
22         for <notmuch@notmuchmail.org>; Mon, 07 Jun 2010 07:35:12 -0700 (PDT)\r
23 Received: by 10.227.145.141 with SMTP id d13mr5570334wbv.40.1275921311840;\r
24         Mon, 07 Jun 2010 07:35:11 -0700 (PDT)\r
25 Received: from ut.hh.sledj.net (gmp-ea-fw-1b.sun.com [192.18.8.1])\r
26         by mx.google.com with ESMTPS id n31sm38249009wba.9.2010.06.07.07.35.09\r
27         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
28         Mon, 07 Jun 2010 07:35:10 -0700 (PDT)\r
29 Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
30         id F1167594015; Mon,  7 Jun 2010 15:35:12 +0100 (BST)\r
31 From: David Edmondson <dme@dme.org>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH] emacs: Re-work the implementation of highlighting in\r
34         notmuch-search-mode.\r
35 Date: Mon,  7 Jun 2010 15:35:10 +0100\r
36 Message-Id: <1275921310-307-1-git-send-email-dme@dme.org>\r
37 X-Mailer: git-send-email 1.7.1\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Mon, 07 Jun 2010 14:35:24 -0000\r
51 \r
52 Re-write `notmuch-search-color-line', with the following improvements:\r
53  - create overlays only if they will be needed,\r
54  - merge the properties specified for a tag on top of any matching a\r
55    previous tag.\r
56 ---\r
57  emacs/notmuch.el |   37 +++++++++++++++++++++----------------\r
58  1 files changed, 21 insertions(+), 16 deletions(-)\r
59 \r
60 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
61 index 10babe4..ac1da34 100644\r
62 --- a/emacs/notmuch.el\r
63 +++ b/emacs/notmuch.el\r
64 @@ -585,28 +585,33 @@ This function advances the next thread when finished."\r
65  Here is an example of how to color search results based on tags.\r
66   (the following text would be placed in your ~/.emacs file):\r
67  \r
68 - (setq notmuch-search-line-faces '((\"delete\" . '(:foreground \"red\"))\r
69 + (setq notmuch-search-line-faces '((\"delete\" . '(:foreground \"red\"\r
70 +                                                  :background \"blue\"))\r
71                                     (\"unread\" . '(:foreground \"green\"))))\r
72  \r
73 -Order matters: for lines with multiple tags, the the first\r
74 -matching will be applied."\r
75 +The attributes defined for matching tags are merged, with later\r
76 +attributes overriding earlier. A message having both \"delete\"\r
77 +and \"unread\" tags with the above settings would have a green\r
78 +foreground and blue background."\r
79    :type '(alist :key-type (string) :value-type (list))\r
80    :group 'notmuch)\r
81  \r
82  (defun notmuch-search-color-line (start end line-tag-list)\r
83 -  "Colorize lines in notmuch-show based on tags"\r
84 -  (if notmuch-search-line-faces\r
85 -      (let ((overlay (make-overlay start end))\r
86 -           (tags-faces (copy-alist notmuch-search-line-faces)))\r
87 -       (while tags-faces\r
88 -         (let* ((tag-face (car tags-faces))\r
89 -                (tag (car tag-face))\r
90 -                (face (cdr tag-face)))\r
91 -           (cond ((member tag line-tag-list)\r
92 -                  (overlay-put overlay 'face face)\r
93 -                  (setq tags-faces nil))\r
94 -                 (t\r
95 -                  (setq tags-faces (cdr tags-faces)))))))))\r
96 +  "Colorize lines in `notmuch-show' based on tags."\r
97 +  ;; Create the overlay only if the message has tags which match one\r
98 +  ;; of those specified in `notmuch-search-line-faces'.\r
99 +  (let (overlay)\r
100 +    (mapc '(lambda (elem)\r
101 +            (let ((tag (car elem))\r
102 +                  (attributes (cdr elem)))\r
103 +              (when (member tag line-tag-list)\r
104 +                (when (not overlay)\r
105 +                  (setq overlay (make-overlay start end)))\r
106 +                ;; Merge the specified properties with any already\r
107 +                ;; applied from an earlier match.\r
108 +                (overlay-put overlay 'face\r
109 +                             (append (overlay-get overlay 'face) attributes)))))\r
110 +         notmuch-search-line-faces)))\r
111  \r
112  (defun notmuch-search-isearch-authors-show (overlay)\r
113    (remove-from-invisibility-spec (cons (overlay-get overlay 'invisible) t)))\r
114 -- \r
115 1.7.1\r
116 \r