Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 73 / 5eba1a2b10cf6f8afe123dfc69daa512ee0e6d
1 Return-Path: <markwalters1009@gmail.com>\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 arlo.cworth.org (Postfix) with ESMTP id 6D3396DE0FB0\r
6  for <notmuch@notmuchmail.org>; Mon, 14 Dec 2015 09:23:16 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.291\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.291 tagged_above=-999 required=5 tests=[AWL=0.279,\r
12   DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13  FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
15  autolearn=disabled\r
16 Received: from arlo.cworth.org ([127.0.0.1])\r
17  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
18  with ESMTP id fqzsqsyfQvnX for <notmuch@notmuchmail.org>;\r
19  Mon, 14 Dec 2015 09:23:14 -0800 (PST)\r
20 Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com\r
21  [74.125.82.48]) by arlo.cworth.org (Postfix) with ESMTPS id 714556DE0C81 for\r
22  <notmuch@notmuchmail.org>; Mon, 14 Dec 2015 09:23:11 -0800 (PST)\r
23 Received: by mail-wm0-f48.google.com with SMTP id n186so128391207wmn.1\r
24  for <notmuch@notmuchmail.org>; Mon, 14 Dec 2015 09:23:11 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26  h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
27  bh=PCa8grG5MiugKV644tQbvyLnhUZq1vMy9cG8O9yT69M=;\r
28  b=Ce2+mTcY6Mr6Y5VU5CtwZaqOGzgk1K0ST0GoQIhs6yhqpzysNfu+sLa9T7pkjAINH9\r
29  ZD2BNWPOKxlRL1OfY26urh5Szjlp7Rg7emKtbF4WXHtWolaFXaUQxc+4GAh5LcMtReBT\r
30  rBJ7w2EcxKWcr6meWGd7mbAXvl9//0hy79+XYSZA1YcEi9Tru5McefuC+RtvC/AKF7hP\r
31  4Oxnue5Fyqg71A/9R9zjHx6P1bIZLN6jr3DTVIl+Ej+B/LJJof6mr4Yo2r7ojRlu3D6v\r
32  YyGnAcz4gBrSlDMyQYZYDJ/5jt1vFdbw5PfT+z6VBQwveANogecQmBhAjgkcdBKOLMqx\r
33  NVuQ==\r
34 X-Received: by 10.28.65.69 with SMTP id o66mr23978797wma.18.1450113787777;\r
35  Mon, 14 Dec 2015 09:23:07 -0800 (PST)\r
36 Received: from localhost (92.40.77.76.threembb.co.uk. [92.40.77.76])\r
37  by smtp.gmail.com with ESMTPSA id h5sm30668485wjz.21.2015.12.14.09.23.04\r
38  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
39  Mon, 14 Dec 2015 09:23:06 -0800 (PST)\r
40 From: Mark Walters <markwalters1009@gmail.com>\r
41 To: notmuch@notmuchmail.org\r
42 Subject: [PATCH v2 (rebased) 2/3] emacs: Improved display of\r
43  matching/non-matching authors.\r
44 Date: Mon, 14 Dec 2015 17:22:45 +0000\r
45 Message-Id: <1450113766-20518-3-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 2.1.4\r
47 In-Reply-To: <1450113766-20518-1-git-send-email-markwalters1009@gmail.com>\r
48 References: <1450113766-20518-1-git-send-email-markwalters1009@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.20\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53  <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
55  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
60  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Mon, 14 Dec 2015 17:23:16 -0000\r
62 \r
63 From: David Edmondson <dme@dme.org>\r
64 \r
65 Rather than splitting the :authors attribute, which is error prone,\r
66 use the separate :authors_matched and :authors_non_matched attributes.\r
67 \r
68 This improves the display of authors should one of them include a pipe\r
69 symbol (|) in their 'from' address.\r
70 ---\r
71  emacs/notmuch.el | 64 +++++++++++++++++++++++++++++++-------------------------\r
72  1 file changed, 35 insertions(+), 29 deletions(-)\r
73 \r
74 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
75 index 463b926..1f4f6c3 100644\r
76 --- a/emacs/notmuch.el\r
77 +++ b/emacs/notmuch.el\r
78 @@ -674,22 +674,24 @@ foreground and blue background."\r
79         ;; Reverse the list so earlier entries take precedence\r
80         (reverse notmuch-search-line-faces)))\r
81  \r
82 -(defun notmuch-search-author-propertize (authors)\r
83 +(defun notmuch-search-author-propertize (authors matching-length)\r
84    "Split `authors' into matching and non-matching authors and\r
85  propertize appropriately. If no boundary between authors and\r
86  non-authors is found, assume that all of the authors match."\r
87 -  (if (string-match "\\(.*\\)|\\(.*\\)" authors)\r
88 -      (concat (propertize (concat (match-string 1 authors) ",")\r
89 -                         'face 'notmuch-search-matching-authors)\r
90 -             (propertize (match-string 2 authors)\r
91 -                         'face 'notmuch-search-non-matching-authors))\r
92 -    (propertize authors 'face 'notmuch-search-matching-authors)))\r
93 -\r
94 -(defun notmuch-search-insert-authors (format-string authors)\r
95 +  (let ((match-part (substring authors 0 matching-length))\r
96 +       (non-match-part (substring authors matching-length)))\r
97 +\r
98 +      (concat (propertize match-part 'face 'notmuch-search-matching-authors)\r
99 +             (propertize non-match-part 'face 'notmuch-search-non-matching-authors))))\r
100 +\r
101 +(defun notmuch-search-insert-authors (format-string matching-authors non-matching-authors)\r
102    ;; Save the match data to avoid interfering with\r
103    ;; `notmuch-search-process-filter'.\r
104    (save-match-data\r
105 -    (let* ((formatted-authors (format format-string authors))\r
106 +    (let* ((authors (if (string= "" non-matching-authors)\r
107 +                       matching-authors\r
108 +                     (concat matching-authors ", " non-matching-authors)))\r
109 +          (formatted-authors (format format-string authors))\r
110            (formatted-sample (format format-string ""))\r
111            (visible-string formatted-authors)\r
112            (invisible-string "")\r
113 @@ -705,9 +707,9 @@ non-authors is found, assume that all of the authors match."\r
114             (setq visible-string (substring formatted-authors 0 visible-length)\r
115                   invisible-string (substring formatted-authors visible-length))\r
116             ;; If possible, truncate the visible string at a natural\r
117 -           ;; break (comma or pipe), as incremental search doesn't\r
118 -           ;; match across the visible/invisible border.\r
119 -           (when (string-match "\\(.*\\)\\([,|] \\)\\([^,|]*\\)" visible-string)\r
120 +           ;; break (comma), as incremental search doesn't match\r
121 +           ;; across the visible/invisible border.\r
122 +           (when (string-match "\\(.*\\)\\(, \\)\\([^,]*\\)" visible-string)\r
123               ;; Second clause is destructive on `visible-string', so\r
124               ;; order is important.\r
125               (setq invisible-string (concat (match-string 3 visible-string)\r
126 @@ -723,20 +725,23 @@ non-authors is found, assume that all of the authors match."\r
127                                        ? ))))\r
128  \r
129        ;; Use different faces to show matching and non-matching authors.\r
130 -      (if (string-match "\\(.*\\)|\\(.*\\)" visible-string)\r
131 -         ;; The visible string contains both matching and\r
132 -         ;; non-matching authors.\r
133 -         (setq visible-string (notmuch-search-author-propertize visible-string)\r
134 -               ;; The invisible string must contain only non-matching\r
135 -               ;; authors, as the visible-string contains both.\r
136 -               invisible-string (propertize invisible-string\r
137 -                                            'face 'notmuch-search-non-matching-authors))\r
138 -       ;; The visible string contains only matching authors.\r
139 -       (setq visible-string (propertize visible-string\r
140 -                                        'face 'notmuch-search-matching-authors)\r
141 -             ;; The invisible string may contain both matching and\r
142 -             ;; non-matching authors.\r
143 -             invisible-string (notmuch-search-author-propertize invisible-string)))\r
144 +      (let ((visible-length (length visible-string))\r
145 +           (matching-length (length matching-authors)))\r
146 +\r
147 +       (if (> visible-length matching-length)\r
148 +           ;; The visible string contains both matching and\r
149 +           ;; non-matching authors.\r
150 +           (setq visible-string (notmuch-search-author-propertize visible-string matching-length)\r
151 +                 ;; The invisible string must contain only non-matching\r
152 +                 ;; authors, as the visible-string contains both.\r
153 +                 invisible-string (propertize invisible-string\r
154 +                                              'face 'notmuch-search-non-matching-authors))\r
155 +         ;; The visible string contains only matching authors.\r
156 +         (setq visible-string (propertize visible-string\r
157 +                                          'face 'notmuch-search-matching-authors)\r
158 +               ;; The invisible string may contain both matching and\r
159 +               ;; non-matching authors.\r
160 +               invisible-string (notmuch-search-author-propertize invisible-string (- visible-length matching-length)))))\r
161  \r
162        ;; If there is any invisible text, add it as a tooltip to the\r
163        ;; visible text.\r
164 @@ -770,8 +775,9 @@ non-authors is found, assume that all of the authors match."\r
165                         'face 'notmuch-search-subject)))\r
166  \r
167     ((string-equal field "authors")\r
168 -    (notmuch-search-insert-authors\r
169 -     format-string (notmuch-sanitize (plist-get result :authors))))\r
170 +    (notmuch-search-insert-authors format-string\r
171 +                                  (notmuch-sanitize (mapconcat 'identity (plist-get result :authors_matched) ", "))\r
172 +                                  (notmuch-sanitize (mapconcat 'identity (plist-get result :authors_non_matched) ", "))))\r
173  \r
174     ((string-equal field "tags")\r
175      (let ((tags (plist-get result :tags))\r
176 -- \r
177 2.1.4\r
178 \r