[PATCH v4 3/3] emacs: colorize buttonized 'id:' links depending on the target message...
authorPieter Praet <pieter@praet.org>
Sun, 22 Jan 2012 08:54:29 +0000 (09:54 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:42:55 +0000 (09:42 -0800)
e0/d217f50351c625b3f27d1de6f6a4b4dab34b7e [new file with mode: 0644]

diff --git a/e0/d217f50351c625b3f27d1de6f6a4b4dab34b7e b/e0/d217f50351c625b3f27d1de6f6a4b4dab34b7e
new file mode 100644 (file)
index 0000000..002de92
--- /dev/null
@@ -0,0 +1,167 @@
+Return-Path: <pieter@praet.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 0CD85429E5F\r
+       for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 00:56:45 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 FSAiCDXOW2Cp for <notmuch@notmuchmail.org>;\r
+       Sun, 22 Jan 2012 00:56:44 -0800 (PST)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 03A63429E54\r
+       for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 00:56:43 -0800 (PST)\r
+Received: by mail-we0-f181.google.com with SMTP id b10so1658214wer.26\r
+       for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 00:56:43 -0800 (PST)\r
+MIME-Version: 1.0\r
+Received: by 10.216.139.25 with SMTP id b25mr1616683wej.28.1327222603610;\r
+       Sun, 22 Jan 2012 00:56:43 -0800 (PST)\r
+Received: from localhost ([109.131.95.182])\r
+       by mx.google.com with ESMTPS id fr8sm18836968wib.10.2012.01.22.00.56.42\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 22 Jan 2012 00:56:43 -0800 (PST)\r
+From: Pieter Praet <pieter@praet.org>\r
+To: Mark Anderson <MarkR.Anderson@amd.com>, Aaron Ecay <aaronecay@gmail.com>,\r
+       David Edmondson <dme@dme.org>,\r
+       Jameson Graef Rollins <jrollins@finestructure.net>\r
+Subject: [PATCH v4 3/3] emacs: colorize buttonized 'id:' links depending on\r
+       the target message's state\r
+Date: Sun, 22 Jan 2012 09:54:29 +0100\r
+Message-Id: <1327222469-29487-3-git-send-email-pieter@praet.org>\r
+X-Mailer: git-send-email 1.7.8.1\r
+In-Reply-To: <871uqsku4h.fsf@praet.org>\r
+References: <871uqsku4h.fsf@praet.org>\r
+X-Gm-Message-State:\r
+ ALoCoQlt47zNumZI29cqWZEbjCuYIET23gGc4B55f2A/uEjiBIR++MTRW3Rqf4ko6D9ybJxoLvbE\r
+Cc: Notmuch Mail <notmuch@notmuchmail.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: Sun, 22 Jan 2012 08:56:45 -0000\r
+\r
+* emacs/notmuch-show.el\r
+\r
+  (notmuch-show-buttonized-link-colors):\r
+    - new defcustom, allows toggling colorization of buttonized links.\r
+\r
+  (notmuch-show-buttonized-link-available),\r
+  (notmuch-show-buttonized-link-available-and-unread),\r
+  (notmuch-show-buttonized-link-missing):\r
+    - new faces for buttonized id: links.\r
+\r
+  (notmuch-show-found-target-p):\r
+    - add optional arg SUBQUERY to allow addition filtering,\r
+      eg. with "tag:unread".\r
+\r
+  (notmuch-show-buttonize-links):\r
+    - tweak `Message-Id' regexp: less greedy matching.\r
+    - use different face property depending on the result of\r
+      `notmuch-show-found-target-p', causing buttons to available,\r
+      available-and-unread and missing messages to be displayed in\r
+      different colors.\r
+---\r
+\r
+Updated regexp.\r
+\r
+ emacs/notmuch-show.el |   47 +++++++++++++++++++++++++++++++++++++++++++----\r
+ 1 files changed, 43 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 972ac79..c04fc28 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -899,6 +899,38 @@ current buffer, if possible."\r
+ (defvar notmuch-show-buffer-name nil)\r
+ (make-variable-buffer-local 'notmuch-show-buffer-name)\r
\r
++(defcustom notmuch-show-buttonized-link-colors t\r
++  "Colorize buttonized links depending on their target's state.\r
++\r
++Also see `notmuch-show-buttonized-link-available',\r
++         `notmuch-show-buttonized-link-available-and-unread',\r
++         `notmuch-show-buttonized-link-missing'.\r
++\r
++Might impact performance."\r
++  :type 'boolean\r
++  :group 'notmuch-show)\r
++\r
++(defface notmuch-show-buttonized-link-available\r
++  '((t (:inherit goto-address-mail-face :foreground "blue")))\r
++  "Face used for buttonized links to messages which are present\r
++in the mail store."\r
++  :group 'notmuch-show\r
++  :group 'notmuch-faces)\r
++\r
++(defface notmuch-show-buttonized-link-available-and-unread\r
++  '((t (:inherit goto-address-mail-face :foreground "green")))\r
++  "Face used for buttonized links to messages which are present\r
++in the mail store, and are tagged `unread'."\r
++  :group 'notmuch-show\r
++  :group 'notmuch-faces)\r
++\r
++(defface notmuch-show-buttonized-link-missing\r
++  '((t (:inherit goto-address-mail-face :foreground "red")))\r
++  "Face used for buttonized links to messages which are NOT\r
++present in in the mail store."\r
++  :group 'notmuch-show\r
++  :group 'notmuch-faces)\r
++\r
+ (defun notmuch-show-buttonize-links (start end)\r
+   "Buttonize URLs and mail addresses between START and END.\r
\r
+@@ -907,7 +939,7 @@ a corresponding notmuch search."\r
+   (goto-address-fontify-region start end)\r
+   (save-excursion\r
+     (goto-char start)\r
+-    (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" end t)\r
++    (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+@[^[:space:]\"]\\{3,\\}\\1" end t)\r
+       (let ((message-id (match-string-no-properties 0))\r
+           (string-start (match-beginning 0))\r
+           (string-end (match-end 0)))\r
+@@ -918,7 +950,14 @@ a corresponding notmuch search."\r
+                                    (notmuch-show-if-found ,message-id))\r
+                         'follow-link t\r
+                         'help-echo "Mouse-1, RET: search for this message"\r
+-                        'face goto-address-mail-face)))))\r
++                        'face (if notmuch-show-buttonized-link-colors\r
++                                  (cond\r
++                                   ((notmuch-show-found-target-p message-id "and tag:unread")\r
++                                    'notmuch-show-buttonized-link-available-and-unread)\r
++                                   ((notmuch-show-found-target-p message-id nil)\r
++                                    'notmuch-show-buttonized-link-available)\r
++                                   (t 'notmuch-show-buttonized-link-missing))\r
++                                'goto-address-mail-face))))))\r
\r
+ ;;;###autoload\r
+ (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)\r
+@@ -1008,8 +1047,8 @@ thread id.  If a prefix is given, crypto processing is toggled."\r
+     (notmuch-kill-this-buffer)\r
+     (notmuch-show-worker thread-id parent-buffer query-context buffer-name process-crypto)))\r
\r
+-(defun notmuch-show-found-target-p (target)\r
+-  (let ((args `("count" ,target)))\r
++(defun notmuch-show-found-target-p (target &optional subquery)\r
++  (let ((args `("count" ,target ,(or subquery ""))))\r
+     (> (string-to-number\r
+       (with-output-to-string\r
+         (apply 'call-process notmuch-command nil standard-output nil args)))\r
+-- \r
+1.7.8.1\r
+\r