From: Jani Nikula Date: Sun, 2 Sep 2012 14:48:36 +0000 (+0300) Subject: [PATCH v2 4/5] emacs: add notmuch hello refresh hook to display message count change X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=964541930fd31a457cbf3ba36bfc7e5dc016e99c;p=notmuch-archives.git [PATCH v2 4/5] emacs: add notmuch hello refresh hook to display message count change --- diff --git a/78/cf9d57d4fca35993345f14d1f909bd3cb0a822 b/78/cf9d57d4fca35993345f14d1f909bd3cb0a822 new file mode 100644 index 000000000..ab35c9f0d --- /dev/null +++ b/78/cf9d57d4fca35993345f14d1f909bd3cb0a822 @@ -0,0 +1,137 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id E7956431FC0 + for ; Sun, 2 Sep 2012 07:49:03 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id M0p1JxO-RvlQ for ; + Sun, 2 Sep 2012 07:49:01 -0700 (PDT) +Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com + [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 36066431E62 + for ; Sun, 2 Sep 2012 07:48:53 -0700 (PDT) +Received: by mail-lpp01m010-f53.google.com with SMTP id c1so3338105lah.26 + for ; Sun, 02 Sep 2012 07:48:53 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references + :in-reply-to:references:x-gm-message-state; + bh=lpkbhuiH9hr11QEWg7A3rntVi7TM/yHv4iz0RQC2x94=; + b=JX9u+XX1nco8jiyA7chLQ0REJ3Qw3c44hksnZ6z1m7il1RBUy9IxTY3LLbWyy8J5x9 + Q60h4Gnmqb4vXvjGN/Yc0FNOiMfB4VpkfhCCHlswEGce2l47mVG7kDBkGGJspdpuPMlc + iEZKf1LNEDpfEPmF2dq5TB9b/bqXRoEPnvluAHvvUGuiutVM5tzWuoR15YZg81KUr/0U + 4I7lBqf2sA5UQzM2HE/JlXaqexNx/jiK5sP2S1RtjFoWTBn/FSx8zZls5DvJ+/xqZMjS + F3lCtSH3b35o7XDqqDjtluc3w9oEngPbvMsxzLi+cL7Wvvn/ap+a1DmiqalAukxtelM4 + szGA== +Received: by 10.152.132.133 with SMTP id ou5mr11535308lab.45.1346597333679; + Sun, 02 Sep 2012 07:48:53 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. + [80.223.81.27]) + by mx.google.com with ESMTPS id mq9sm10741917lab.0.2012.09.02.07.48.52 + (version=SSLv3 cipher=OTHER); Sun, 02 Sep 2012 07:48:52 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH v2 4/5] emacs: add notmuch hello refresh hook to display + message count change +Date: Sun, 2 Sep 2012 17:48:36 +0300 +Message-Id: + <68598461de8be62156ce21545baeb2ab325fa817.1346596156.git.jani@nikula.org> +X-Mailer: git-send-email 1.7.9.5 +In-Reply-To: +References: +In-Reply-To: +References: +X-Gm-Message-State: + ALoCoQkvRIidSe+0zxgATcR9NHm7Q7JRYPA/zuSPH1CfNgCFtKUlwOte9s1mR2Te6Abq3UNkXovW +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 02 Sep 2012 14:49:04 -0000 + +Add a notmuch hello refresh hook to display a message about change in +message count in the database since the notmuch-hello buffer was last +refreshed manually (no-display is nil). + +Signed-off-by: Jani Nikula +--- + emacs/notmuch-hello.el | 38 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 38 insertions(+) + +diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +index fa14443..f7a3c95 100644 +--- a/emacs/notmuch-hello.el ++++ b/emacs/notmuch-hello.el +@@ -148,6 +148,7 @@ International Bureau of Weights and Measures." + (defcustom notmuch-hello-refresh-hook nil + "Functions called after updating a `notmuch-hello' buffer." + :type 'hook ++ :options '(notmuch-hello-refresh-status-message) + :group 'notmuch-hello + :group 'notmuch-hooks) + +@@ -749,6 +750,43 @@ following: + (let ((fill-column (- (window-width) notmuch-hello-indent))) + (center-region start (point))))) + ++(defcustom notmuch-hello-refresh-status-query "*" ++ "Query to use for `notmuch-hello-refresh-status-message' hook." ++ :type '(choice (const :tag "All messages" "*") ++ (string :tag "Custom query" ++ :value "tag:inbox")) ++ :group 'notmuch-hello) ++ ++(defvar notmuch-hello-refresh-count 0 ++ "Number of matching messages when `notmuch-hello' was last run. ++ ++Used internally by `notmuch-hello-refresh-status-message'.") ++ ++(defun notmuch-hello-refresh-status-message (no-display) ++ "Hook to display a status message when refreshing notmuch-hello buffer. ++ ++Display a status message about the difference in message count ++matching `notmuch-hello-refresh-status-query' since the last time ++notmuch-hello was refreshed. Only takes into account explicit ++refreshes (NO-DISPLAY is nil)." ++ (unless no-display ++ (let* ((new-count ++ (string-to-number ++ (car (process-lines notmuch-command "count" ++ notmuch-hello-refresh-status-query)))) ++ (diff-count (- new-count notmuch-hello-refresh-count))) ++ (cond ++ ((= notmuch-hello-refresh-count 0) ++ (message "You have %s messages." ++ (notmuch-hello-nice-number new-count))) ++ ((> diff-count 0) ++ (message "You have %s more messages since last refresh." ++ (notmuch-hello-nice-number diff-count))) ++ ((< diff-count 0) ++ (message "You have %s fewer messages since last refresh." ++ (notmuch-hello-nice-number (- diff-count))))) ++ (setq notmuch-hello-refresh-count new-count)))) ++ + ;;;###autoload + (defun notmuch-hello (&optional no-display) + "Run notmuch and display saved searches, known tags, etc. +-- +1.7.9.5 +