From cc213b05504ff4d892354b60c73502bdf1651842 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sun, 8 Jul 2012 11:20:28 +0300 Subject: [PATCH] Re: [PATCH 3/3] emacs: add notmuch hello refresh hook to display message count change --- 78/b42b81fe0ab8362e0a24e157daef9c07c38fc0 | 279 ++++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 78/b42b81fe0ab8362e0a24e157daef9c07c38fc0 diff --git a/78/b42b81fe0ab8362e0a24e157daef9c07c38fc0 b/78/b42b81fe0ab8362e0a24e157daef9c07c38fc0 new file mode 100644 index 000000000..f61a49168 --- /dev/null +++ b/78/b42b81fe0ab8362e0a24e157daef9c07c38fc0 @@ -0,0 +1,279 @@ +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 61246431FBC + for ; Sun, 8 Jul 2012 01:20:31 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.699 +X-Spam-Level: +X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 + tests=[HTML_MESSAGE=0.001, 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 25U3-2NCnBZm for ; + Sun, 8 Jul 2012 01:20:30 -0700 (PDT) +Received: from mail-ob0-f181.google.com (mail-ob0-f181.google.com + [209.85.214.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 79056431FAE + for ; Sun, 8 Jul 2012 01:20:30 -0700 (PDT) +Received: by obbup19 with SMTP id up19so14298438obb.26 + for ; Sun, 08 Jul 2012 01:20:28 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=mime-version:in-reply-to:references:date:message-id:subject:from:to + :cc:content-type:x-gm-message-state; + bh=UnobBbcHrmfPPCDZ9KICABuffucwM2yARooOkwVqEQ0=; + b=WhntwzGbzlZ2WIV231+plDP3ah0gme0OEmtz8UhyV54Mrn5sHWCvdo0FbZofv0IOX8 + v0EQKgHzzPGc4xrlmFcRTQhYAejt6dv205KXKnhbhu2nN0L69HUOySUlWGwTMwSnsWKe + 5bcAEzy/RTyR1v43DKKdKUG5UMvv/pXVsLXPctJd7yiaTdOqmOv43k37oQzRkPmSEnSP + 2+RcqFA6NOXnU+jIbmJWA1kW1rFaBImI8neFJ/SAPa8kQFjs+2vgezUw705vbcgyWY4w + hbqYWnvZtet95hCtWsOWNmNQv389wv2Qec6u4+oKoH0Gln1oprcP2SJq1pUJtt0gJclb + Z8kw== +MIME-Version: 1.0 +Received: by 10.60.18.168 with SMTP id x8mr36878871oed.18.1341735628469; Sun, + 08 Jul 2012 01:20:28 -0700 (PDT) +Received: by 10.76.10.102 with HTTP; Sun, 8 Jul 2012 01:20:28 -0700 (PDT) +Received: by 10.76.10.102 with HTTP; Sun, 8 Jul 2012 01:20:28 -0700 (PDT) +In-Reply-To: <87zk7aviy7.fsf@qmul.ac.uk> +References: + <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org> + <627aea74b0080dcd903b801042a4b2fd3868c049.1339775602.git.jani@nikula.org> + <87zk7aviy7.fsf@qmul.ac.uk> +Date: Sun, 8 Jul 2012 11:20:28 +0300 +Message-ID: + +Subject: Re: [PATCH 3/3] emacs: add notmuch hello refresh hook to display + message count change +From: Jani Nikula +To: Mark Walters +Content-Type: multipart/alternative; boundary=e89a8ff2561a84752f04c44d2bd2 +X-Gm-Message-State: + ALoCoQm6n5GEvDTL9elR1plIrGnFbpd8WENq54d6YILDtkXjMrWmEVXalJJ9FTa202bgfcwRAu8L +Cc: notmuch@notmuchmail.org +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: Sun, 08 Jul 2012 08:20:31 -0000 + +--e89a8ff2561a84752f04c44d2bd2 +Content-Type: text/plain; charset=UTF-8 + +On Jul 8, 2012 9:57 AM, "Mark Walters" wrote: +> +> On Fri, 15 Jun 2012, Jani Nikula 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 +> +> 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@notmuchmail.org +> > http://notmuchmail.org/mailman/listinfo/notmuch + +--e89a8ff2561a84752f04c44d2bd2 +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +


+On Jul 8, 2012 9:57 AM, "Mark Walters" <markwalters1009@gmail.com> wrote:
+>
+> On Fri, 15 Jun 2012, Jani Nikula <jani@nikula.org> wrote:
+> > Add a notmuch hello refresh hook to display a message about chang= +e 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@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<= +br> +> 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
+>
+> > ---
+> > =C2=A0emacs/notmuch-hello.el | =C2=A0 27 ++++++++++++++++++++++++= ++++
+> > =C2=A01 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.= +"
+> > =C2=A0(defcustom notmuch-hello-refresh-hook nil
+> > =C2=A0 =C2=A0"Functions called after updating a `notmuch-hel= +lo' buffer."
+> > =C2=A0 =C2=A0:type 'hook
+> > + =C2=A0:options '(notmuch-hello-refresh-status-message)
+> > =C2=A0 =C2=A0:group 'notmuch-hello
+> > =C2=A0 =C2=A0:group 'notmuch-hooks)
+> >
+> > @@ -749,6 +750,32 @@ following:
+> > =C2=A0 =C2=A0 =C2=A0(let ((fill-column (- (window-width) notmuch-= +hello-indent)))
+> > =C2=A0 =C2=A0 =C2=A0 =C2=A0(center-region start (point)))))
+> >
+> > +(defvar notmuch-hello-refresh-count 0
+> > + =C2=A0"Number of messages in the database when `notmuch-he= +llo' was last run.
+> > +
+> > +Used internally by `notmuch-hello-refresh-status-message'.&q= +uot;)
+> > +
+> > +(defun notmuch-hello-refresh-status-message (no-display)
+> > + =C2=A0"Hook to display a status message when refreshing no= +tmuch-hello buffer.
+> > +
+> > +Display a status message about the difference in message count i= +n
+> > +the database since the last call."
+> > + =C2=A0(unless no-display
+> > + =C2=A0 =C2=A0(let* ((new-count
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 (string-to-number (car (process-lin= +es notmuch-command "count"))))
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0(diff-count (- new-count notmuch-hel= +lo-refresh-count)))
+> > + =C2=A0 =C2=A0 =C2=A0(cond
+> > + =C2=A0 =C2=A0 =C2=A0 ((=3D notmuch-hello-refresh-count 0)
+> > + =C2=A0 =C2=A0 (message "You have %s messages."
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-hello-= +nice-number new-count)))
+> > + =C2=A0 =C2=A0 =C2=A0 ((> diff-count 0)
+> > + =C2=A0 =C2=A0 (message "You have %s more messages since la= +st refresh."
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-hello-= +nice-number diff-count)))
+> > + =C2=A0 =C2=A0 =C2=A0 ((< diff-count 0)
+> > + =C2=A0 =C2=A0 (message "You have %s fewer messages since l= +ast refresh."
+> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-hello-= +nice-number (- diff-count)))))
+> > + =C2=A0 =C2=A0 =C2=A0(setq notmuch-hello-refresh-count new-count= +))))
+> > +
+> > =C2=A0;;;###autoload
+> > =C2=A0(defun notmuch-hello (&optional no-display)
+> > =C2=A0 =C2=A0"Run notmuch and display saved searches, known = +tags, etc."
+> > --
+> > 1.7.9.5
+> >
+> > _______________________________________________
+> > notmuch mailing list
+> > notmuch@notmuchmail.or= +g
+> > http:= +//notmuchmail.org/mailman/listinfo/notmuch
+

+ +--e89a8ff2561a84752f04c44d2bd2-- -- 2.26.2