Re: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display message count...
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Tue, 17 Apr 2012 09:43:28 +0000 (13:43 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:31 +0000 (09:46 -0800)
bf/e31911c153a58ee7b6a9efda8cf991d6a727a3 [new file with mode: 0644]

diff --git a/bf/e31911c153a58ee7b6a9efda8cf991d6a727a3 b/bf/e31911c153a58ee7b6a9efda8cf991d6a727a3
new file mode 100644 (file)
index 0000000..de865d1
--- /dev/null
@@ -0,0 +1,169 @@
+Return-Path: <dmitry.kurochkin@gmail.com>\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 2C1A0431FB6\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:45:24 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=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 4Z-GpKARgmIN for <notmuch@notmuchmail.org>;\r
+       Tue, 17 Apr 2012 02:45:20 -0700 (PDT)\r
+Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com\r
+       [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 16AB1431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:45:19 -0700 (PDT)\r
+Received: by lahc1 with SMTP id c1so4783588lah.26\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:45:18 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type;\r
+       bh=UNvkLiMfVtnWdjYrEglmE1YKerzn6wCJlBOAChpyl5w=;\r
+       b=sdlsSzS0WDvf62rcNx/h/52UWHqEghcWMiK0LVwsXS514aD+xaJw1Bw2GrurBituFR\r
+       f1F6nvlkzy8xtIohAF31S2HoRWKfZv/5y69D5gHTohaj/0dCc1K/J3sMHy5vccOUoKNl\r
+       KBMMgiL/KYemjnNECnx5VAiBa+pRegLXChzS2ObmkS2fF/SqbXNZ4y8XE4wCjbFed0Bv\r
+       9UUz4J4669Ute9A08i78kO4ghJqUk4toASYLnpHOOh4eBFQwoRjgUVKM919IWdwXeRwO\r
+       r7IUOoMiZDWzFzpu5DMrErMZquWwdtYa/H1OPqUnjfdC5iiyr/2RORc3D0NcQo8Zqx+H\r
+       8hqA==\r
+Received: by 10.112.48.36 with SMTP id i4mr6900644lbn.84.1334655918454;\r
+       Tue, 17 Apr 2012 02:45:18 -0700 (PDT)\r
+Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id\r
+       gw17sm22284179lab.11.2012.04.17.02.45.17\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Tue, 17 Apr 2012 02:45:17 -0700 (PDT)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: Jani Nikula <jani@nikula.org>, 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: <87ehrmvgyn.fsf@nikula.org>\r
+References:\r
+ <bcfdc0d1969997e89e5abe0b320d77ee2109796a.1334651669.git.jani@nikula.org>\r
+       <c2449d9a081e5f013da4349368f4be291d03724e.1334651669.git.jani@nikula.org>\r
+       <874nsioh5g.fsf@gmail.com> <87ehrmvgyn.fsf@nikula.org>\r
+User-Agent: Notmuch/0.12+104~gf9ad237 (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Tue, 17 Apr 2012 13:43:28 +0400\r
+Message-ID: <87vckyn16n.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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:45:24 -0000\r
+\r
+Jani Nikula <jani@nikula.org> writes:\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?\r
+\r
+Well, that is what I meant by "less flexible than a hook".\r
+\r
+> Also, you'd have to pass no-display there too.\r
+\r
+Sure, we can pass it to sections.\r
+\r
+> 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
+\r
+I think this feature should be enabled by default.\r
+\r
+I guess you are right that it is not a big issue.  I still think we\r
+would be better without it (and we still can isolate the feature), but I\r
+would not object to having the extra call.\r
+\r
+Regards,\r
+  Dmitry\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