unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Damien Cassou <damien.cassou@gmail.com>
Cc: notmuch mailing list <notmuch@notmuchmail.org>
Subject: Re: [PATCH 1/4] Add a thread's tags to emacs header-line
Date: Tue, 20 Nov 2012 00:32:07 -0500	[thread overview]
Message-ID: <20121120053207.GB32514@mit.edu> (raw)
In-Reply-To: <20121120051320.GA32514@mit.edu>

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 <damien.cassou@gmail.com>
> > ---
> >  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 <http://www.gnu.org/licenses/>.
> > +;;
> > +;; Authors: Damien Cassou <damien.cassou@gmail.com>
> > +;;; 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

  reply	other threads:[~2012-11-20  5:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-18 19:18 [PATCH v2] emacs: display tags in notmuch-show with links Damien Cassou
2012-11-18 19:18 ` [PATCH 1/4] Add a thread's tags to emacs header-line Damien Cassou
2012-11-20  5:13   ` Austin Clements
2012-11-20  5:32     ` Austin Clements [this message]
2012-11-22 18:36       ` Damien Cassou
2012-11-18 19:18 ` [PATCH 2/4] Make tags in header-line clickable Damien Cassou
2012-11-18 19:18 ` [PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable Damien Cassou
2012-11-18 23:06   ` Mark Walters
2012-11-22 18:40     ` Damien Cassou
2012-11-22 18:46       ` Mark Walters
2012-11-23  8:02       ` Bernard Hurley
2012-11-23 11:18         ` Tomi Ollila
2012-11-30 16:15         ` Damien Cassou
2012-11-20  5:32   ` Austin Clements
2012-11-30 16:13     ` Damien Cassou
2012-11-18 19:18 ` [PATCH 4/4] emacs: Add unit-tests for clickable tags in notmuch-show Damien Cassou
2012-11-18 22:59 ` [PATCH v2] emacs: display tags in notmuch-show with links Ethan Glasser-Camp
2012-11-19  0:10   ` Aaron Ecay
2012-11-20  4:23   ` Austin Clements
2012-11-20  4:50     ` Ethan
2012-11-22 18:11   ` Damien Cassou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121120053207.GB32514@mit.edu \
    --to=amdragon@mit.edu \
    --cc=damien.cassou@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).