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 41DC9431FAF for ; Mon, 16 Jan 2012 08:59:28 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled 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 5EWhIKv30WKX for ; Mon, 16 Jan 2012 08:59:27 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 8B04B431FAE for ; Mon, 16 Jan 2012 08:59:27 -0800 (PST) Received: by wibhr12 with SMTP id hr12so2632349wib.26 for ; Mon, 16 Jan 2012 08:59:26 -0800 (PST) Received: by 10.180.88.229 with SMTP id bj5mr21773950wib.5.1326733166316; Mon, 16 Jan 2012 08:59:26 -0800 (PST) Received: from localhost ([109.131.75.86]) by mx.google.com with ESMTPS id fi6sm35082784wib.2.2012.01.16.08.59.25 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jan 2012 08:59:25 -0800 (PST) From: Pieter Praet To: David Edmondson , Jameson Graef Rollins Subject: [PATCH] v2 emacs: colorize buttonized 'id:' links depending on the target message's state Date: Mon, 16 Jan 2012 17:57:33 +0100 Message-Id: <1326733053-25185-1-git-send-email-pieter@praet.org> X-Mailer: git-send-email 1.7.8.1 In-Reply-To: <87hazva8qe.fsf@praet.org> References: <87hazva8qe.fsf@praet.org> Cc: Notmuch Mail 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: Mon, 16 Jan 2012 16:59:28 -0000 * emacs/notmuch-show.el (notmuch-show-buttonized-link-colors): new defcustom, allows toggling colorization of buttonized links. * emacs/notmuch-show.el (notmuch-show-buttonized-link-present), * emacs/notmuch-show.el (notmuch-show-buttonized-link-present-and-unread), * emacs/notmuch-show.el (notmuch-show-buttonized-link-missing): new faces for buttonized id: links. * emacs/notmuch-show.el (notmuch-show-found-target-p): add optional arg VERIFY-UNREAD which causes results to be filtered by "tag:unread". * emacs/notmuch-show.el (notmuch-show-buttonize-links): use different face property depending on the result of `notmuch-show-found-target-p', causing buttons to available, available-and-unread and missing messages to be displayed in a different color. --- v2: - add `notmuch-show-buttonized-link-colors': new defcustom, allows toggling colorization of buttonized links, to address concerns re performance. - ... and some minor refactoring emacs/notmuch-show.el | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 42 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 7a79d06..c6d7e29 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -794,6 +794,38 @@ current buffer, if possible." (defvar notmuch-show-buffer-name nil) (make-variable-buffer-local 'notmuch-show-buffer-name) +(defcustom notmuch-show-buttonized-link-colors t + "Colorize buttonized links depending on their target's state. + +Also see `notmuch-show-buttonized-link-available', + `notmuch-show-buttonized-link-available-and-unread', + `notmuch-show-buttonized-link-missing'. + +Might impact performance." + :type 'boolean + :group 'notmuch-show) + +(defface notmuch-show-buttonized-link-available + '((t (:inherit goto-address-mail-face :foreground "blue"))) + "Face used for buttonized links to messages which are present +in the mail store." + :group 'notmuch-show + :group 'notmuch-faces) + +(defface notmuch-show-buttonized-link-available-and-unread + '((t (:inherit goto-address-mail-face :foreground "green"))) + "Face used for buttonized links to messages which are present +in the mail store, and are tagged `unread'." + :group 'notmuch-show + :group 'notmuch-faces) + +(defface notmuch-show-buttonized-link-missing + '((t (:inherit goto-address-mail-face :foreground "red"))) + "Face used for buttonized links to messages which are NOT +present in in the mail store." + :group 'notmuch-show + :group 'notmuch-faces) + (defun notmuch-show-buttonize-links (start end) "Buttonize URLs and mail addresses between START and END. @@ -813,7 +845,14 @@ a corresponding notmuch search." (notmuch-show-if-found ,message-id)) 'follow-link t 'help-echo "Mouse-1, RET: search for this message" - 'face goto-address-mail-face))))) + 'face (if notmuch-show-buttonized-link-colors + (cond + ((notmuch-show-found-target-p message-id "and tag:unread") + 'notmuch-show-buttonized-link-available-and-unread) + ((notmuch-show-found-target-p message-id nil) + 'notmuch-show-buttonized-link-available) + (t 'notmuch-show-buttonized-link-missing)) + 'goto-address-mail-face)))))) ;;;###autoload (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch) @@ -906,8 +945,8 @@ thread id. If a prefix is given, crypto processing is toggled." (notmuch-kill-this-buffer) (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto))) -(defun notmuch-show-found-target-p (target) - (let ((args `("count" ,target))) +(defun notmuch-show-found-target-p (target &optional subquery) + (let ((args `("count" ,target ,(or subquery "")))) (> (string-to-number (with-output-to-string (apply 'call-process notmuch-command nil standard-output nil args))) -- 1.7.8.1