[PATCH 1/4] Add a thread's tags to emacs header-line
authorDamien Cassou <damien.cassou@gmail.com>
Sun, 18 Nov 2012 19:18:39 +0000 (20:18 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:43 +0000 (09:50 -0800)
1a/3644eeb479c2a6b7f1ae69d8886db1d7692a30 [new file with mode: 0644]

diff --git a/1a/3644eeb479c2a6b7f1ae69d8886db1d7692a30 b/1a/3644eeb479c2a6b7f1ae69d8886db1d7692a30
new file mode 100644 (file)
index 0000000..e489acb
--- /dev/null
@@ -0,0 +1,170 @@
+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 EF6C1431FDA\r
+       for <notmuch@notmuchmail.org>; Sun, 18 Nov 2012 11:19:18 -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 WQX5bciRr10W for <notmuch@notmuchmail.org>;\r
+       Sun, 18 Nov 2012 11:19:17 -0800 (PST)\r
+Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com\r
+ [74.125.82.45])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 45365431FC0   for <notmuch@notmuchmail.org>; Sun, 18 Nov 2012 11:19:17 -0800\r
+ (PST)\r
+Received: by mail-wg0-f45.google.com with SMTP id dq11so838560wgb.2\r
+       for <notmuch@notmuchmail.org>; Sun, 18 Nov 2012 11:19:16 -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=onHk67cScTJNp2gozO0WJgxX9RxqiJzg1GvFczObDjs=;\r
+       b=aXw22UFlCKOxEF7DLqt7Hip8Z+p/swJV0NmnZeBhMSquy2qvaaPX4oub7sW9PoSxJ5\r
+       VFazoxIJGbHx9ebrzKXnMXPxU5EPzDg6bdJ8JmPxOGyA/D9Csm1vOEvDlzON5//i63/j\r
+       WomJNONE8lgkfWFEoahHhVbF4q9PXVnMCV+G6SfGG+tqojN8xEjFfGbsvvfa8hFdGtEI\r
+       WXq7OBFSLlyWdMtHst3xKtTpBXEXTQpCAFWPEE0/JpEm0uQUB4ZFu8VDh1BnUJuRTC6f\r
+       prb2o7W64llhDiOCDgWo1JYVE7rI9G0VTzWQQL0CDWcuBI85TLcd4KoWBlpUKnJxTShb\r
+       EdOw==\r
+Received: by 10.216.217.214 with SMTP id i64mr3666202wep.124.1353266354696;\r
+       Sun, 18 Nov 2012 11:19:14 -0800 (PST)\r
+Received: from localhost.localdomain (ble59-4-82-228-190-150.fbx.proxad.net.\r
+       [82.228.190.150])\r
+       by mx.google.com with ESMTPS id i2sm10290063wiw.3.2012.11.18.11.19.13\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 18 Nov 2012 11:19:13 -0800 (PST)\r
+From: Damien Cassou <damien.cassou@gmail.com>\r
+To: notmuch mailing list <notmuch@notmuchmail.org>\r
+Subject: [PATCH 1/4] Add a thread's tags to emacs header-line\r
+Date: Sun, 18 Nov 2012 20:18:39 +0100\r
+Message-Id: <1353266322-20318-2-git-send-email-damien.cassou@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1353266322-20318-1-git-send-email-damien.cassou@gmail.com>\r
+References: <1353266322-20318-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: Sun, 18 Nov 2012 19:19:19 -0000\r
+\r
+Signed-off-by: Damien Cassou <damien.cassou@gmail.com>\r
+---\r
+ emacs/notmuch-show.el   |   24 +++++++++++++++++++++---\r
+ emacs/notmuch-tagger.el |   44 ++++++++++++++++++++++++++++++++++++++++++++\r
+ 2 files changed, 65 insertions(+), 3 deletions(-)\r
+ create mode 100644 emacs/notmuch-tagger.el\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 5b3e70e..988e27c 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
+@@ -1121,11 +1122,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-present-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..5ca190e\r
+--- /dev/null\r
++++ b/emacs/notmuch-tagger.el\r
+@@ -0,0 +1,44 @@\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
++(defun notmuch-tagger-separate-elems (list sep)\r
++  "Return a list with all elements of LIST separated by SEP."\r
++  (let ((first t)\r
++        (res nil))\r
++    (dolist (elt (reverse list) res)\r
++      (unless first\r
++        (push sep res))\r
++      (setq first nil)\r
++      (push elt res))))\r
++\r
++(defun notmuch-tagger-present-tags-header-line (tags)\r
++  "Return a property list to present TAGS in emacs header-line."\r
++  (list\r
++   "("\r
++   (notmuch-tagger-separate-elems tags " ")\r
++   ")"))\r
++\r
++\r
++(provide 'notmuch-tagger)\r
++;;; notmuch-tagger.el ends here\r
+-- \r
+1.7.10.4\r
+\r