[PATCH v1 2/3] emacs: Improved display of matching/non-matching authors.
authorDavid Edmondson <dme@dme.org>
Fri, 24 Oct 2014 08:48:07 +0000 (09:48 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:05:35 +0000 (10:05 -0800)
d2/34409fde5049f030373f2f026851c658505b48 [new file with mode: 0644]

diff --git a/d2/34409fde5049f030373f2f026851c658505b48 b/d2/34409fde5049f030373f2f026851c658505b48
new file mode 100644 (file)
index 0000000..fe44ad6
--- /dev/null
@@ -0,0 +1,186 @@
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id B5477429E30\r
+       for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 01:48:25 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.699\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id QHrjmLQreUys for <notmuch@notmuchmail.org>;\r
+       Fri, 24 Oct 2014 01:48:21 -0700 (PDT)\r
+Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com\r
+       [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 7BF68429E25\r
+       for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 01:48:14 -0700 (PDT)\r
+Received: by mail-wi0-f174.google.com with SMTP id q5so680150wiv.7\r
+       for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 01:48:13 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:user-agent:from:to:subject:date:message-id\r
+       :in-reply-to:references;\r
+       bh=GlCgVuD8Rad5QeXkFhIKJQTsvMSQb7Gzj3WkwGCX/4w=;\r
+       b=d5hRQ/WUahdgrGcyhzENyyIsPCNL7zyyUh50k7fPckos26nIaSE198dWFqgmv5rE7r\r
+       QSpiLBPCrOXdtaApKQYPa7d5vekiQ81/nV4b9xJxs8KYQbtYFeMtre9R9ZktF17IH/mO\r
+       3RzfKzSU8qVJYymU8ACJWvlb+ffzXB3aiF3Wn7yI8ktPZzoNYLBjbBoGOmYFMDLX+t4d\r
+       dYDnxCo9R+za3zVmYZpkn0xnawcXuvfa4ttps4pdhcmikFBWS+jcG8itk0zNTTVnAjsU\r
+       FDsRzj1KtTAIXprk/40bPhzHqm0wisKHSjXYA8WRNTM/V9zIzZMGy0+uhoesL6I1mD+K\r
+       d+hw==\r
+X-Gm-Message-State:\r
+ ALoCoQkaRX9/MT0Iif7YuFkzNa3jW+yN1phY1iifATlykyGUWeyYGhNAwOpNlc5j/gGHYIy9t4/D\r
+X-Received: by 10.194.24.197 with SMTP id w5mr3163005wjf.71.1414140493293;\r
+       Fri, 24 Oct 2014 01:48:13 -0700 (PDT)\r
+Received: from disaster-area.hh.sledj.net\r
+       ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])\r
+       by mx.google.com with ESMTPSA id ee3sm1250679wic.4.2014.10.24.01.48.12\r
+       for <notmuch@notmuchmail.org>\r
+       (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+       Fri, 24 Oct 2014 01:48:12 -0700 (PDT)\r
+Received: from localhost (30000@localhost [local]);\r
+       by localhost (OpenSMTPD) with ESMTPA id 1170bf63;\r
+       for <notmuch@notmuchmail.org>; Fri, 24 Oct 2014 08:48:08 +0000 (UTC)\r
+User-Agent: OpenSMTPD enqueuer (Demoostik)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v1 2/3] emacs: Improved display of matching/non-matching\r
+       authors.\r
+Date: Fri, 24 Oct 2014 09:48:07 +0100\r
+Message-Id: <1414140488-29978-3-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 2.1.1\r
+In-Reply-To: <1414140488-29978-1-git-send-email-dme@dme.org>\r
+References: <1414140488-29978-1-git-send-email-dme@dme.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 24 Oct 2014 08:48:26 -0000\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 b44a907..29b6cdc 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -672,22 +672,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
+@@ -703,9 +705,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
+@@ -721,20 +723,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
+@@ -768,8 +773,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 (plist-get result :authors_matched))\r
++                                 (notmuch-sanitize (plist-get result :authors_non_matched))))\r
\r
+    ((string-equal field "tags")\r
+     (let ((tags (plist-get result :tags))\r
+-- \r
+2.1.1\r
+\r