Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 9a / 47405c34100883220ed9885293093f871222ee
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 CCA834196F2\r
6         for <notmuch@notmuchmail.org>; Wed, 28 Apr 2010 23:52:08 -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 l3vrAqomkSqW for <notmuch@notmuchmail.org>;\r
16         Wed, 28 Apr 2010 23:52:07 -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 41E7A431FC1\r
20         for <notmuch@notmuchmail.org>; Wed, 28 Apr 2010 23:52:07 -0700 (PDT)\r
21 Received: by wyj26 with SMTP id 26so2828306wyj.26\r
22         for <notmuch@notmuchmail.org>; Wed, 28 Apr 2010 23:52:06 -0700 (PDT)\r
23 Received: by 10.216.161.68 with SMTP id v46mr3733816wek.107.1272523926336;\r
24         Wed, 28 Apr 2010 23:52:06 -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 x1sm4781291wbx.19.2010.04.28.23.52.04\r
27         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
28         Wed, 28 Apr 2010 23:52:05 -0700 (PDT)\r
29 Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
30         id 1D64959411F; Thu, 29 Apr 2010 07:52:25 +0100 (BST)\r
31 From: David Edmondson <dme@dme.org>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH 1/2] emacs: Display non-matching authors with a different\r
34  face.\r
35 Date: Thu, 29 Apr 2010 07:52:22 +0100\r
36 Message-Id: <1272523943-25588-1-git-send-email-dme@dme.org>\r
37 X-Mailer: git-send-email 1.7.0\r
38 In-Reply-To: <1272477627-10562-1-git-send-email-dme@dme.org>\r
39 References: <1272477627-10562-1-git-send-email-dme@dme.org>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Thu, 29 Apr 2010 06:52:09 -0000\r
53 \r
54 In search mode some messages don't match the search criteria. Show\r
55 their authors names with a different face - generally darker than\r
56 those that do match.\r
57 ---\r
58 \r
59 At Sebastian's request, allow the face to be customised.\r
60 \r
61  emacs/notmuch.el |   36 +++++++++++++++++++++++++++++-------\r
62  1 files changed, 29 insertions(+), 7 deletions(-)\r
63 \r
64 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
65 index 7457da9..60c0ee5 100644\r
66 --- a/emacs/notmuch.el\r
67 +++ b/emacs/notmuch.el\r
68 @@ -297,6 +297,17 @@ For a mouse binding, return nil."\r
69    "Notmuch search mode face used to highligh tags."\r
70    :group 'notmuch)\r
71  \r
72 +(defface notmuch-search-non-matching-authors\r
73 +  '((((class color)\r
74 +      (background dark))\r
75 +     (:foreground "grey30"))\r
76 +    (((class color)\r
77 +      (background light))\r
78 +     (:foreground "grey60"))\r
79 +    (t (:italic t)))\r
80 +  "Face used in search mode for authors not matching the query."\r
81 +  :group 'notmuch)\r
82 +\r
83  ;;;###autoload\r
84  (defun notmuch-search-mode ()\r
85    "Major mode displaying results of a notmuch search.\r
86 @@ -576,6 +587,23 @@ matching will be applied."\r
87                   (t\r
88                    (setq tags-faces (cdr tags-faces)))))))))\r
89  \r
90 +(defun notmuch-search-insert-authors (format-string authors)\r
91 +  (insert (let* ((formatted-sample (format format-string ""))\r
92 +                (formatted-authors (format format-string authors))\r
93 +                (truncated-string\r
94 +                 (if (> (length formatted-authors)\r
95 +                        (length formatted-sample))\r
96 +                     (concat (substring authors 0 (- (length formatted-sample) 4)) "... ")\r
97 +                   formatted-authors)))\r
98 +           ;; Need to save the match data to avoid interfering with\r
99 +           ;; `notmuch-search-process-filter'.\r
100 +           (save-match-data\r
101 +             (if (string-match "\\(.*\\)|\\(..*\\)" truncated-string)\r
102 +                 (concat (match-string 1 truncated-string) ","\r
103 +                         (propertize (match-string 2 truncated-string)\r
104 +                                     'face 'notmuch-search-non-matching-authors))\r
105 +               truncated-string)))))\r
106 +\r
107  (defun notmuch-search-insert-field (field date count authors subject tags)\r
108    (cond\r
109     ((string-equal field "date")\r
110 @@ -583,13 +611,7 @@ matching will be applied."\r
111     ((string-equal field "count")\r
112      (insert (format (cdr (assoc field notmuch-search-result-format)) count)))\r
113     ((string-equal field "authors")\r
114 -    (insert (let* ((format-string (cdr (assoc field notmuch-search-result-format)))\r
115 -                  (formatted-sample (format format-string ""))\r
116 -                  (formatted-authors (format format-string authors)))\r
117 -             (if (> (length formatted-authors)\r
118 -                    (length formatted-sample))\r
119 -                 (concat (substring authors 0 (- (length formatted-sample) 4)) "... ")\r
120 -               formatted-authors))))\r
121 +    (notmuch-search-insert-authors (cdr (assoc field notmuch-search-result-format)) authors))\r
122     ((string-equal field "subject")\r
123      (insert (format (cdr (assoc field notmuch-search-result-format)) subject)))\r
124     ((string-equal field "tags")\r
125 -- \r
126 1.7.0\r
127 \r