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:13:15 +0000 (13:13 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:30 +0000 (09:46 -0800)
c0/415f6f67961d7f16c8a94ed21751450f67e3f0 [new file with mode: 0644]

diff --git a/c0/415f6f67961d7f16c8a94ed21751450f67e3f0 b/c0/415f6f67961d7f16c8a94ed21751450f67e3f0
new file mode 100644 (file)
index 0000000..04b173d
--- /dev/null
@@ -0,0 +1,138 @@
+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 3FAE9431FB6\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:15:12 -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 RCf9MelaOOJY for <notmuch@notmuchmail.org>;\r
+       Tue, 17 Apr 2012 02:15:07 -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 94BCC431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:15:07 -0700 (PDT)\r
+Received: by lahc1 with SMTP id c1so4765502lah.26\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 02:15:06 -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=990vjPpnDm9P+RsMbwGOjAQEsYqB1PzKu6MCSN829Jo=;\r
+       b=ilRX6A19bxQW5rlWt3sYmKRCY8Uw+pQBzK7p76dRSJjlTGxJsTH3NoB4kTgNzYfO0L\r
+       WmYCzTyIA2Y0bIVVpmRvZczNlhjij1S+yZHYFeDbtZ549C+zhavlUwWg+BF/OeBvqnO+\r
+       wrXfvsPOQcsbXzKFRXosu7eN8FhEs1r8KrUC7vzSTaOqJOtc94jqAoK6gfXaEF5yBzhu\r
+       n9zI2jB2Gc3ZMTqp4Y6HAgnUSNqAJB51I6ctzzTJD/8Awq7Xtukd0yWscYSAAjelXkwY\r
+       6w3AsL5qWJze6rt7pu+c1+5qnIVzSLUsvz5iXpUAc8FC2RQ8CH5Rs+RvqipnJzYzipX+\r
+       tsvw==\r
+Received: by 10.112.99.38 with SMTP id en6mr6884321lbb.48.1334654105990;\r
+       Tue, 17 Apr 2012 02:15:05 -0700 (PDT)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id nv7sm10605563lab.9.2012.04.17.02.15.04\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Tue, 17 Apr 2012 02:15:05 -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:\r
+ <c2449d9a081e5f013da4349368f4be291d03724e.1334651669.git.jani@nikula.org>\r
+References:\r
+ <bcfdc0d1969997e89e5abe0b320d77ee2109796a.1334651669.git.jani@nikula.org>\r
+       <c2449d9a081e5f013da4349368f4be291d03724e.1334651669.git.jani@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:13:15 +0400\r
+Message-ID: <874nsioh5g.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:15:12 -0000\r
+\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
+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