[PATCH v2 (rebased) 2/3] emacs: Improved display of matching/non-matching authors.
authorMark Walters <markwalters1009@gmail.com>
Mon, 14 Dec 2015 17:22:45 +0000 (17:22 +0000)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:50:13 +0000 (14:50 -0700)
73/5eba1a2b10cf6f8afe123dfc69daa512ee0e6d [new file with mode: 0644]

diff --git a/73/5eba1a2b10cf6f8afe123dfc69daa512ee0e6d b/73/5eba1a2b10cf6f8afe123dfc69daa512ee0e6d
new file mode 100644 (file)
index 0000000..f87640c
--- /dev/null
@@ -0,0 +1,178 @@
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 6D3396DE0FB0\r
+ for <notmuch@notmuchmail.org>; Mon, 14 Dec 2015 09:23:16 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.291\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.291 tagged_above=-999 required=5 tests=[AWL=0.279,\r
+  DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id fqzsqsyfQvnX for <notmuch@notmuchmail.org>;\r
+ Mon, 14 Dec 2015 09:23:14 -0800 (PST)\r
+Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com\r
+ [74.125.82.48]) by arlo.cworth.org (Postfix) with ESMTPS id 714556DE0C81 for\r
+ <notmuch@notmuchmail.org>; Mon, 14 Dec 2015 09:23:11 -0800 (PST)\r
+Received: by mail-wm0-f48.google.com with SMTP id n186so128391207wmn.1\r
+ for <notmuch@notmuchmail.org>; Mon, 14 Dec 2015 09:23:11 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=PCa8grG5MiugKV644tQbvyLnhUZq1vMy9cG8O9yT69M=;\r
+ b=Ce2+mTcY6Mr6Y5VU5CtwZaqOGzgk1K0ST0GoQIhs6yhqpzysNfu+sLa9T7pkjAINH9\r
+ ZD2BNWPOKxlRL1OfY26urh5Szjlp7Rg7emKtbF4WXHtWolaFXaUQxc+4GAh5LcMtReBT\r
+ rBJ7w2EcxKWcr6meWGd7mbAXvl9//0hy79+XYSZA1YcEi9Tru5McefuC+RtvC/AKF7hP\r
+ 4Oxnue5Fyqg71A/9R9zjHx6P1bIZLN6jr3DTVIl+Ej+B/LJJof6mr4Yo2r7ojRlu3D6v\r
+ YyGnAcz4gBrSlDMyQYZYDJ/5jt1vFdbw5PfT+z6VBQwveANogecQmBhAjgkcdBKOLMqx\r
+ NVuQ==\r
+X-Received: by 10.28.65.69 with SMTP id o66mr23978797wma.18.1450113787777;\r
+ Mon, 14 Dec 2015 09:23:07 -0800 (PST)\r
+Received: from localhost (92.40.77.76.threembb.co.uk. [92.40.77.76])\r
+ by smtp.gmail.com with ESMTPSA id h5sm30668485wjz.21.2015.12.14.09.23.04\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Mon, 14 Dec 2015 09:23:06 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 (rebased) 2/3] emacs: Improved display of\r
+ matching/non-matching authors.\r
+Date: Mon, 14 Dec 2015 17:22:45 +0000\r
+Message-Id: <1450113766-20518-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1450113766-20518-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1450113766-20518-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 14 Dec 2015 17:23:16 -0000\r
+\r
+From: David Edmondson <dme@dme.org>\r
+\r
+Rather than splitting the :authors attribute, which is error prone,\r
+use the separate :authors_matched and :authors_non_matched attributes.\r
+\r
+This improves the display of authors should one of them include a pipe\r
+symbol (|) in their 'from' address.\r
+---\r
+ emacs/notmuch.el | 64 +++++++++++++++++++++++++++++++-------------------------\r
+ 1 file changed, 35 insertions(+), 29 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 463b926..1f4f6c3 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -674,22 +674,24 @@ foreground and blue background."\r
+       ;; Reverse the list so earlier entries take precedence\r
+       (reverse notmuch-search-line-faces)))\r
\r
+-(defun notmuch-search-author-propertize (authors)\r
++(defun notmuch-search-author-propertize (authors matching-length)\r
+   "Split `authors' into matching and non-matching authors and\r
+ propertize appropriately. If no boundary between authors and\r
+ non-authors is found, assume that all of the authors match."\r
+-  (if (string-match "\\(.*\\)|\\(.*\\)" authors)\r
+-      (concat (propertize (concat (match-string 1 authors) ",")\r
+-                        'face 'notmuch-search-matching-authors)\r
+-            (propertize (match-string 2 authors)\r
+-                        'face 'notmuch-search-non-matching-authors))\r
+-    (propertize authors 'face 'notmuch-search-matching-authors)))\r
+-\r
+-(defun notmuch-search-insert-authors (format-string authors)\r
++  (let ((match-part (substring authors 0 matching-length))\r
++      (non-match-part (substring authors matching-length)))\r
++\r
++      (concat (propertize match-part 'face 'notmuch-search-matching-authors)\r
++            (propertize non-match-part 'face 'notmuch-search-non-matching-authors))))\r
++\r
++(defun notmuch-search-insert-authors (format-string matching-authors non-matching-authors)\r
+   ;; Save the match data to avoid interfering with\r
+   ;; `notmuch-search-process-filter'.\r
+   (save-match-data\r
+-    (let* ((formatted-authors (format format-string authors))\r
++    (let* ((authors (if (string= "" non-matching-authors)\r
++                      matching-authors\r
++                    (concat matching-authors ", " non-matching-authors)))\r
++         (formatted-authors (format format-string authors))\r
+          (formatted-sample (format format-string ""))\r
+          (visible-string formatted-authors)\r
+          (invisible-string "")\r
+@@ -705,9 +707,9 @@ non-authors is found, assume that all of the authors match."\r
+           (setq visible-string (substring formatted-authors 0 visible-length)\r
+                 invisible-string (substring formatted-authors visible-length))\r
+           ;; If possible, truncate the visible string at a natural\r
+-          ;; break (comma or pipe), as incremental search doesn't\r
+-          ;; match across the visible/invisible border.\r
+-          (when (string-match "\\(.*\\)\\([,|] \\)\\([^,|]*\\)" visible-string)\r
++          ;; break (comma), as incremental search doesn't match\r
++          ;; across the visible/invisible border.\r
++          (when (string-match "\\(.*\\)\\(, \\)\\([^,]*\\)" visible-string)\r
+             ;; Second clause is destructive on `visible-string', so\r
+             ;; order is important.\r
+             (setq invisible-string (concat (match-string 3 visible-string)\r
+@@ -723,20 +725,23 @@ non-authors is found, assume that all of the authors match."\r
+                                      ? ))))\r
\r
+       ;; Use different faces to show matching and non-matching authors.\r
+-      (if (string-match "\\(.*\\)|\\(.*\\)" visible-string)\r
+-        ;; The visible string contains both matching and\r
+-        ;; non-matching authors.\r
+-        (setq visible-string (notmuch-search-author-propertize visible-string)\r
+-              ;; The invisible string must contain only non-matching\r
+-              ;; authors, as the visible-string contains both.\r
+-              invisible-string (propertize invisible-string\r
+-                                           'face 'notmuch-search-non-matching-authors))\r
+-      ;; The visible string contains only matching authors.\r
+-      (setq visible-string (propertize visible-string\r
+-                                       'face 'notmuch-search-matching-authors)\r
+-            ;; The invisible string may contain both matching and\r
+-            ;; non-matching authors.\r
+-            invisible-string (notmuch-search-author-propertize invisible-string)))\r
++      (let ((visible-length (length visible-string))\r
++          (matching-length (length matching-authors)))\r
++\r
++      (if (> visible-length matching-length)\r
++          ;; The visible string contains both matching and\r
++          ;; non-matching authors.\r
++          (setq visible-string (notmuch-search-author-propertize visible-string matching-length)\r
++                ;; The invisible string must contain only non-matching\r
++                ;; authors, as the visible-string contains both.\r
++                invisible-string (propertize invisible-string\r
++                                             'face 'notmuch-search-non-matching-authors))\r
++        ;; The visible string contains only matching authors.\r
++        (setq visible-string (propertize visible-string\r
++                                         'face 'notmuch-search-matching-authors)\r
++              ;; The invisible string may contain both matching and\r
++              ;; non-matching authors.\r
++              invisible-string (notmuch-search-author-propertize invisible-string (- visible-length matching-length)))))\r
\r
+       ;; If there is any invisible text, add it as a tooltip to the\r
+       ;; visible text.\r
+@@ -770,8 +775,9 @@ non-authors is found, assume that all of the authors match."\r
+                       'face 'notmuch-search-subject)))\r
\r
+    ((string-equal field "authors")\r
+-    (notmuch-search-insert-authors\r
+-     format-string (notmuch-sanitize (plist-get result :authors))))\r
++    (notmuch-search-insert-authors format-string\r
++                                 (notmuch-sanitize (mapconcat 'identity (plist-get result :authors_matched) ", "))\r
++                                 (notmuch-sanitize (mapconcat 'identity (plist-get result :authors_non_matched) ", "))))\r
\r
+    ((string-equal field "tags")\r
+     (let ((tags (plist-get result :tags))\r
+-- \r
+2.1.4\r
+\r