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

diff --git a/d9/0d74ca20bf84b21f1ae680617d6a1bff1a39fe b/d9/0d74ca20bf84b21f1ae680617d6a1bff1a39fe
new file mode 100644 (file)
index 0000000..bd5db45
--- /dev/null
@@ -0,0 +1,123 @@
+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 19B41431FD4\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 01:35:44 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\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 7yzlTucx-v1y for <notmuch@notmuchmail.org>;\r
+       Tue, 17 Apr 2012 01:35:42 -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 DF8D1431FC7\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 01:35:36 -0700 (PDT)\r
+Received: by mail-qa0-f43.google.com with SMTP id b15so225149qad.2\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Apr 2012 01:35:36 -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:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
+       :in-reply-to:references:x-gm-message-state;\r
+       bh=cI9JN7spgr90sOxN8oeJZSgD+GfYoU4XntX5CWkYh+E=;\r
+       b=Pw0S95qbfp9vdYYdAAogqd8634JqTW9J4WA38qDJ8yMsIZlfM7BCA38Oe6MuM+Ge2Q\r
+       EkVsxk04f75ok3+XbTLExSo0O2w4jQQLVf4EciCqu2Cu68eXV8bk1pf7coWgZkbQaXuJ\r
+       2XGX3A2BVMpx9Jv7kyCv9zw+B7Q/kgQkiac/NC16FI1+Dc4jVHeSxV4nzqV0teToV/1N\r
+       u8+aDDohNyWbEo9P98TtQeQ2YSd2PBBgRJOp2jWgiD8kXP2jt9wMDGI55YEeAsOfeNuv\r
+       K5zqOuMIJv5O+WkicjrYr7SRJ1mrhY8kWi/5Cmj4rTnjFcDyEpixX1F4CnC+0SAdOrXs\r
+       zQlA==\r
+Received: by 10.229.136.7 with SMTP id p7mr5896824qct.52.1334651736555;\r
+       Tue, 17 Apr 2012 01:35:36 -0700 (PDT)\r
+Received: from localhost (nikula.org. [92.243.24.172])\r
+       by mx.google.com with ESMTPS id i8sm15947250qap.0.2012.04.17.01.35.35\r
+       (version=SSLv3 cipher=OTHER); Tue, 17 Apr 2012 01:35:35 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display\r
+       message count change\r
+Date: Tue, 17 Apr 2012 08:35:24 +0000\r
+Message-Id:\r
+ <c2449d9a081e5f013da4349368f4be291d03724e.1334651669.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.1\r
+In-Reply-To:\r
+ <bcfdc0d1969997e89e5abe0b320d77ee2109796a.1334651669.git.jani@nikula.org>\r
+References:\r
+ <bcfdc0d1969997e89e5abe0b320d77ee2109796a.1334651669.git.jani@nikula.org>\r
+In-Reply-To:\r
+ <bcfdc0d1969997e89e5abe0b320d77ee2109796a.1334651669.git.jani@nikula.org>\r
+References:\r
+ <bcfdc0d1969997e89e5abe0b320d77ee2109796a.1334651669.git.jani@nikula.org>\r
+X-Gm-Message-State:\r
+ ALoCoQkg4U22FefUtW10XDcvV5wdltchQuaYCoZxx+X67ieL9WD/Lxf4PS06mU2q4phGFv3DmgkH\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 08:35:44 -0000\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
+ 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