[PATCH 1/4] emacs: Add a thread's tags to notmuch-show header-line
authorDamien Cassou <damien.cassou@gmail.com>
Tue, 11 Dec 2012 09:00:34 +0000 (10:00 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:02 +0000 (09:52 -0800)
cb/15a2b61a112ea409f50f3bcd1fdc24e1e8b0f4 [new file with mode: 0644]

diff --git a/cb/15a2b61a112ea409f50f3bcd1fdc24e1e8b0f4 b/cb/15a2b61a112ea409f50f3bcd1fdc24e1e8b0f4
new file mode 100644 (file)
index 0000000..e65b7c1
--- /dev/null
@@ -0,0 +1,193 @@
+Return-Path: <damien.cassou@gmail.com>\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 3EDEB431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 11 Dec 2012 01:00:50 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, 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 k4DExCsbhAPD for <notmuch@notmuchmail.org>;\r
+       Tue, 11 Dec 2012 01:00:48 -0800 (PST)\r
+Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com\r
+       [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id CEAF3431FAF\r
+       for <notmuch@notmuchmail.org>; Tue, 11 Dec 2012 01:00:47 -0800 (PST)\r
+Received: by mail-wi0-f175.google.com with SMTP id hm11so1683809wib.2\r
+       for <notmuch@notmuchmail.org>; Tue, 11 Dec 2012 01:00:45 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
+       :mime-version:content-type:content-transfer-encoding;\r
+       bh=3on8qi4zRfLKlM7RHnKw3s1xoGgc2hlg4XiSP5dEa5A=;\r
+       b=NzXR+1hvIA22tclHjWwap8YvGe/IaSzumcSSbvQ1sqGt8262dNN+WOWu0kDO2nAyd6\r
+       B8ikcyQBdXHW7uCmOk+xRyIjHGpg+muK9L+YZrk2ymR4ZoQwI1d9YV+/drM+/G6JQTi6\r
+       ZqRy0mU1c1ST/jbkSOrPlnf/qHg5fgBvF+kQToFmIhrm8TbYnNb3/zYSMGc7tKOmGUug\r
+       mW0F/IoAmF77Y7ux0KH7GHP2kastSo1vnlWyQrjThNMUPQGuAArfDnh71aJ0E7C1GG4V\r
+       aZ2S9SuPssGTPeseWgGSd9gGZ4vdwEQYuTSxt2nFmOKxQoEc7W6208NFxoRfs9Crngcp\r
+       7XHQ==\r
+Received: by 10.216.203.165 with SMTP id f37mr364949weo.95.1355216445388;\r
+       Tue, 11 Dec 2012 01:00:45 -0800 (PST)\r
+Received: from luz3.lille.inria.fr ([193.51.236.232])\r
+       by mx.google.com with ESMTPS id b1sm15376748wix.11.2012.12.11.01.00.44\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Tue, 11 Dec 2012 01:00:44 -0800 (PST)\r
+From: Damien Cassou <damien.cassou@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/4] emacs: Add a thread's tags to notmuch-show header-line\r
+Date: Tue, 11 Dec 2012 10:00:34 +0100\r
+Message-Id: <1355216437-21109-2-git-send-email-damien.cassou@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1355216437-21109-1-git-send-email-damien.cassou@gmail.com>\r
+References: <1355216437-21109-1-git-send-email-damien.cassou@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\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: Tue, 11 Dec 2012 09:00:50 -0000\r
+\r
+Signed-off-by: Damien Cassou <damien.cassou@gmail.com>\r
+---\r
+ emacs/notmuch-lib.el    |   11 +++++++++--\r
+ emacs/notmuch-show.el   |   27 +++++++++++++++++++++++----\r
+ emacs/notmuch-tagger.el |   35 +++++++++++++++++++++++++++++++++++\r
+ 3 files changed, 67 insertions(+), 6 deletions(-)\r
+ create mode 100644 emacs/notmuch-tagger.el\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 9c4ee71..3541bb7 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -603,8 +603,15 @@ left it."\r
+     ;; Clear out what we've parsed\r
+     (delete-region (point-min) (point))))\r
\r
+-\r
+-\r
++(defun notmuch-intersperse (list sep)\r
++  "Return a list with all elements of LIST separated by SEP."\r
++  (let ((first t)\r
++        (res nil))\r
++    (dolist (elt list (nreverse res))\r
++      (unless first\r
++        (push sep res))\r
++      (setq first nil)\r
++      (push elt res))))\r
\r
+ (provide 'notmuch-lib)\r
\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 7d9f8a9..a71497a 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -36,6 +36,7 @@\r
+ (require 'notmuch-mua)\r
+ (require 'notmuch-crypto)\r
+ (require 'notmuch-print)\r
++(require 'notmuch-tagger)\r
\r
+ (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))\r
+ (declare-function notmuch-fontify-headers "notmuch" nil)\r
+@@ -364,7 +365,8 @@ operation on the contents of the current buffer."\r
+         (replace-match (concat "("\r
+                                (propertize (mapconcat 'identity tags " ")\r
+                                            'face 'notmuch-tag-face)\r
+-                               ")"))))))\r
++                               ")")))))\r
++  (notmuch-show-update-header-line))\r
\r
+ (defun notmuch-clean-address (address)\r
+   "Try to clean a single email ADDRESS for display. Return a cons\r
+@@ -1136,11 +1138,28 @@ function is used."\r
\r
+       (jit-lock-register #'notmuch-show-buttonise-links)\r
\r
+-      ;; Set the header line to the subject of the first message.\r
+-      (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))\r
+-\r
++      (notmuch-show-update-header-line)\r
+       (run-hooks 'notmuch-show-hook))))\r
\r
++(defun notmuch-show-thread-tags ()\r
++  "Return the list of tags for the current thread."\r
++  (let ((tags (list)))\r
++    (notmuch-show-mapc (lambda ()\r
++                       (mapcar (lambda (elt)\r
++                                 ;; Avoid adding duplicate tags\r
++                                 (add-to-list 'tags elt))\r
++                               (notmuch-show-get-tags))))\r
++    tags))\r
++\r
++(defun notmuch-show-update-header-line ()\r
++  "Make the header-line show the thread's subject and tags."\r
++  (let ((thread-subject (notmuch-show-strip-re (notmuch-show-get-subject))))\r
++    (setq header-line-format\r
++        (list\r
++         thread-subject\r
++         " "\r
++         (notmuch-tagger-format-tags-header-line (notmuch-show-thread-tags))))))\r
++\r
+ (defun notmuch-show-capture-state ()\r
+   "Capture the state of the current buffer.\r
\r
+diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el\r
+new file mode 100644\r
+index 0000000..6fcebff\r
+--- /dev/null\r
++++ b/emacs/notmuch-tagger.el\r
+@@ -0,0 +1,35 @@\r
++;; notmuch-tagger.el --- Library to improve the way tags are displayed\r
++;;\r
++;; Copyright © Damien Cassou\r
++;;\r
++;; This file is part of Notmuch.\r
++;;\r
++;; Notmuch is free software: you can redistribute it and/or modify it\r
++;; under the terms of the GNU General Public License as published by\r
++;; the Free Software Foundation, either version 3 of the License, or\r
++;; (at your option) any later version.\r
++;;\r
++;; Notmuch is distributed in the hope that it will be useful, but\r
++;; WITHOUT ANY WARRANTY; without even the implied warranty of\r
++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
++;; General Public License for more details.\r
++;;\r
++;; You should have received a copy of the GNU General Public License\r
++;; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.\r
++;;\r
++;; Authors: Damien Cassou <damien.cassou@gmail.com>\r
++;;; Commentary:\r
++;;\r
++;;; Code:\r
++;;\r
++\r
++(defun notmuch-tagger-format-tags-header-line (tags)\r
++  "Format TAGS as a `mode-line-format' template.\r
++The result is suitable for inclusion in `header-line-format'."\r
++  (list\r
++   "("\r
++   (notmuch-intersperse tags " ")\r
++   ")"))\r
++\r
++(provide 'notmuch-tagger)\r
++;;; notmuch-tagger.el ends here\r
+-- \r
+1.7.10.4\r
+\r