From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id E8D97431FAF for ; Wed, 18 Jan 2012 04:50:49 -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 43raw4AyDzyi for ; Wed, 18 Jan 2012 04:50:49 -0800 (PST) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 12B4B431FAE for ; Wed, 18 Jan 2012 04:50:48 -0800 (PST) Received: by werp13 with SMTP id p13so1364175wer.26 for ; Wed, 18 Jan 2012 04:50:47 -0800 (PST) Received: by 10.216.134.71 with SMTP id r49mr1757137wei.49.1326891047509; Wed, 18 Jan 2012 04:50:47 -0800 (PST) Received: from localhost ([109.131.97.13]) by mx.google.com with ESMTPS id eq5sm7095973wib.2.2012.01.18.04.50.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Jan 2012 04:50:46 -0800 (PST) From: Pieter Praet To: Aaron Ecay , David Edmondson , Jameson Graef Rollins Subject: [PATCH 3/3 v3] emacs: colorize buttonized 'id:' links depending on the target message's state Date: Wed, 18 Jan 2012 13:48:53 +0100 Message-Id: <1326890933-14947-1-git-send-email-pieter@praet.org> X-Mailer: git-send-email 1.7.8.1 In-Reply-To: <87aa5l8gqx.fsf@praet.org> References: <87aa5l8gqx.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: Wed, 18 Jan 2012 12:50:50 -0000 * emacs/notmuch-show.el (notmuch-show-buttonized-link-colors): - new defcustom, allows toggling colorization of buttonized links. (notmuch-show-buttonized-link-available), (notmuch-show-buttonized-link-available-and-unread), (notmuch-show-buttonized-link-missing): - new faces for buttonized id: links. (notmuch-show-found-target-p): - add optional arg SUBQUERY to allow addition filtering, eg. with "tag:unread". (notmuch-show-buttonize-links): - tweak `Message-Id' regexp: less greedy matching. - 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 different colors. --- [Forgot to cc the list, apologies for the dupes.] I've also noticed that Message-Id's from `git send-email' don't get colorized (but do get buttonized) for some reason. Thus, would appreciate some assistance with the regexp. v2: - add `notmuch-show-buttonized-link-colors': new defcustom, allows toggling colorization of buttonized links, to address unquestionable concerns re performance, voiced by David Edmondson [1]. - ... and some minor refactoring v3: - tweak `Message-Id' regexp: mock Message-Id's shouldn't be matched, as pointed out by Aaron Ecay [2]. [1] id:"cun4nvv50s6.fsf@hotblack-desiato.hh.sledj.net" [2] id:"m2sjjfb9xx.fsf@gmail.com" emacs/notmuch-show.el | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 43 insertions(+), 4 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 244824a..deac9a6 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -798,6 +798,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. @@ -806,7 +838,7 @@ a corresponding notmuch search." (goto-address-fontify-region start end) (save-excursion (goto-char start) - (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" end t) + (while (re-search-forward "id:\\(\"?\\)\[^ \t\"@\]\+@[^ \t\"]\+\\1" end t) (let ((message-id (match-string-no-properties 0)) (string-start (match-beginning 0)) (string-end (match-end 0))) @@ -817,7 +849,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) @@ -910,8 +949,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