From: Austin Clements Date: Tue, 20 Nov 2012 05:32:07 +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=27d118ea1e12379a3751b1e93a38766238c99cc8;p=notmuch-archives.git Re: [PATCH 1/4] Add a thread's tags to emacs header-line --- diff --git a/79/c69da9f9cb937de40b49aae879741a5c7bd8b9 b/79/c69da9f9cb937de40b49aae879741a5c7bd8b9 new file mode 100644 index 000000000..b01c6b219 --- /dev/null +++ b/79/c69da9f9cb937de40b49aae879741a5c7bd8b9 @@ -0,0 +1,211 @@ +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 B213C431FC7 + for ; Mon, 19 Nov 2012 21:32:12 -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 AVBPvZ9CxFML for ; + Mon, 19 Nov 2012 21:32:11 -0800 (PST) +Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU + [18.7.68.37]) + by olra.theworths.org (Postfix) with ESMTP id D407C431FBC + for ; Mon, 19 Nov 2012 21:32:10 -0800 (PST) +X-AuditID: 12074425-b7fcc6d00000091f-04-50ab15d9b496 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP + id 2B.17.02335.9D51BA05; Tue, 20 Nov 2012 00:32:09 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qAK5W9np007400; + Tue, 20 Nov 2012 00:32:09 -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 qAK5W7hg001257 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Tue, 20 Nov 2012 00:32:08 -0500 (EST) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1TagRL-0000Kd-34; Tue, 20 Nov 2012 00:32:07 -0500 +Date: Tue, 20 Nov 2012 00:32:07 -0500 +From: Austin Clements +To: Damien Cassou +Subject: Re: [PATCH 1/4] Add a thread's tags to emacs header-line +Message-ID: <20121120053207.GB32514@mit.edu> +References: <1353266322-20318-1-git-send-email-damien.cassou@gmail.com> + <1353266322-20318-2-git-send-email-damien.cassou@gmail.com> + <20121120051320.GA32514@mit.edu> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <20121120051320.GA32514@mit.edu> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFlrBKsWRmVeSWpSXmKPExsUixCmqrHtTdHWAwe9uG4tdd7cyWVy/OZPZ + gclj56y77B7PVt1iDmCK4rJJSc3JLEst0rdL4Mp4vX8+W8E3lYqDtx6wNTA+keli5OSQEDCR + 2PfuPiuELSZx4d56ti5GLg4hgX2MEtuetTJDOBsYJZ6f/coI4Zxkkth/pIMdpEVIYAmjxPwl + XCA2i4CqxNVXt5lBbDYBDYlt+5czgtgiAtoSb5Z2gK1gFjCSuL9jOliNsICjROuUlWA2r4CO + xLqdp6BWr2CU+LHuAVRCUOLkzCcsEM06Eju33gEq4gCypSWW/+OACMtLNG+dDVbOKaArcfLd + aTYQW1RARWLKyW1sExiFZyGZNAvJpFkIk2YhmbSAkWUVo2xKbpVubmJmTnFqsm5xcmJeXmqR + roVebmaJXmpK6SZGUCSwu6juYJxwSOkQowAHoxIP74OEVQFCrIllxZW5hxglOZiURHk3CK8O + EOJLyk+pzEgszogvKs1JLT7EKMHBrCTC21QOVM6bklhZlVqUD5OS5mBREue9kXLTX0ggPbEk + NTs1tSC1CCYrw8GhJMHrJQI0VLAoNT21Ii0zpwQhzcTBCTKcB2i4P0gNb3FBYm5xZjpE/hSj + LsfCNe1PGIVY8vLzUqXEeXNAigRAijJK8+DmwBLYK0ZxoLeEeatAqniAyQ9u0iugJUxAS64F + LAdZUpKIkJJqYAw1fVQ/c1frZfPVW9uvvX+w6f8sGydPY73Di35qzF7nHMYZesY6qu3/nxuP + zsik/wt3M1qz6iT/o3iPqI4ZzVeffyvrL/tl6FwdtXDhj46Flpu2bZe/bmrQG/RKsMPkj+fa + bdeK3zFODhFdWKEy/ZKbjlrhAaVkK9GdN//m9qz1edByzoTLMECJpTgj0VCLuag4EQDN79UG + OwMAAA== +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:32:12 -0000 + +Sorry, I was a little trigger-happy on the send. A few more comments +below. + +Quoth myself on Nov 20 at 12:13 am: +> 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) + +notmuch-tagger-format-tags-header-line? It doesn't actually present +them (though "format" isn't great either.) + +> > + "Return a property list to present TAGS in emacs header-line." + +This doesn't return a property list, it returns a mode-line-format +template. Maybe something like, + + "Format TAGS as a mode-line-format template. +The result is suitable for inclusion in `header-line-format' or +`mode-line-format'." + +(Is it actually suitable for mode-line-format or do header-line +buttons really only work in the header line?) + +> > + (list +> > + "(" +> > + (notmuch-tagger-separate-elems tags " ") +> > + ")")) +> > + +> > + +> > +(provide 'notmuch-tagger) +> > +;;; notmuch-tagger.el ends here