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 B3D53431FB6
\r
6 for <notmuch@notmuchmail.org>; Mon, 19 Jan 2015 01:18:24 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=1.739 tagged_above=-999 required=5
\r
12 tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7,
\r
13 UNPARSEABLE_RELAY=0.001] autolearn=disabled
\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 HEWAdpCx3JAm for <notmuch@notmuchmail.org>;
\r
17 Mon, 19 Jan 2015 01:18:20 -0800 (PST)
\r
18 Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com
\r
19 [74.125.82.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
20 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
21 8D919431FAF for <notmuch@notmuchmail.org>; Mon, 19 Jan 2015 01:18:20 -0800
\r
23 Received: by mail-wg0-f46.google.com with SMTP id x13so30543023wgg.5
\r
24 for <notmuch@notmuchmail.org>; Mon, 19 Jan 2015 01:18:19 -0800 (PST)
\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:to:subject:in-reply-to:references:user-agent
\r
28 :from:date:message-id:mime-version:content-type;
\r
29 bh=HKb+HJljNoXJ1QUmT5l46+3GC5UqXzw/Ix06XYznn/s=;
\r
30 b=Py3AuPHcYPYDB5JTeGskQm1DnLeN7u9LLCRj8ff8aOHhKjJI/c2PkX6+BVIVmOSVQA
\r
31 /iWEF5treYSXBY+x2lxM+9x4tS3hobsILTS+YOnIxfLKy74j8Ta5Y401c+IVMO3Zf/kS
\r
32 mfGXhhgxXSOk2eN9c8y+EuOhTSfn3fsvEWmLzy698hnBMiO2Fnlikrc5wwojjtNwVhI6
\r
33 KW8eRDc8Hs3PLIpFkq81gOj1/eHorRsfJji4Q46zZjWFQq7MH3WkzjZchBmZ5lsuKS2A
\r
34 ZYarR0GSBeImG+i9ylMlOMVWofG5+yvMqnMQxpuGxER6MeXaY/310OlBlk6+Ysz1ciSD
\r
37 ALoCoQns778PiErCnuJ1/XBtyuy19rQebE8VV3uNCOQ2JPiVC+deoaZoFhzR/bB9askp4gkUH7G/
\r
38 X-Received: by 10.180.228.72 with SMTP id sg8mr33561156wic.48.1421659099365;
\r
39 Mon, 19 Jan 2015 01:18:19 -0800 (PST)
\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 fp2sm13419444wib.8.2015.01.19.01.18.18
\r
43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
44 Mon, 19 Jan 2015 01:18:18 -0800 (PST)
\r
45 Received: from localhost (30000@localhost [local]);
\r
46 by localhost (OpenSMTPD) with ESMTPA id d2b51c17;
\r
47 Mon, 19 Jan 2015 09:18:17 +0000 (UTC)
\r
48 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
\r
49 Subject: Re: [PATCH v2 2/3] emacs: Improved display of
\r
50 matching/non-matching authors.
\r
51 In-Reply-To: <87oapwj6xg.fsf@qmul.ac.uk>
\r
52 References: <1414172643-28270-1-git-send-email-dme@dme.org>
\r
53 <1414172643-28270-3-git-send-email-dme@dme.org>
\r
54 <87oapwj6xg.fsf@qmul.ac.uk>
\r
56 From: David Edmondson <dme@dme.org>
\r
57 Date: Mon, 19 Jan 2015 09:18:17 +0000
\r
58 Message-ID: <cund26bku1y.fsf@gargravarr.hh.sledj.net>
\r
60 Content-Type: text/plain
\r
61 X-BeenThere: notmuch@notmuchmail.org
\r
62 X-Mailman-Version: 2.1.13
\r
64 List-Id: "Use and development of the notmuch mail system."
\r
65 <notmuch.notmuchmail.org>
\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
69 List-Post: <mailto:notmuch@notmuchmail.org>
\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
73 X-List-Received-Date: Mon, 19 Jan 2015 09:18:24 -0000
\r
75 On Sun, Jan 18 2015, Mark Walters wrote:
\r
76 > On Fri, 24 Oct 2014, David Edmondson <dme@dme.org> wrote:
\r
77 >> Rather than splitting the :authors attribute, which is error prone,
\r
78 >> use the separate :authors_matched and :authors_non_matched attributes.
\r
80 >> This improves the display of authors should one of them include a pipe
\r
81 >> symbol (|) in their 'from' address.
\r
85 > I haven't fully understood this code yet: do you need to join the
\r
86 > matching and non-matching authors and then split again for propertizing?
\r
87 > It feels like it would be nicer to keep them separate and only combine
\r
90 > Does this all get nicer with your formatting search results series?
\r
92 Yes. I tried re-writing this code to use the already split authors here,
\r
93 but given that I was going to re-write it for the formatting changes
\r
103 >> emacs/notmuch.el | 64 +++++++++++++++++++++++++++++++-------------------------
\r
104 >> 1 file changed, 35 insertions(+), 29 deletions(-)
\r
106 >> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
107 >> index b44a907..688b37c 100644
\r
108 >> --- a/emacs/notmuch.el
\r
109 >> +++ b/emacs/notmuch.el
\r
110 >> @@ -672,22 +672,24 @@ foreground and blue background."
\r
111 >> ;; Reverse the list so earlier entries take precedence
\r
112 >> (reverse notmuch-search-line-faces)))
\r
114 >> -(defun notmuch-search-author-propertize (authors)
\r
115 >> +(defun notmuch-search-author-propertize (authors matching-length)
\r
116 >> "Split `authors' into matching and non-matching authors and
\r
117 >> propertize appropriately. If no boundary between authors and
\r
118 >> non-authors is found, assume that all of the authors match."
\r
119 >> - (if (string-match "\\(.*\\)|\\(.*\\)" authors)
\r
120 >> - (concat (propertize (concat (match-string 1 authors) ",")
\r
121 >> - 'face 'notmuch-search-matching-authors)
\r
122 >> - (propertize (match-string 2 authors)
\r
123 >> - 'face 'notmuch-search-non-matching-authors))
\r
124 >> - (propertize authors 'face 'notmuch-search-matching-authors)))
\r
126 >> -(defun notmuch-search-insert-authors (format-string authors)
\r
127 >> + (let ((match-part (substring authors 0 matching-length))
\r
128 >> + (non-match-part (substring authors matching-length)))
\r
130 >> + (concat (propertize match-part 'face 'notmuch-search-matching-authors)
\r
131 >> + (propertize non-match-part 'face 'notmuch-search-non-matching-authors))))
\r
133 >> +(defun notmuch-search-insert-authors (format-string matching-authors non-matching-authors)
\r
134 >> ;; Save the match data to avoid interfering with
\r
135 >> ;; `notmuch-search-process-filter'.
\r
136 >> (save-match-data
\r
137 >> - (let* ((formatted-authors (format format-string authors))
\r
138 >> + (let* ((authors (if (string= "" non-matching-authors)
\r
139 >> + matching-authors
\r
140 >> + (concat matching-authors ", " non-matching-authors)))
\r
141 >> + (formatted-authors (format format-string authors))
\r
142 >> (formatted-sample (format format-string ""))
\r
143 >> (visible-string formatted-authors)
\r
144 >> (invisible-string "")
\r
145 >> @@ -703,9 +705,9 @@ non-authors is found, assume that all of the authors match."
\r
146 >> (setq visible-string (substring formatted-authors 0 visible-length)
\r
147 >> invisible-string (substring formatted-authors visible-length))
\r
148 >> ;; If possible, truncate the visible string at a natural
\r
149 >> - ;; break (comma or pipe), as incremental search doesn't
\r
150 >> - ;; match across the visible/invisible border.
\r
151 >> - (when (string-match "\\(.*\\)\\([,|] \\)\\([^,|]*\\)" visible-string)
\r
152 >> + ;; break (comma), as incremental search doesn't match
\r
153 >> + ;; across the visible/invisible border.
\r
154 >> + (when (string-match "\\(.*\\)\\(, \\)\\([^,]*\\)" visible-string)
\r
155 >> ;; Second clause is destructive on `visible-string', so
\r
156 >> ;; order is important.
\r
157 >> (setq invisible-string (concat (match-string 3 visible-string)
\r
158 >> @@ -721,20 +723,23 @@ non-authors is found, assume that all of the authors match."
\r
161 >> ;; Use different faces to show matching and non-matching authors.
\r
162 >> - (if (string-match "\\(.*\\)|\\(.*\\)" visible-string)
\r
163 >> - ;; The visible string contains both matching and
\r
164 >> - ;; non-matching authors.
\r
165 >> - (setq visible-string (notmuch-search-author-propertize visible-string)
\r
166 >> - ;; The invisible string must contain only non-matching
\r
167 >> - ;; authors, as the visible-string contains both.
\r
168 >> - invisible-string (propertize invisible-string
\r
169 >> - 'face 'notmuch-search-non-matching-authors))
\r
170 >> - ;; The visible string contains only matching authors.
\r
171 >> - (setq visible-string (propertize visible-string
\r
172 >> - 'face 'notmuch-search-matching-authors)
\r
173 >> - ;; The invisible string may contain both matching and
\r
174 >> - ;; non-matching authors.
\r
175 >> - invisible-string (notmuch-search-author-propertize invisible-string)))
\r
176 >> + (let ((visible-length (length visible-string))
\r
177 >> + (matching-length (length matching-authors)))
\r
179 >> + (if (> visible-length matching-length)
\r
180 >> + ;; The visible string contains both matching and
\r
181 >> + ;; non-matching authors.
\r
182 >> + (setq visible-string (notmuch-search-author-propertize visible-string matching-length)
\r
183 >> + ;; The invisible string must contain only non-matching
\r
184 >> + ;; authors, as the visible-string contains both.
\r
185 >> + invisible-string (propertize invisible-string
\r
186 >> + 'face 'notmuch-search-non-matching-authors))
\r
187 >> + ;; The visible string contains only matching authors.
\r
188 >> + (setq visible-string (propertize visible-string
\r
189 >> + 'face 'notmuch-search-matching-authors)
\r
190 >> + ;; The invisible string may contain both matching and
\r
191 >> + ;; non-matching authors.
\r
192 >> + invisible-string (notmuch-search-author-propertize invisible-string (- visible-length matching-length)))))
\r
194 >> ;; If there is any invisible text, add it as a tooltip to the
\r
195 >> ;; visible text.
\r
196 >> @@ -768,8 +773,9 @@ non-authors is found, assume that all of the authors match."
\r
197 >> 'face 'notmuch-search-subject)))
\r
199 >> ((string-equal field "authors")
\r
200 >> - (notmuch-search-insert-authors
\r
201 >> - format-string (notmuch-sanitize (plist-get result :authors))))
\r
202 >> + (notmuch-search-insert-authors format-string
\r
203 >> + (notmuch-sanitize (mapconcat 'identity (plist-get result :authors_matched) ", "))
\r
204 >> + (notmuch-sanitize (mapconcat 'identity (plist-get result :authors_non_matched) ", "))))
\r
206 >> ((string-equal field "tags")
\r
207 >> (let ((tags (plist-get result :tags))
\r
211 >> _______________________________________________
\r
212 >> notmuch mailing list
\r
213 >> notmuch@notmuchmail.org
\r
214 >> http://notmuchmail.org/mailman/listinfo/notmuch
\r