From: Austin Clements Date: Tue, 20 Nov 2012 05:13:20 +0000 (+1900) Subject: Re: [PATCH 1/4] Add a thread's tags to emacs header-line X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=57589b9f11c3894bd2f44ef31b8ce4170bc07092;p=notmuch-archives.git Re: [PATCH 1/4] Add a thread's tags to emacs header-line --- diff --git a/63/7d61b09ad4bd90d1e4aea28ee25412af4c49eb b/63/7d61b09ad4bd90d1e4aea28ee25412af4c49eb new file mode 100644 index 000000000..fee8b729b --- /dev/null +++ b/63/7d61b09ad4bd90d1e4aea28ee25412af4c49eb @@ -0,0 +1,190 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id D7BEA431FC7 + for ; Mon, 19 Nov 2012 21:13:23 -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 0fe4kFU7CKU2 for ; + Mon, 19 Nov 2012 21:13:23 -0800 (PST) +Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU + [18.9.25.13]) + by olra.theworths.org (Postfix) with ESMTP id 03F15431FBC + for ; Mon, 19 Nov 2012 21:13:22 -0800 (PST) +X-AuditID: 1209190d-b7f906d0000008de-1a-50ab1172ec0d +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP + id 1D.34.02270.2711BA05; Tue, 20 Nov 2012 00:13:22 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qAK5DMa7009392; + Tue, 20 Nov 2012 00:13:22 -0500 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAK5DKOP029680 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Tue, 20 Nov 2012 00:13:21 -0500 (EST) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1Tag9A-0000E7-9K; Tue, 20 Nov 2012 00:13:20 -0500 +Date: Tue, 20 Nov 2012 00:13:20 -0500 +From: Austin Clements +To: Damien Cassou +Subject: Re: [PATCH 1/4] Add a thread's tags to emacs header-line +Message-ID: <20121120051320.GA32514@mit.edu> +References: <1353266322-20318-1-git-send-email-damien.cassou@gmail.com> + <1353266322-20318-2-git-send-email-damien.cassou@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <1353266322-20318-2-git-send-email-damien.cassou@gmail.com> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFlrOKsWRmVeSWpSXmKPExsUixG6nolskuDrAoGWJmsWuu1uZLK7fnMns + wOSxc9Zddo9nq24xBzBFcdmkpOZklqUW6dslcGX8bLvBXnBUrmLu3PlMDYyTJLoYOTkkBEwk + 3rduZYKwxSQu3FvP1sXIxSEksI9R4t+zXjaQhJDABkaJlgfKEPZJJolXS8UgipYwSpxpnsAK + kmARUJXYfv0XI4jNJqAhsW3/cjBbREBb4s3SDrAaZgEjifs7pjOD2MICjhKtU1aC2bwCOhIL + rn1lhRjayiixYuIORoiEoMTJmU9YIJp1JHZuvQN0EQeQLS2x/B8HRFheonnrbLA5nAIeEnOu + zwVrFRVQkZhychvbBEbhWUgmzUIyaRbCpFlIJi1gZFnFKJuSW6Wbm5iZU5yarFucnJiXl1qk + a6SXm1mil5pSuokRFAeckrw7GN8dVDrEKMDBqMTD+yBhVYAQa2JZcWXuIUZJDiYlUd4X/KsD + hPiS8lMqMxKLM+KLSnNSiw8xSnAwK4nwNpUDlfOmJFZWpRblw6SkOViUxHmvpNz0FxJITyxJ + zU5NLUgtgsnKcHAoSfByCQANFSxKTU+tSMvMKUFIM3FwggznARouAVLDW1yQmFucmQ6RP8Wo + y7FwTfsTRiGWvPy8VClxXg2QIgGQoozSPLg5sPT1ilEc6C1hXjaQKh5g6oOb9ApoCRPQkmsB + y0GWlCQipKQaGAPvpMiouzUt/lDZWqSxc/a2n24S+1fxfnk6cV2d7Y7lfl4cPk8PNti59vit + 2+ClzRd97MTPorUzs2UdNOcaempUql54uUL45zoRI83eHxNjuyZ+uMR6/x/zz3rGM5zrnk2a + uovV1K+baWVjo/CBwBeOfak1M/MrgrPbLz1+fiulKkTuVvCjYCWW4oxEQy3mouJEAIcyJDg6 AwAA +Cc: notmuch mailing list +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: Tue, 20 Nov 2012 05:13:24 -0000 + +Quoth Damien Cassou on Nov 18 at 8:18 pm: +> Signed-off-by: Damien Cassou +> --- +> emacs/notmuch-show.el | 24 +++++++++++++++++++++--- +> emacs/notmuch-tagger.el | 44 ++++++++++++++++++++++++++++++++++++++++++++ +> 2 files changed, 65 insertions(+), 3 deletions(-) +> create mode 100644 emacs/notmuch-tagger.el +> +> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +> index 5b3e70e..988e27c 100644 +> --- a/emacs/notmuch-show.el +> +++ b/emacs/notmuch-show.el +> @@ -36,6 +36,7 @@ +> (require 'notmuch-mua) +> (require 'notmuch-crypto) +> (require 'notmuch-print) +> +(require 'notmuch-tagger) +> +> (declare-function notmuch-call-notmuch-process "notmuch" (&rest args)) +> (declare-function notmuch-fontify-headers "notmuch" nil) +> @@ -1121,11 +1122,28 @@ function is used." +> +> (jit-lock-register #'notmuch-show-buttonise-links) +> +> - ;; Set the header line to the subject of the first message. +> - (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject))) +> - +> + (notmuch-show-update-header-line) +> (run-hooks 'notmuch-show-hook)))) +> +> +(defun notmuch-show-thread-tags () +> + "Return the list of tags for the current thread." +> + (let ((tags (list))) +> + (notmuch-show-mapc (lambda () +> + (mapcar (lambda (elt) +> + ;; Avoid adding duplicate tags +> + (add-to-list 'tags elt)) +> + (notmuch-show-get-tags)))) +> + tags)) +> + +> +(defun notmuch-show-update-header-line () +> + "Make the header-line show the thread's subject and tags." +> + (let ((thread-subject (notmuch-show-strip-re (notmuch-show-get-subject)))) +> + (setq header-line-format +> + (list +> + thread-subject +> + " " +> + (notmuch-tagger-present-tags-header-line (notmuch-show-thread-tags)))))) +> + +> (defun notmuch-show-capture-state () +> "Capture the state of the current buffer. +> +> diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el +> new file mode 100644 +> index 0000000..5ca190e +> --- /dev/null +> +++ b/emacs/notmuch-tagger.el +> @@ -0,0 +1,44 @@ +> +;; notmuch-tagger.el --- Library to improve the way tags are displayed +> +;; +> +;; Copyright © Damien Cassou +> +;; +> +;; This file is part of Notmuch. +> +;; +> +;; Notmuch is free software: you can redistribute it and/or modify it +> +;; under the terms of the GNU General Public License as published by +> +;; the Free Software Foundation, either version 3 of the License, or +> +;; (at your option) any later version. +> +;; +> +;; Notmuch is distributed in the hope that it will be useful, but +> +;; WITHOUT ANY WARRANTY; without even the implied warranty of +> +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +> +;; General Public License for more details. +> +;; +> +;; You should have received a copy of the GNU General Public License +> +;; along with Notmuch. If not, see . +> +;; +> +;; Authors: Damien Cassou +> +;;; Commentary: +> +;; +> +;;; Code: +> +;; +> +(defun notmuch-tagger-separate-elems (list sep) + +notmuch-tagger-intersperse? + +This could also reasonably go in notmuch-lib.el as a general utility. + +(How do neither Elisp nor 'cl have an intersperse?) + +> + "Return a list with all elements of LIST separated by SEP." +> + (let ((first t) +> + (res nil)) +> + (dolist (elt (reverse list) res) + +(dolist (elt list (nreverse res)) ...) to save a list copy? + +> + (unless first +> + (push sep res)) +> + (setq first nil) +> + (push elt res)))) +> + +> +(defun notmuch-tagger-present-tags-header-line (tags) +> + "Return a property list to present TAGS in emacs header-line." +> + (list +> + "(" +> + (notmuch-tagger-separate-elems tags " ") +> + ")")) +> + +> + +> +(provide 'notmuch-tagger) +> +;;; notmuch-tagger.el ends here