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 B5477429E30
\r
6 for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 01:48:25 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001]
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id QHrjmLQreUys for <notmuch@notmuchmail.org>;
\r
17 Fri, 24 Oct 2014 01:48:21 -0700 (PDT)
\r
18 Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com
\r
19 [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 7BF68429E25
\r
22 for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 01:48:14 -0700 (PDT)
\r
23 Received: by mail-wi0-f174.google.com with SMTP id q5so680150wiv.7
\r
24 for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 01:48:13 -0700 (PDT)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=1e100.net; s=20130820;
\r
27 h=x-gm-message-state:user-agent:from:to:subject:date:message-id
\r
28 :in-reply-to:references;
\r
29 bh=GlCgVuD8Rad5QeXkFhIKJQTsvMSQb7Gzj3WkwGCX/4w=;
\r
30 b=d5hRQ/WUahdgrGcyhzENyyIsPCNL7zyyUh50k7fPckos26nIaSE198dWFqgmv5rE7r
\r
31 QSpiLBPCrOXdtaApKQYPa7d5vekiQ81/nV4b9xJxs8KYQbtYFeMtre9R9ZktF17IH/mO
\r
32 3RzfKzSU8qVJYymU8ACJWvlb+ffzXB3aiF3Wn7yI8ktPZzoNYLBjbBoGOmYFMDLX+t4d
\r
33 dYDnxCo9R+za3zVmYZpkn0xnawcXuvfa4ttps4pdhcmikFBWS+jcG8itk0zNTTVnAjsU
\r
34 FDsRzj1KtTAIXprk/40bPhzHqm0wisKHSjXYA8WRNTM/V9zIzZMGy0+uhoesL6I1mD+K
\r
37 ALoCoQkaRX9/MT0Iif7YuFkzNa3jW+yN1phY1iifATlykyGUWeyYGhNAwOpNlc5j/gGHYIy9t4/D
\r
38 X-Received: by 10.194.24.197 with SMTP id w5mr3163005wjf.71.1414140493293;
\r
39 Fri, 24 Oct 2014 01:48:13 -0700 (PDT)
\r
40 Received: from disaster-area.hh.sledj.net
\r
41 ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])
\r
42 by mx.google.com with ESMTPSA id ee3sm1250679wic.4.2014.10.24.01.48.12
\r
43 for <notmuch@notmuchmail.org>
\r
44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
45 Fri, 24 Oct 2014 01:48:12 -0700 (PDT)
\r
46 Received: from localhost (30000@localhost [local]);
\r
47 by localhost (OpenSMTPD) with ESMTPA id 1170bf63;
\r
48 for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 08:48:08 +0000 (UTC)
\r
49 User-Agent: OpenSMTPD enqueuer (Demoostik)
\r
50 From: David Edmondson <dme@dme.org>
\r
51 To: notmuch@notmuchmail.org
\r
52 Subject: [PATCH v1 2/3] emacs: Improved display of matching/non-matching
\r
54 Date: Fri, 24 Oct 2014 09:48:07 +0100
\r
55 Message-Id: <1414140488-29978-3-git-send-email-dme@dme.org>
\r
56 X-Mailer: git-send-email 2.1.1
\r
57 In-Reply-To: <1414140488-29978-1-git-send-email-dme@dme.org>
\r
58 References: <1414140488-29978-1-git-send-email-dme@dme.org>
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Fri, 24 Oct 2014 08:48:26 -0000
\r
73 Rather than splitting the :authors attribute, which is error prone,
\r
74 use the separate :authors_matched and :authors_non_matched attributes.
\r
76 This improves the display of authors should one of them include a pipe
\r
77 symbol (|) in their 'from' address.
\r
79 emacs/notmuch.el | 64 +++++++++++++++++++++++++++++++-------------------------
\r
80 1 file changed, 35 insertions(+), 29 deletions(-)
\r
82 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
83 index b44a907..29b6cdc 100644
\r
84 --- a/emacs/notmuch.el
\r
85 +++ b/emacs/notmuch.el
\r
86 @@ -672,22 +672,24 @@ foreground and blue background."
\r
87 ;; Reverse the list so earlier entries take precedence
\r
88 (reverse notmuch-search-line-faces)))
\r
90 -(defun notmuch-search-author-propertize (authors)
\r
91 +(defun notmuch-search-author-propertize (authors matching-length)
\r
92 "Split `authors' into matching and non-matching authors and
\r
93 propertize appropriately. If no boundary between authors and
\r
94 non-authors is found, assume that all of the authors match."
\r
95 - (if (string-match "\\(.*\\)|\\(.*\\)" authors)
\r
96 - (concat (propertize (concat (match-string 1 authors) ",")
\r
97 - 'face 'notmuch-search-matching-authors)
\r
98 - (propertize (match-string 2 authors)
\r
99 - 'face 'notmuch-search-non-matching-authors))
\r
100 - (propertize authors 'face 'notmuch-search-matching-authors)))
\r
102 -(defun notmuch-search-insert-authors (format-string authors)
\r
103 + (let ((match-part (substring authors 0 matching-length))
\r
104 + (non-match-part (substring authors matching-length)))
\r
106 + (concat (propertize match-part 'face 'notmuch-search-matching-authors)
\r
107 + (propertize non-match-part 'face 'notmuch-search-non-matching-authors))))
\r
109 +(defun notmuch-search-insert-authors (format-string matching-authors non-matching-authors)
\r
110 ;; Save the match data to avoid interfering with
\r
111 ;; `notmuch-search-process-filter'.
\r
113 - (let* ((formatted-authors (format format-string authors))
\r
114 + (let* ((authors (if (string= "" non-matching-authors)
\r
116 + (concat matching-authors ", " non-matching-authors)))
\r
117 + (formatted-authors (format format-string authors))
\r
118 (formatted-sample (format format-string ""))
\r
119 (visible-string formatted-authors)
\r
120 (invisible-string "")
\r
121 @@ -703,9 +705,9 @@ non-authors is found, assume that all of the authors match."
\r
122 (setq visible-string (substring formatted-authors 0 visible-length)
\r
123 invisible-string (substring formatted-authors visible-length))
\r
124 ;; If possible, truncate the visible string at a natural
\r
125 - ;; break (comma or pipe), as incremental search doesn't
\r
126 - ;; match across the visible/invisible border.
\r
127 - (when (string-match "\\(.*\\)\\([,|] \\)\\([^,|]*\\)" visible-string)
\r
128 + ;; break (comma), as incremental search doesn't match
\r
129 + ;; across the visible/invisible border.
\r
130 + (when (string-match "\\(.*\\)\\(, \\)\\([^,]*\\)" visible-string)
\r
131 ;; Second clause is destructive on `visible-string', so
\r
132 ;; order is important.
\r
133 (setq invisible-string (concat (match-string 3 visible-string)
\r
134 @@ -721,20 +723,23 @@ non-authors is found, assume that all of the authors match."
\r
137 ;; Use different faces to show matching and non-matching authors.
\r
138 - (if (string-match "\\(.*\\)|\\(.*\\)" visible-string)
\r
139 - ;; The visible string contains both matching and
\r
140 - ;; non-matching authors.
\r
141 - (setq visible-string (notmuch-search-author-propertize visible-string)
\r
142 - ;; The invisible string must contain only non-matching
\r
143 - ;; authors, as the visible-string contains both.
\r
144 - invisible-string (propertize invisible-string
\r
145 - 'face 'notmuch-search-non-matching-authors))
\r
146 - ;; The visible string contains only matching authors.
\r
147 - (setq visible-string (propertize visible-string
\r
148 - 'face 'notmuch-search-matching-authors)
\r
149 - ;; The invisible string may contain both matching and
\r
150 - ;; non-matching authors.
\r
151 - invisible-string (notmuch-search-author-propertize invisible-string)))
\r
152 + (let ((visible-length (length visible-string))
\r
153 + (matching-length (length matching-authors)))
\r
155 + (if (> visible-length matching-length)
\r
156 + ;; The visible string contains both matching and
\r
157 + ;; non-matching authors.
\r
158 + (setq visible-string (notmuch-search-author-propertize visible-string matching-length)
\r
159 + ;; The invisible string must contain only non-matching
\r
160 + ;; authors, as the visible-string contains both.
\r
161 + invisible-string (propertize invisible-string
\r
162 + 'face 'notmuch-search-non-matching-authors))
\r
163 + ;; The visible string contains only matching authors.
\r
164 + (setq visible-string (propertize visible-string
\r
165 + 'face 'notmuch-search-matching-authors)
\r
166 + ;; The invisible string may contain both matching and
\r
167 + ;; non-matching authors.
\r
168 + invisible-string (notmuch-search-author-propertize invisible-string (- visible-length matching-length)))))
\r
170 ;; If there is any invisible text, add it as a tooltip to the
\r
172 @@ -768,8 +773,9 @@ non-authors is found, assume that all of the authors match."
\r
173 'face 'notmuch-search-subject)))
\r
175 ((string-equal field "authors")
\r
176 - (notmuch-search-insert-authors
\r
177 - format-string (notmuch-sanitize (plist-get result :authors))))
\r
178 + (notmuch-search-insert-authors format-string
\r
179 + (notmuch-sanitize (plist-get result :authors_matched))
\r
180 + (notmuch-sanitize (plist-get result :authors_non_matched))))
\r
182 ((string-equal field "tags")
\r
183 (let ((tags (plist-get result :tags))
\r