[PATCH 1/2] emacs: Display non-matching authors with a different face.
authorDavid Edmondson <dme@dme.org>
Thu, 29 Apr 2010 06:52:22 +0000 (07:52 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:00 +0000 (09:37 -0800)
9a/47405c34100883220ed9885293093f871222ee [new file with mode: 0644]

diff --git a/9a/47405c34100883220ed9885293093f871222ee b/9a/47405c34100883220ed9885293093f871222ee
new file mode 100644 (file)
index 0000000..8e899cb
--- /dev/null
@@ -0,0 +1,127 @@
+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 CCA834196F2\r
+       for <notmuch@notmuchmail.org>; Wed, 28 Apr 2010 23:52:08 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9] autolearn=ham\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 l3vrAqomkSqW for <notmuch@notmuchmail.org>;\r
+       Wed, 28 Apr 2010 23:52:07 -0700 (PDT)\r
+Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
+       [74.125.82.181])\r
+       by olra.theworths.org (Postfix) with ESMTP id 41E7A431FC1\r
+       for <notmuch@notmuchmail.org>; Wed, 28 Apr 2010 23:52:07 -0700 (PDT)\r
+Received: by wyj26 with SMTP id 26so2828306wyj.26\r
+       for <notmuch@notmuchmail.org>; Wed, 28 Apr 2010 23:52:06 -0700 (PDT)\r
+Received: by 10.216.161.68 with SMTP id v46mr3733816wek.107.1272523926336;\r
+       Wed, 28 Apr 2010 23:52:06 -0700 (PDT)\r
+Received: from ut.hh.sledj.net (gmp-ea-fw-1b.sun.com [192.18.8.1])\r
+       by mx.google.com with ESMTPS id x1sm4781291wbx.19.2010.04.28.23.52.04\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Wed, 28 Apr 2010 23:52:05 -0700 (PDT)\r
+Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
+       id 1D64959411F; Thu, 29 Apr 2010 07:52:25 +0100 (BST)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/2] emacs: Display non-matching authors with a different\r
+ face.\r
+Date: Thu, 29 Apr 2010 07:52:22 +0100\r
+Message-Id: <1272523943-25588-1-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.0\r
+In-Reply-To: <1272477627-10562-1-git-send-email-dme@dme.org>\r
+References: <1272477627-10562-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: Thu, 29 Apr 2010 06:52:09 -0000\r
+\r
+In search mode some messages don't match the search criteria. Show\r
+their authors names with a different face - generally darker than\r
+those that do match.\r
+---\r
+\r
+At Sebastian's request, allow the face to be customised.\r
+\r
+ emacs/notmuch.el |   36 +++++++++++++++++++++++++++++-------\r
+ 1 files changed, 29 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 7457da9..60c0ee5 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -297,6 +297,17 @@ For a mouse binding, return nil."\r
+   "Notmuch search mode face used to highligh tags."\r
+   :group 'notmuch)\r
\r
++(defface notmuch-search-non-matching-authors\r
++  '((((class color)\r
++      (background dark))\r
++     (:foreground "grey30"))\r
++    (((class color)\r
++      (background light))\r
++     (:foreground "grey60"))\r
++    (t (:italic t)))\r
++  "Face used in search mode for authors not matching the query."\r
++  :group 'notmuch)\r
++\r
+ ;;;###autoload\r
+ (defun notmuch-search-mode ()\r
+   "Major mode displaying results of a notmuch search.\r
+@@ -576,6 +587,23 @@ matching will be applied."\r
+                 (t\r
+                  (setq tags-faces (cdr tags-faces)))))))))\r
\r
++(defun notmuch-search-insert-authors (format-string authors)\r
++  (insert (let* ((formatted-sample (format format-string ""))\r
++               (formatted-authors (format format-string authors))\r
++               (truncated-string\r
++                (if (> (length formatted-authors)\r
++                       (length formatted-sample))\r
++                    (concat (substring authors 0 (- (length formatted-sample) 4)) "... ")\r
++                  formatted-authors)))\r
++          ;; Need to save the match data to avoid interfering with\r
++          ;; `notmuch-search-process-filter'.\r
++          (save-match-data\r
++            (if (string-match "\\(.*\\)|\\(..*\\)" truncated-string)\r
++                (concat (match-string 1 truncated-string) ","\r
++                        (propertize (match-string 2 truncated-string)\r
++                                    'face 'notmuch-search-non-matching-authors))\r
++              truncated-string)))))\r
++\r
+ (defun notmuch-search-insert-field (field date count authors subject tags)\r
+   (cond\r
+    ((string-equal field "date")\r
+@@ -583,13 +611,7 @@ matching will be applied."\r
+    ((string-equal field "count")\r
+     (insert (format (cdr (assoc field notmuch-search-result-format)) count)))\r
+    ((string-equal field "authors")\r
+-    (insert (let* ((format-string (cdr (assoc field notmuch-search-result-format)))\r
+-                 (formatted-sample (format format-string ""))\r
+-                 (formatted-authors (format format-string authors)))\r
+-            (if (> (length formatted-authors)\r
+-                   (length formatted-sample))\r
+-                (concat (substring authors 0 (- (length formatted-sample) 4)) "... ")\r
+-              formatted-authors))))\r
++    (notmuch-search-insert-authors (cdr (assoc field notmuch-search-result-format)) authors))\r
+    ((string-equal field "subject")\r
+     (insert (format (cdr (assoc field notmuch-search-result-format)) subject)))\r
+    ((string-equal field "tags")\r
+-- \r
+1.7.0\r
+\r