[PATCH 3/3] emacs: add notmuch hello refresh hook to display message count change
authorJani Nikula <jani@nikula.org>
Fri, 15 Jun 2012 15:53:44 +0000 (18:53 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:41 +0000 (09:47 -0800)
a6/f6b0536a66f12106fdbfa9a6c64795f8ea5a9e [new file with mode: 0644]

diff --git a/a6/f6b0536a66f12106fdbfa9a6c64795f8ea5a9e b/a6/f6b0536a66f12106fdbfa9a6c64795f8ea5a9e
new file mode 100644 (file)
index 0000000..64f5df4
--- /dev/null
@@ -0,0 +1,130 @@
+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 DEB10431FC0\r
+       for <notmuch@notmuchmail.org>; Fri, 15 Jun 2012 08:53:59 -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 EeV7ntdOqcul for <notmuch@notmuchmail.org>;\r
+       Fri, 15 Jun 2012 08:53:58 -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 59EDB431FC3\r
+       for <notmuch@notmuchmail.org>; Fri, 15 Jun 2012 08:53:55 -0700 (PDT)\r
+Received: by mail-lpp01m010-f53.google.com with SMTP id u2so2337793lag.26\r
+       for <notmuch@notmuchmail.org>; Fri, 15 Jun 2012 08:53:55 -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=VzQTZiy3GXoadDahhaTRSeWkIxyRvSSBTnWReEwUKuA=;\r
+       b=jFuZUquyWou+uQ8pWWnQyhzJ1MJ8JxlxkESWfTMcoMW4B5zZ15kECODQgT4wLuh4gi\r
+       PodetXshlHLX7eNnjUUoIBWV/Ipp5W8csFZ3VHQe4z8+KCCxVNnaAL5D9A1LJXMFopbk\r
+       EuFVc3tAUWlNytsIHat3m0dP6QuriMHT9yjqw5YrwjAy5HGZggZML970gKzTYWCWGrxc\r
+       kHbo1kJ4YgXsUJ6eCehEEE21srWV5AI1QWXyvJunfKG1tPFeVuHoWYnJIINb9fzVl372\r
+       eFuDLfiGNefRmKCkKHectkZy3Bx2fB4FG0//8AEewQqia+DrXpCWAqP/fW2JLdD0EpmQ\r
+       iePw==\r
+Received: by 10.152.123.244 with SMTP id md20mr6085677lab.0.1339775634962;\r
+       Fri, 15 Jun 2012 08:53:54 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi.\r
+       [80.220.80.68])\r
+       by mx.google.com with ESMTPS id k4sm6420333lbb.12.2012.06.15.08.53.53\r
+       (version=SSLv3 cipher=OTHER); Fri, 15 Jun 2012 08:53:54 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/3] emacs: add notmuch hello refresh hook to display message\r
+       count change\r
+Date: Fri, 15 Jun 2012 18:53:44 +0300\r
+Message-Id:\r
+ <627aea74b0080dcd903b801042a4b2fd3868c049.1339775602.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.9.5\r
+In-Reply-To:\r
+ <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org>\r
+References:\r
+ <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org>\r
+In-Reply-To:\r
+ <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org>\r
+References:\r
+ <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org>\r
+X-Gm-Message-State:\r
+ ALoCoQmAdPfZETe1lMt1mGspoGL/Rp63pYH801N/czhy0CG82foGlZnajh8/CbCjZBaFs5cVfy0D\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: Fri, 15 Jun 2012 15:54:00 -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
+Signed-off-by: Jani Nikula <jani@nikula.org>\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 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
++\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 "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