Re: [PATCH 3/3] emacs: add notmuch hello refresh hook to display message count change
authorJani Nikula <jani@nikula.org>
Sun, 8 Jul 2012 08:20:28 +0000 (11:20 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:04 +0000 (09:48 -0800)
78/b42b81fe0ab8362e0a24e157daef9c07c38fc0 [new file with mode: 0644]

diff --git a/78/b42b81fe0ab8362e0a24e157daef9c07c38fc0 b/78/b42b81fe0ab8362e0a24e157daef9c07c38fc0
new file mode 100644 (file)
index 0000000..f61a491
--- /dev/null
@@ -0,0 +1,279 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 61246431FBC\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Jul 2012 01:20:31 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.699\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
+       tests=[HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 25U3-2NCnBZm for <notmuch@notmuchmail.org>;\r
+       Sun,  8 Jul 2012 01:20:30 -0700 (PDT)\r
+Received: from mail-ob0-f181.google.com (mail-ob0-f181.google.com\r
+       [209.85.214.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 79056431FAE\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Jul 2012 01:20:30 -0700 (PDT)\r
+Received: by obbup19 with SMTP id up19so14298438obb.26\r
+       for <notmuch@notmuchmail.org>; Sun, 08 Jul 2012 01:20:28 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=mime-version:in-reply-to:references:date:message-id:subject:from:to\r
+       :cc:content-type:x-gm-message-state;\r
+       bh=UnobBbcHrmfPPCDZ9KICABuffucwM2yARooOkwVqEQ0=;\r
+       b=WhntwzGbzlZ2WIV231+plDP3ah0gme0OEmtz8UhyV54Mrn5sHWCvdo0FbZofv0IOX8\r
+       v0EQKgHzzPGc4xrlmFcRTQhYAejt6dv205KXKnhbhu2nN0L69HUOySUlWGwTMwSnsWKe\r
+       5bcAEzy/RTyR1v43DKKdKUG5UMvv/pXVsLXPctJd7yiaTdOqmOv43k37oQzRkPmSEnSP\r
+       2+RcqFA6NOXnU+jIbmJWA1kW1rFaBImI8neFJ/SAPa8kQFjs+2vgezUw705vbcgyWY4w\r
+       hbqYWnvZtet95hCtWsOWNmNQv389wv2Qec6u4+oKoH0Gln1oprcP2SJq1pUJtt0gJclb\r
+       Z8kw==\r
+MIME-Version: 1.0\r
+Received: by 10.60.18.168 with SMTP id x8mr36878871oed.18.1341735628469; Sun,\r
+       08 Jul 2012 01:20:28 -0700 (PDT)\r
+Received: by 10.76.10.102 with HTTP; Sun, 8 Jul 2012 01:20:28 -0700 (PDT)\r
+Received: by 10.76.10.102 with HTTP; Sun, 8 Jul 2012 01:20:28 -0700 (PDT)\r
+In-Reply-To: <87zk7aviy7.fsf@qmul.ac.uk>\r
+References:\r
+ <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org>\r
+       <627aea74b0080dcd903b801042a4b2fd3868c049.1339775602.git.jani@nikula.org>\r
+       <87zk7aviy7.fsf@qmul.ac.uk>\r
+Date: Sun, 8 Jul 2012 11:20:28 +0300\r
+Message-ID:\r
+ <CAB+hUn-PnmG+=tDNaDVEhARjAeEUcSb2EOrxV8oUTqDX1MvW-A@mail.gmail.com>\r
+Subject: Re: [PATCH 3/3] emacs: add notmuch hello refresh hook to display\r
+       message count change\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Content-Type: multipart/alternative; boundary=e89a8ff2561a84752f04c44d2bd2\r
+X-Gm-Message-State:\r
+ ALoCoQm6n5GEvDTL9elR1plIrGnFbpd8WENq54d6YILDtkXjMrWmEVXalJJ9FTa202bgfcwRAu8L\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 08 Jul 2012 08:20:31 -0000\r
+\r
+--e89a8ff2561a84752f04c44d2bd2\r
+Content-Type: text/plain; charset=UTF-8\r
+\r
+On Jul 8, 2012 9:57 AM, "Mark Walters" <markwalters1009@gmail.com> wrote:\r
+>\r
+> On Fri, 15 Jun 2012, Jani Nikula <jani@nikula.org> wrote:\r
+> > Add a notmuch hello refresh hook to display a message about change in\r
+> > message count in the database since the notmuch-hello buffer was last\r
+> > refreshed manually (no-display is nil).\r
+> >\r
+> > Signed-off-by: Jani Nikula <jani@nikula.org>\r
+>\r
+> Hi\r
+>\r
+> I just have a couple of comments/queries. First, since it breaks\r
+> existing hooks I think it needs a NEWS item.\r
+\r
+Sure.\r
+\r
+> Secondly, I, personally, would much prefer the hook with the slight\r
+> tweak that it counts inbox messages rather than all messages. Is that\r
+> an option that could be put in the defcustom?\r
+\r
+I suppose the query could be customizable. That's simple enough; for\r
+anything non-trivial people can write their own hooks.\r
+\r
+BR,\r
+Jani.\r
+\r
+>\r
+> Best wishes\r
+>\r
+> Mark\r
+>\r
+> > ---\r
+> >  emacs/notmuch-hello.el |   27 +++++++++++++++++++++++++++\r
+> >  1 file changed, 27 insertions(+)\r
+> >\r
+> > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+> > index bc43178..bcca044 100644\r
+> > --- a/emacs/notmuch-hello.el\r
+> > +++ b/emacs/notmuch-hello.el\r
+> > @@ -148,6 +148,7 @@ International Bureau of Weights and Measures."\r
+> >  (defcustom notmuch-hello-refresh-hook nil\r
+> >    "Functions called after updating a `notmuch-hello' buffer."\r
+> >    :type 'hook\r
+> > +  :options '(notmuch-hello-refresh-status-message)\r
+> >    :group 'notmuch-hello\r
+> >    :group 'notmuch-hooks)\r
+> >\r
+> > @@ -749,6 +750,32 @@ following:\r
+> >      (let ((fill-column (- (window-width) notmuch-hello-indent)))\r
+> >        (center-region start (point)))))\r
+> >\r
+> > +(defvar notmuch-hello-refresh-count 0\r
+> > +  "Number of messages in the database when `notmuch-hello' was last\r
+run.\r
+> > +\r
+> > +Used internally by `notmuch-hello-refresh-status-message'.")\r
+> > +\r
+> > +(defun notmuch-hello-refresh-status-message (no-display)\r
+> > +  "Hook to display a status message when refreshing notmuch-hello\r
+buffer.\r
+> > +\r
+> > +Display a status message about the difference in message count in\r
+> > +the database since the last call."\r
+> > +  (unless no-display\r
+> > +    (let* ((new-count\r
+> > +         (string-to-number (car (process-lines notmuch-command\r
+"count"))))\r
+> > +        (diff-count (- new-count notmuch-hello-refresh-count)))\r
+> > +      (cond\r
+> > +       ((= notmuch-hello-refresh-count 0)\r
+> > +     (message "You have %s messages."\r
+> > +              (notmuch-hello-nice-number new-count)))\r
+> > +       ((> diff-count 0)\r
+> > +     (message "You have %s more messages since last refresh."\r
+> > +              (notmuch-hello-nice-number diff-count)))\r
+> > +       ((< diff-count 0)\r
+> > +     (message "You have %s fewer messages since last refresh."\r
+> > +              (notmuch-hello-nice-number (- diff-count)))))\r
+> > +      (setq notmuch-hello-refresh-count new-count))))\r
+> > +\r
+> >  ;;;###autoload\r
+> >  (defun notmuch-hello (&optional no-display)\r
+> >    "Run notmuch and display saved searches, known tags, etc."\r
+> > --\r
+> > 1.7.9.5\r
+> >\r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+--e89a8ff2561a84752f04c44d2bd2\r
+Content-Type: text/html; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+<p><br>\r
+On Jul 8, 2012 9:57 AM, &quot;Mark Walters&quot; &lt;<a href=3D"mailto:mark=\r
+walters1009@gmail.com">markwalters1009@gmail.com</a>&gt; wrote:<br>\r
+&gt;<br>\r
+&gt; On Fri, 15 Jun 2012, Jani Nikula &lt;<a href=3D"mailto:jani@nikula.org=\r
+">jani@nikula.org</a>&gt; wrote:<br>\r
+&gt; &gt; Add a notmuch hello refresh hook to display a message about chang=\r
+e in<br>\r
+&gt; &gt; message count in the database since the notmuch-hello buffer was =\r
+last<br>\r
+&gt; &gt; refreshed manually (no-display is nil).<br>\r
+&gt; &gt;<br>\r
+&gt; &gt; Signed-off-by: Jani Nikula &lt;<a href=3D"mailto:jani@nikula.org"=\r
+>jani@nikula.org</a>&gt;<br>\r
+&gt;<br>\r
+&gt; Hi<br>\r
+&gt;<br>\r
+&gt; I just have a couple of comments/queries. First, since it breaks<br>\r
+&gt; existing hooks I think it needs a NEWS item.</p>\r
+<p>Sure.</p>\r
+<p>&gt; Secondly, I, personally, would much prefer the hook with the slight=\r
+<br>\r
+&gt; tweak that it counts inbox messages rather than all messages. Is that<=\r
+br>\r
+&gt; an option that could be put in the defcustom?</p>\r
+<p>I suppose the query could be customizable. That&#39;s simple enough; for=\r
+ anything non-trivial people can write their own hooks.</p>\r
+<p>BR,<br>\r
+Jani.</p>\r
+<p>&gt;<br>\r
+&gt; Best wishes<br>\r
+&gt;<br>\r
+&gt; Mark<br>\r
+&gt;<br>\r
+&gt; &gt; ---<br>\r
+&gt; &gt; =C2=A0emacs/notmuch-hello.el | =C2=A0 27 ++++++++++++++++++++++++=\r
++++<br>\r
+&gt; &gt; =C2=A01 file changed, 27 insertions(+)<br>\r
+&gt; &gt;<br>\r
+&gt; &gt; diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el<br>\r
+&gt; &gt; index bc43178..bcca044 100644<br>\r
+&gt; &gt; --- a/emacs/notmuch-hello.el<br>\r
+&gt; &gt; +++ b/emacs/notmuch-hello.el<br>\r
+&gt; &gt; @@ -148,6 +148,7 @@ International Bureau of Weights and Measures.=\r
+&quot;<br>\r
+&gt; &gt; =C2=A0(defcustom notmuch-hello-refresh-hook nil<br>\r
+&gt; &gt; =C2=A0 =C2=A0&quot;Functions called after updating a `notmuch-hel=\r
+lo&#39; buffer.&quot;<br>\r
+&gt; &gt; =C2=A0 =C2=A0:type &#39;hook<br>\r
+&gt; &gt; + =C2=A0:options &#39;(notmuch-hello-refresh-status-message)<br>\r
+&gt; &gt; =C2=A0 =C2=A0:group &#39;notmuch-hello<br>\r
+&gt; &gt; =C2=A0 =C2=A0:group &#39;notmuch-hooks)<br>\r
+&gt; &gt;<br>\r
+&gt; &gt; @@ -749,6 +750,32 @@ following:<br>\r
+&gt; &gt; =C2=A0 =C2=A0 =C2=A0(let ((fill-column (- (window-width) notmuch-=\r
+hello-indent)))<br>\r
+&gt; &gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0(center-region start (point)))))<br>\r
+&gt; &gt;<br>\r
+&gt; &gt; +(defvar notmuch-hello-refresh-count 0<br>\r
+&gt; &gt; + =C2=A0&quot;Number of messages in the database when `notmuch-he=\r
+llo&#39; was last run.<br>\r
+&gt; &gt; +<br>\r
+&gt; &gt; +Used internally by `notmuch-hello-refresh-status-message&#39;.&q=\r
+uot;)<br>\r
+&gt; &gt; +<br>\r
+&gt; &gt; +(defun notmuch-hello-refresh-status-message (no-display)<br>\r
+&gt; &gt; + =C2=A0&quot;Hook to display a status message when refreshing no=\r
+tmuch-hello buffer.<br>\r
+&gt; &gt; +<br>\r
+&gt; &gt; +Display a status message about the difference in message count i=\r
+n<br>\r
+&gt; &gt; +the database since the last call.&quot;<br>\r
+&gt; &gt; + =C2=A0(unless no-display<br>\r
+&gt; &gt; + =C2=A0 =C2=A0(let* ((new-count<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 (string-to-number (car (process-lin=\r
+es notmuch-command &quot;count&quot;))))<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0(diff-count (- new-count notmuch-hel=\r
+lo-refresh-count)))<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 =C2=A0(cond<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 =C2=A0 ((=3D notmuch-hello-refresh-count 0)<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 (message &quot;You have %s messages.&quot;<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-hello-=\r
+nice-number new-count)))<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 =C2=A0 ((&gt; diff-count 0)<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 (message &quot;You have %s more messages since la=\r
+st refresh.&quot;<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-hello-=\r
+nice-number diff-count)))<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 =C2=A0 ((&lt; diff-count 0)<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 (message &quot;You have %s fewer messages since l=\r
+ast refresh.&quot;<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-hello-=\r
+nice-number (- diff-count)))))<br>\r
+&gt; &gt; + =C2=A0 =C2=A0 =C2=A0(setq notmuch-hello-refresh-count new-count=\r
+))))<br>\r
+&gt; &gt; +<br>\r
+&gt; &gt; =C2=A0;;;###autoload<br>\r
+&gt; &gt; =C2=A0(defun notmuch-hello (&amp;optional no-display)<br>\r
+&gt; &gt; =C2=A0 =C2=A0&quot;Run notmuch and display saved searches, known =\r
+tags, etc.&quot;<br>\r
+&gt; &gt; --<br>\r
+&gt; &gt; 1.7.9.5<br>\r
+&gt; &gt;<br>\r
+&gt; &gt; _______________________________________________<br>\r
+&gt; &gt; notmuch mailing list<br>\r
+&gt; &gt; <a href=3D"mailto:notmuch@notmuchmail.org">notmuch@notmuchmail.or=\r
+g</a><br>\r
+&gt; &gt; <a href=3D"http://notmuchmail.org/mailman/listinfo/notmuch">http:=\r
+//notmuchmail.org/mailman/listinfo/notmuch</a><br>\r
+</p>\r
+\r
+--e89a8ff2561a84752f04c44d2bd2--\r