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