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 CBEDA409C81
\r
6 for <notmuch@notmuchmail.org>; Wed, 19 May 2010 01:54:36 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] 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 0MGO6aajkMqi for <notmuch@notmuchmail.org>;
\r
16 Wed, 19 May 2010 01:54:22 -0700 (PDT)
\r
17 Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com
\r
19 by olra.theworths.org (Postfix) with ESMTP id 26BD8418C38
\r
20 for <notmuch@notmuchmail.org>; Wed, 19 May 2010 01:53:46 -0700 (PDT)
\r
21 Received: by ewy5 with SMTP id 5so1814160ewy.0
\r
22 for <notmuch@notmuchmail.org>; Wed, 19 May 2010 01:53:43 -0700 (PDT)
\r
23 Received: by 10.213.41.131 with SMTP id o3mr3248660ebe.68.1274259222929;
\r
24 Wed, 19 May 2010 01:53:42 -0700 (PDT)
\r
25 Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com
\r
27 by mx.google.com with ESMTPS id 16sm3519150ewy.7.2010.05.19.01.53.38
\r
28 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
29 Wed, 19 May 2010 01:53:39 -0700 (PDT)
\r
30 Received: by ut.hh.sledj.net (Postfix, from userid 1000)
\r
31 id B81505940B1; Wed, 19 May 2010 08:03:45 +0100 (BST)
\r
32 From: David Edmondson <dme@dme.org>
\r
33 To: notmuch@notmuchmail.org
\r
34 Subject: [PATCH 10/13] emacs: In search mode,
\r
35 truncate authors using invisible text.
\r
36 Date: Wed, 19 May 2010 08:03:37 +0100
\r
37 Message-Id: <1274252620-1249-11-git-send-email-dme@dme.org>
\r
38 X-Mailer: git-send-email 1.7.1
\r
39 In-Reply-To: <1274252620-1249-1-git-send-email-dme@dme.org>
\r
40 References: <1274252620-1249-1-git-send-email-dme@dme.org>
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Wed, 19 May 2010 08:54:37 -0000
\r
55 Rather than discarding authors when truncated to fit the defined
\r
56 column width, mark the text beyond the end of the column as invisible
\r
57 and allow `isearch' to be used over the text so hidden.
\r
59 This allows us to retain the compact display whilst enabling a user to
\r
60 find the elided text.
\r
62 emacs/notmuch.el | 61 +++++++++++++++++++++++++++++++++++++++--------------
\r
63 1 files changed, 45 insertions(+), 16 deletions(-)
\r
65 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
66 index c2fefe5..10babe4 100644
\r
67 --- a/emacs/notmuch.el
\r
68 +++ b/emacs/notmuch.el
\r
69 @@ -608,23 +608,52 @@ matching will be applied."
\r
71 (setq tags-faces (cdr tags-faces)))))))))
\r
73 +(defun notmuch-search-isearch-authors-show (overlay)
\r
74 + (remove-from-invisibility-spec (cons (overlay-get overlay 'invisible) t)))
\r
76 (defun notmuch-search-insert-authors (format-string authors)
\r
77 - (insert (let* ((formatted-sample (format format-string ""))
\r
78 - (formatted-authors (format format-string authors))
\r
80 - (if (> (length formatted-authors)
\r
81 - (length formatted-sample))
\r
82 - (concat (substring authors 0 (- (length formatted-sample) 4)) "... ")
\r
83 - formatted-authors)))
\r
84 - ;; Need to save the match data to avoid interfering with
\r
85 - ;; `notmuch-search-process-filter'.
\r
87 - (if (string-match "\\(.*\\)|\\(..*\\)" truncated-string)
\r
88 - (concat (propertize (concat (match-string 1 truncated-string) ",")
\r
89 - 'face 'notmuch-search-matching-authors)
\r
90 - (propertize (match-string 2 truncated-string)
\r
91 - 'face 'notmuch-search-non-matching-authors))
\r
92 - (propertize truncated-string 'face 'notmuch-search-matching-authors))))))
\r
93 + (let* ((propertized-authors
\r
94 + ;; Need to save the match data to avoid interfering with
\r
95 + ;; `notmuch-search-process-filter'.
\r
97 + ;; Authors that don't match the search query are shown in a
\r
98 + ;; different font.
\r
99 + (if (string-match "\\(.*\\)|\\(..*\\)" authors)
\r
100 + (concat (propertize (concat (match-string 1 authors) ",")
\r
101 + 'face 'notmuch-search-matching-authors)
\r
102 + (propertize (match-string 2 authors)
\r
103 + 'face 'notmuch-search-non-matching-authors))
\r
104 + (propertize authors 'face 'notmuch-search-matching-authors))))
\r
106 + (formatted-sample (format format-string ""))
\r
107 + (formatted-authors (format format-string propertized-authors))
\r
108 + visible-string invisible-string)
\r
110 + ;; Determine the part of the authors that will be visible by
\r
112 + (if (> (length formatted-authors)
\r
113 + (length formatted-sample))
\r
114 + ;; 4 is `(length "... ")'.
\r
115 + (let ((visible-length (- (length formatted-sample) 4)))
\r
116 + (setq visible-string (substring propertized-authors 0 visible-length)
\r
117 + invisible-string (substring propertized-authors visible-length)))
\r
118 + (setq visible-string formatted-authors
\r
119 + invisible-string nil))
\r
121 + ;; Insert both the visible and invisible author strings.
\r
122 + (insert visible-string)
\r
123 + (when invisible-string
\r
124 + (let ((start (point))
\r
125 + (invis-spec (make-symbol "notmuch-search-authors"))
\r
127 + (insert invisible-string)
\r
128 + ;; Using a cons-cell here causes an ellipsis to be inserted
\r
129 + ;; instead of the invisible text.
\r
130 + (add-to-invisibility-spec (cons invis-spec t))
\r
131 + (setq overlay (make-overlay start (point)))
\r
132 + (overlay-put overlay 'invisible invis-spec)
\r
133 + (overlay-put overlay 'isearch-open-invisible #'notmuch-search-isearch-authors-show)
\r
136 (defun notmuch-search-insert-field (field date count authors subject tags)
\r