Re: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display message count...
authorJani Nikula <jani@nikula.org>
Tue, 17 Apr 2012 09:35:28 +0000 (09:35 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:30 +0000 (09:46 -0800)
6f/e353d2ceab11381238ca4ba5edeceb4dec36da [new file with mode: 0644]

diff --git a/6f/e353d2ceab11381238ca4ba5edeceb4dec36da b/6f/e353d2ceab11381238ca4ba5edeceb4dec36da
new file mode 100644 (file)
index 0000000..19eb7b7
--- /dev/null
@@ -0,0 +1,150 @@
+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 0C41C431FB6\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:35:34 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[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 tAQk57ICccCb for <notmuch@notmuchmail.org>;\r
+       Tue, 17 Apr 2012 02:35:33 -0700 (PDT)\r
+Received: from mail-qa0-f43.google.com (mail-qa0-f43.google.com\r
+       [209.85.216.43]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 580F5431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:35:33 -0700 (PDT)\r
+Received: by qadb15 with SMTP id b15so259245qad.2\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:35:32 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type:x-gm-message-state;\r
+       bh=Mr8EorY1W/3t/hs/Z/pGrpY83ajsjC3EiE41/4l04wc=;\r
+       b=ei7gmmbMzmdON5JvYvKxLTMc0iWAxOYjwpn0L7BJ0FXtr6k4GAFIUSmjbNZekZs5jP\r
+       SVpXeIti1v9Jc2CFvMqHC0tmsOEb00xAzNtjsuVq5QxEWB9bsjCFQI1iGRUrbW8jJVf1\r
+       /YWMxFx4KOhCQfsrJ61tUZpEo98C2AfldnIsHS/uzpIB52aVfu0hVDFqVpCdmdJGDFXO\r
+       gNpIck569gi/9990p2BXkhPuHlDYA4fhro38DDjj0sQZ8jAgteOWGJTHRp9IOprjzctV\r
+       ZRyL5NQrwMeFKNFmpJMmW4fNhFlgfacT8bTWakUAOFO5hADCYblRb4yrU8M8AOSCj2wL\r
+       5Yqg==\r
+Received: by 10.229.137.3 with SMTP id u3mr6301746qct.20.1334655332663;\r
+       Tue, 17 Apr 2012 02:35:32 -0700 (PDT)\r
+Received: from localhost (nikula.org. [92.243.24.172])\r
+       by mx.google.com with ESMTPS id dm8sm39266459qab.18.2012.04.17.02.35.31\r
+       (version=SSLv3 cipher=OTHER); Tue, 17 Apr 2012 02:35:31 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display\r
+       message count change\r
+In-Reply-To: <874nsioh5g.fsf@gmail.com>\r
+References:\r
+ <bcfdc0d1969997e89e5abe0b320d77ee2109796a.1334651669.git.jani@nikula.org>\r
+       <c2449d9a081e5f013da4349368f4be291d03724e.1334651669.git.jani@nikula.org>\r
+       <874nsioh5g.fsf@gmail.com>\r
+User-Agent: Notmuch/0.11.1+222~ga47a98c (http://notmuchmail.org) Emacs/23.1.1\r
+       (i686-pc-linux-gnu)\r
+Date: Tue, 17 Apr 2012 09:35:28 +0000\r
+Message-ID: <87ehrmvgyn.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Gm-Message-State:\r
+ ALoCoQnn36pr8RGzDkZ0gNy32A/W1hunjH/fHlgPf39zhd9u97DIEjwjFIdgzfwHOwmbZxyCELsu\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: Tue, 17 Apr 2012 09:35:34 -0000\r
+\r
+On Tue, 17 Apr 2012 13:13:15 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:\r
+> Jani Nikula <jani@nikula.org> writes:\r
+> \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
+> I like this idea.  But IMO we should avoid another call to notmuch\r
+> count.  Notmuch-hello buffer already displays the message count on the\r
+> first line.  I would propose to implement this functionality not as a\r
+> hook but as part of the section which outputs the first line.  We can\r
+> add an option to disable it if you prefer but I do not think it is\r
+> needed.  This is less flexible than a hook, but IMO it is not a big\r
+> issue.\r
+\r
+And what if someone has disabled the header section but would want the\r
+message? Also, you'd have to pass no-display there too. IMHO one call to\r
+notmuch count is not a big issue, especially for an optional feature.\r
+And having it as a hook very nicely isolates the feature from everything\r
+else.\r
+\r
+Jani.\r
+\r
+\r
+> \r
+> Regards,\r
+>   Dmitry\r
+> \r
+> > ---\r
+> >  emacs/notmuch-hello.el |   23 +++++++++++++++++++++++\r
+> >  1 files changed, 23 insertions(+), 0 deletions(-)\r
+> >\r
+> > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+> > index 0596bbe..13da146 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
+> > @@ -729,6 +730,28 @@ 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 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 buffer."\r
+> > +  (unless no-display\r
+> > +    (let* ((new-count\r
+> > +      (string-to-number (car (process-lines notmuch-command "count"))))\r
+> > +     (diff-count (- new-count notmuch-hello-refresh-count)))\r
+> > +      (if (= notmuch-hello-refresh-count 0)\r
+> > +    (message "You have %s messages."\r
+> > +             (notmuch-hello-nice-number new-count))\r
+> > +  (if (not (= diff-count 0))\r
+> > +      (if (>= diff-count 0)\r
+> > +          (message "You have %s more messages since last refresh."\r
+> > +                   (notmuch-hello-nice-number diff-count))\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.1\r
+> >\r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > http://notmuchmail.org/mailman/listinfo/notmuch\r