Re: Hi all
[notmuch-archives.git] / 9a / 762e98d42ad194c0129e410314368f605cb48e
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 404B54196F0\r
6         for <notmuch@notmuchmail.org>; Wed, 28 Apr 2010 11:06:30 -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 8RzJBXODz53d for <notmuch@notmuchmail.org>;\r
16         Wed, 28 Apr 2010 11:06:29 -0700 (PDT)\r
17 Received: from mail-ww0-f53.google.com (mail-ww0-f53.google.com\r
18  [74.125.82.53])        by olra.theworths.org (Postfix) with ESMTP id 3FEAA431FC1       for\r
19  <notmuch@notmuchmail.org>; Wed, 28 Apr 2010 11:06:29 -0700 (PDT)\r
20 Received: by wwe15 with SMTP id 15so141610wwe.26\r
21         for <notmuch@notmuchmail.org>; Wed, 28 Apr 2010 11:06:28 -0700 (PDT)\r
22 Received: by 10.216.159.141 with SMTP id s13mr4586390wek.64.1272477987149;\r
23         Wed, 28 Apr 2010 11:06:27 -0700 (PDT)\r
24 Received: from ut.hh.sledj.net (gmp-ea-fw-1b.sun.com [192.18.8.1])\r
25         by mx.google.com with ESMTPS id z34sm230022wbv.14.2010.04.28.11.06.25\r
26         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
27         Wed, 28 Apr 2010 11:06:25 -0700 (PDT)\r
28 Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
29         id 5318459411F; Wed, 28 Apr 2010 19:00:29 +0100 (BST)\r
30 From: David Edmondson <dme@dme.org>\r
31 To: notmuch@notmuchmail.org\r
32 Subject: [PATCH] emacs: Display non-matching authors in italic.\r
33 Date: Wed, 28 Apr 2010 19:00:27 +0100\r
34 Message-Id: <1272477627-10562-1-git-send-email-dme@dme.org>\r
35 X-Mailer: git-send-email 1.7.0\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.13\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40         <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Wed, 28 Apr 2010 18:06:30 -0000\r
49 \r
50 In search mode some messages don't match the search criteria. Show\r
51 their authors names in italic.\r
52 ---\r
53 \r
54 Whilst enjoying knowing which authors match, I disliked the pipe\r
55 symbol. This is a proposed improvement.\r
56 \r
57  emacs/notmuch.el |   24 +++++++++++++++++-------\r
58  1 files changed, 17 insertions(+), 7 deletions(-)\r
59 \r
60 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
61 index 7457da9..0a7a398 100644\r
62 --- a/emacs/notmuch.el\r
63 +++ b/emacs/notmuch.el\r
64 @@ -576,6 +576,22 @@ matching will be applied."\r
65                   (t\r
66                    (setq tags-faces (cdr tags-faces)))))))))\r
67  \r
68 +(defun notmuch-search-insert-authors (format-string authors)\r
69 +  (insert (let* ((formatted-sample (format format-string ""))\r
70 +                (formatted-authors (format format-string authors))\r
71 +                (truncated-string\r
72 +                 (if (> (length formatted-authors)\r
73 +                        (length formatted-sample))\r
74 +                     (concat (substring authors 0 (- (length formatted-sample) 4)) "... ")\r
75 +                   formatted-authors)))\r
76 +           ;; Need to save the match data to avoid interfering with\r
77 +           ;; `notmuch-search-process-filter'.\r
78 +           (save-match-data\r
79 +             (if (string-match "\\(.*\\)|\\(..*\\)" truncated-string)\r
80 +                 (concat (match-string 1 truncated-string) ","\r
81 +                         (propertize (match-string 2 truncated-string) 'face 'italic))\r
82 +               truncated-string)))))\r
83 +\r
84  (defun notmuch-search-insert-field (field date count authors subject tags)\r
85    (cond\r
86     ((string-equal field "date")\r
87 @@ -583,13 +599,7 @@ matching will be applied."\r
88     ((string-equal field "count")\r
89      (insert (format (cdr (assoc field notmuch-search-result-format)) count)))\r
90     ((string-equal field "authors")\r
91 -    (insert (let* ((format-string (cdr (assoc field notmuch-search-result-format)))\r
92 -                  (formatted-sample (format format-string ""))\r
93 -                  (formatted-authors (format format-string authors)))\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 +    (notmuch-search-insert-authors (cdr (assoc field notmuch-search-result-format)) authors))\r
99     ((string-equal field "subject")\r
100      (insert (format (cdr (assoc field notmuch-search-result-format)) subject)))\r
101     ((string-equal field "tags")\r
102 -- \r
103 1.7.0\r
104 \r