Re: [PATCH 1/4] Add a thread's tags to emacs header-line
authorAustin Clements <amdragon@MIT.EDU>
Tue, 20 Nov 2012 05:13:20 +0000 (00:13 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:46 +0000 (09:50 -0800)
63/7d61b09ad4bd90d1e4aea28ee25412af4c49eb [new file with mode: 0644]

diff --git a/63/7d61b09ad4bd90d1e4aea28ee25412af4c49eb b/63/7d61b09ad4bd90d1e4aea28ee25412af4c49eb
new file mode 100644 (file)
index 0000000..fee8b72
--- /dev/null
@@ -0,0 +1,190 @@
+Return-Path: <amdragon@mit.edu>\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 D7BEA431FC7\r
+       for <notmuch@notmuchmail.org>; Mon, 19 Nov 2012 21:13:23 -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 0fe4kFU7CKU2 for <notmuch@notmuchmail.org>;\r
+       Mon, 19 Nov 2012 21:13:23 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
+       [18.9.25.13])\r
+       by olra.theworths.org (Postfix) with ESMTP id 03F15431FBC\r
+       for <notmuch@notmuchmail.org>; Mon, 19 Nov 2012 21:13:22 -0800 (PST)\r
+X-AuditID: 1209190d-b7f906d0000008de-1a-50ab1172ec0d\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 1D.34.02270.2711BA05; Tue, 20 Nov 2012 00:13:22 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qAK5DMa7009392; \r
+       Tue, 20 Nov 2012 00:13:22 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAK5DKOP029680\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Tue, 20 Nov 2012 00:13:21 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1Tag9A-0000E7-9K; Tue, 20 Nov 2012 00:13:20 -0500\r
+Date: Tue, 20 Nov 2012 00:13:20 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Damien Cassou <damien.cassou@gmail.com>\r
+Subject: Re: [PATCH 1/4] Add a thread's tags to emacs header-line\r
+Message-ID: <20121120051320.GA32514@mit.edu>\r
+References: <1353266322-20318-1-git-send-email-damien.cassou@gmail.com>\r
+       <1353266322-20318-2-git-send-email-damien.cassou@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=iso-8859-1\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: 8bit\r
+In-Reply-To: <1353266322-20318-2-git-send-email-damien.cassou@gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFlrOKsWRmVeSWpSXmKPExsUixG6nolskuDrAoGWJmsWuu1uZLK7fnMns\r
+       wOSxc9Zddo9nq24xBzBFcdmkpOZklqUW6dslcGX8bLvBXnBUrmLu3PlMDYyTJLoYOTkkBEwk\r
+       3rduZYKwxSQu3FvP1sXIxSEksI9R4t+zXjaQhJDABkaJlgfKEPZJJolXS8UgipYwSpxpnsAK\r
+       kmARUJXYfv0XI4jNJqAhsW3/cjBbREBb4s3SDrAaZgEjifs7pjOD2MICjhKtU1aC2bwCOhIL\r
+       rn1lhRjayiixYuIORoiEoMTJmU9YIJp1JHZuvQN0EQeQLS2x/B8HRFheonnrbLA5nAIeEnOu\r
+       zwVrFRVQkZhychvbBEbhWUgmzUIyaRbCpFlIJi1gZFnFKJuSW6Wbm5iZU5yarFucnJiXl1qk\r
+       a6SXm1mil5pSuokRFAeckrw7GN8dVDrEKMDBqMTD+yBhVYAQa2JZcWXuIUZJDiYlUd4X/KsD\r
+       hPiS8lMqMxKLM+KLSnNSiw8xSnAwK4nwNpUDlfOmJFZWpRblw6SkOViUxHmvpNz0FxJITyxJ\r
+       zU5NLUgtgsnKcHAoSfByCQANFSxKTU+tSMvMKUFIM3FwggznARouAVLDW1yQmFucmQ6RP8Wo\r
+       y7FwTfsTRiGWvPy8VClxXg2QIgGQoozSPLg5sPT1ilEc6C1hXjaQKh5g6oOb9ApoCRPQkmsB\r
+       y0GWlCQipKQaGAPvpMiouzUt/lDZWqSxc/a2n24S+1fxfnk6cV2d7Y7lfl4cPk8PNti59vit\r
+       2+ClzRd97MTPorUzs2UdNOcaempUql54uUL45zoRI83eHxNjuyZ+uMR6/x/zz3rGM5zrnk2a\r
+       uovV1K+baWVjo/CBwBeOfak1M/MrgrPbLz1+fiulKkTuVvCjYCWW4oxEQy3mouJEAIcyJDg6        AwAA\r
+Cc: notmuch mailing list <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: Tue, 20 Nov 2012 05:13:24 -0000\r
+\r
+Quoth Damien Cassou on Nov 18 at  8:18 pm:\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
+\r
+notmuch-tagger-intersperse?\r
+\r
+This could also reasonably go in notmuch-lib.el as a general utility.\r
+\r
+(How do neither Elisp nor 'cl have an intersperse?)\r
+\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
+\r
+(dolist (elt list (nreverse res)) ...) to save a list copy?\r
+\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