From: Jani Nikula Date: Tue, 17 Apr 2012 08:35:24 +0000 (+0000) Subject: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display message count change X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=c4b124ce86bdfd54b8e323c549fcd6ca31a3d15c;p=notmuch-archives.git [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display message count change --- diff --git a/d9/0d74ca20bf84b21f1ae680617d6a1bff1a39fe b/d9/0d74ca20bf84b21f1ae680617d6a1bff1a39fe new file mode 100644 index 000000000..bd5db45c5 --- /dev/null +++ b/d9/0d74ca20bf84b21f1ae680617d6a1bff1a39fe @@ -0,0 +1,123 @@ +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 19B41431FD4 + for ; Tue, 17 Apr 2012 01:35:44 -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 7yzlTucx-v1y for ; + Tue, 17 Apr 2012 01:35:42 -0700 (PDT) +Received: from mail-qa0-f43.google.com (mail-qa0-f43.google.com + [209.85.216.43]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id DF8D1431FC7 + for ; Tue, 17 Apr 2012 01:35:36 -0700 (PDT) +Received: by mail-qa0-f43.google.com with SMTP id b15so225149qad.2 + for ; Tue, 17 Apr 2012 01:35:36 -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=cI9JN7spgr90sOxN8oeJZSgD+GfYoU4XntX5CWkYh+E=; + b=Pw0S95qbfp9vdYYdAAogqd8634JqTW9J4WA38qDJ8yMsIZlfM7BCA38Oe6MuM+Ge2Q + EkVsxk04f75ok3+XbTLExSo0O2w4jQQLVf4EciCqu2Cu68eXV8bk1pf7coWgZkbQaXuJ + 2XGX3A2BVMpx9Jv7kyCv9zw+B7Q/kgQkiac/NC16FI1+Dc4jVHeSxV4nzqV0teToV/1N + u8+aDDohNyWbEo9P98TtQeQ2YSd2PBBgRJOp2jWgiD8kXP2jt9wMDGI55YEeAsOfeNuv + K5zqOuMIJv5O+WkicjrYr7SRJ1mrhY8kWi/5Cmj4rTnjFcDyEpixX1F4CnC+0SAdOrXs + zQlA== +Received: by 10.229.136.7 with SMTP id p7mr5896824qct.52.1334651736555; + Tue, 17 Apr 2012 01:35:36 -0700 (PDT) +Received: from localhost (nikula.org. [92.243.24.172]) + by mx.google.com with ESMTPS id i8sm15947250qap.0.2012.04.17.01.35.35 + (version=SSLv3 cipher=OTHER); Tue, 17 Apr 2012 01:35:35 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display + message count change +Date: Tue, 17 Apr 2012 08:35:24 +0000 +Message-Id: + +X-Mailer: git-send-email 1.7.1 +In-Reply-To: + +References: + +In-Reply-To: + +References: + +X-Gm-Message-State: + ALoCoQkg4U22FefUtW10XDcvV5wdltchQuaYCoZxx+X67ieL9WD/Lxf4PS06mU2q4phGFv3DmgkH +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: Tue, 17 Apr 2012 08:35:44 -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). +--- + emacs/notmuch-hello.el | 23 +++++++++++++++++++++++ + 1 files changed, 23 insertions(+), 0 deletions(-) + +diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +index 0596bbe..13da146 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) + +@@ -729,6 +730,28 @@ following: + (let ((fill-column (- (window-width) notmuch-hello-indent))) + (center-region start (point))))) + ++(defvar notmuch-hello-refresh-count 0 ++ "Number of messages in the database 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." ++ (unless no-display ++ (let* ((new-count ++ (string-to-number (car (process-lines notmuch-command "count")))) ++ (diff-count (- new-count notmuch-hello-refresh-count))) ++ (if (= notmuch-hello-refresh-count 0) ++ (message "You have %s messages." ++ (notmuch-hello-nice-number new-count)) ++ (if (not (= diff-count 0)) ++ (if (>= diff-count 0) ++ (message "You have %s more messages since last refresh." ++ (notmuch-hello-nice-number diff-count)) ++ (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.1 +