[PATCH 3/3] emacs: add notmuch hello refresh hook to display message count change

Jani Nikula jani at nikula.org
Sun Jul 8 01:20:28 PDT 2012


On Jul 8, 2012 9:57 AM, "Mark Walters" <markwalters1009 at gmail.com> wrote:
>
> On Fri, 15 Jun 2012, Jani Nikula <jani at nikula.org> wrote:
> > Add a notmuch hello refresh hook to display a message about change in
> > message count in the database since the notmuch-hello buffer was last
> > refreshed manually (no-display is nil).
> >
> > Signed-off-by: Jani Nikula <jani at nikula.org>
>
> Hi
>
> I just have a couple of comments/queries. First, since it breaks
> existing hooks I think it needs a NEWS item.

Sure.

> Secondly, I, personally, would much prefer the hook with the slight
> tweak that it counts inbox messages rather than all messages. Is that
> an option that could be put in the defcustom?

I suppose the query could be customizable. That's simple enough; for
anything non-trivial people can write their own hooks.

BR,
Jani.

>
> Best wishes
>
> Mark
>
> > ---
> >  emacs/notmuch-hello.el |   27 +++++++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> >
> > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> > index bc43178..bcca044 100644
> > --- a/emacs/notmuch-hello.el
> > +++ b/emacs/notmuch-hello.el
> > @@ -148,6 +148,7 @@ International Bureau of Weights and Measures."
> >  (defcustom notmuch-hello-refresh-hook nil
> >    "Functions called after updating a `notmuch-hello' buffer."
> >    :type 'hook
> > +  :options '(notmuch-hello-refresh-status-message)
> >    :group 'notmuch-hello
> >    :group 'notmuch-hooks)
> >
> > @@ -749,6 +750,32 @@ following:
> >      (let ((fill-column (- (window-width) notmuch-hello-indent)))
> >        (center-region start (point)))))
> >
> > +(defvar notmuch-hello-refresh-count 0
> > +  "Number of messages in the database when `notmuch-hello' was last
run.
> > +
> > +Used internally by `notmuch-hello-refresh-status-message'.")
> > +
> > +(defun notmuch-hello-refresh-status-message (no-display)
> > +  "Hook to display a status message when refreshing notmuch-hello
buffer.
> > +
> > +Display a status message about the difference in message count in
> > +the database since the last call."
> > +  (unless no-display
> > +    (let* ((new-count
> > +         (string-to-number (car (process-lines notmuch-command
"count"))))
> > +        (diff-count (- new-count notmuch-hello-refresh-count)))
> > +      (cond
> > +       ((= notmuch-hello-refresh-count 0)
> > +     (message "You have %s messages."
> > +              (notmuch-hello-nice-number new-count)))
> > +       ((> diff-count 0)
> > +     (message "You have %s more messages since last refresh."
> > +              (notmuch-hello-nice-number diff-count)))
> > +       ((< diff-count 0)
> > +     (message "You have %s fewer messages since last refresh."
> > +              (notmuch-hello-nice-number (- diff-count)))))
> > +      (setq notmuch-hello-refresh-count new-count))))
> > +
> >  ;;;###autoload
> >  (defun notmuch-hello (&optional no-display)
> >    "Run notmuch and display saved searches, known tags, etc."
> > --
> > 1.7.9.5
> >
> > _______________________________________________
> > notmuch mailing list
> > notmuch at notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20120708/fb6eeaf5/attachment.html>


More information about the notmuch mailing list