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 0C41C431FB6 for ; Tue, 17 Apr 2012 02:35:34 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 tAQk57ICccCb for ; Tue, 17 Apr 2012 02:35:33 -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 580F5431FAE for ; Tue, 17 Apr 2012 02:35:33 -0700 (PDT) Received: by qadb15 with SMTP id b15so259245qad.2 for ; Tue, 17 Apr 2012 02:35:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type:x-gm-message-state; bh=Mr8EorY1W/3t/hs/Z/pGrpY83ajsjC3EiE41/4l04wc=; b=ei7gmmbMzmdON5JvYvKxLTMc0iWAxOYjwpn0L7BJ0FXtr6k4GAFIUSmjbNZekZs5jP SVpXeIti1v9Jc2CFvMqHC0tmsOEb00xAzNtjsuVq5QxEWB9bsjCFQI1iGRUrbW8jJVf1 /YWMxFx4KOhCQfsrJ61tUZpEo98C2AfldnIsHS/uzpIB52aVfu0hVDFqVpCdmdJGDFXO gNpIck569gi/9990p2BXkhPuHlDYA4fhro38DDjj0sQZ8jAgteOWGJTHRp9IOprjzctV ZRyL5NQrwMeFKNFmpJMmW4fNhFlgfacT8bTWakUAOFO5hADCYblRb4yrU8M8AOSCj2wL 5Yqg== Received: by 10.229.137.3 with SMTP id u3mr6301746qct.20.1334655332663; Tue, 17 Apr 2012 02:35:32 -0700 (PDT) Received: from localhost (nikula.org. [92.243.24.172]) by mx.google.com with ESMTPS id dm8sm39266459qab.18.2012.04.17.02.35.31 (version=SSLv3 cipher=OTHER); Tue, 17 Apr 2012 02:35:31 -0700 (PDT) From: Jani Nikula To: Dmitry Kurochkin , notmuch@notmuchmail.org Subject: Re: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display message count change In-Reply-To: <874nsioh5g.fsf@gmail.com> References: <874nsioh5g.fsf@gmail.com> User-Agent: Notmuch/0.11.1+222~ga47a98c (http://notmuchmail.org) Emacs/23.1.1 (i686-pc-linux-gnu) Date: Tue, 17 Apr 2012 09:35:28 +0000 Message-ID: <87ehrmvgyn.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gm-Message-State: ALoCoQnn36pr8RGzDkZ0gNy32A/W1hunjH/fHlgPf39zhd9u97DIEjwjFIdgzfwHOwmbZxyCELsu 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 09:35:34 -0000 On Tue, 17 Apr 2012 13:13:15 +0400, Dmitry Kurochkin wrote: > Jani Nikula writes: > > > 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). > > I like this idea. But IMO we should avoid another call to notmuch > count. Notmuch-hello buffer already displays the message count on the > first line. I would propose to implement this functionality not as a > hook but as part of the section which outputs the first line. We can > add an option to disable it if you prefer but I do not think it is > needed. This is less flexible than a hook, but IMO it is not a big > issue. And what if someone has disabled the header section but would want the message? Also, you'd have to pass no-display there too. IMHO one call to notmuch count is not a big issue, especially for an optional feature. And having it as a hook very nicely isolates the feature from everything else. Jani. > > Regards, > Dmitry > > > --- > > 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 > > > > _______________________________________________ > > notmuch mailing list > > notmuch@notmuchmail.org > > http://notmuchmail.org/mailman/listinfo/notmuch