From: Dmitry Kurochkin Date: Tue, 17 Apr 2012 09:43:28 +0000 (+0400) Subject: Re: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display message count... X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=529bae141e73e814eb3e5d7004a1281ae863b676;p=notmuch-archives.git Re: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display message count change --- diff --git a/bf/e31911c153a58ee7b6a9efda8cf991d6a727a3 b/bf/e31911c153a58ee7b6a9efda8cf991d6a727a3 new file mode 100644 index 000000000..de865d19e --- /dev/null +++ b/bf/e31911c153a58ee7b6a9efda8cf991d6a727a3 @@ -0,0 +1,169 @@ +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 2C1A0431FB6 + for ; Tue, 17 Apr 2012 02:45:24 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, 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 4Z-GpKARgmIN for ; + Tue, 17 Apr 2012 02:45:20 -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 16AB1431FAE + for ; Tue, 17 Apr 2012 02:45:19 -0700 (PDT) +Received: by lahc1 with SMTP id c1so4783588lah.26 + for ; Tue, 17 Apr 2012 02:45:18 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type; + bh=UNvkLiMfVtnWdjYrEglmE1YKerzn6wCJlBOAChpyl5w=; + b=sdlsSzS0WDvf62rcNx/h/52UWHqEghcWMiK0LVwsXS514aD+xaJw1Bw2GrurBituFR + f1F6nvlkzy8xtIohAF31S2HoRWKfZv/5y69D5gHTohaj/0dCc1K/J3sMHy5vccOUoKNl + KBMMgiL/KYemjnNECnx5VAiBa+pRegLXChzS2ObmkS2fF/SqbXNZ4y8XE4wCjbFed0Bv + 9UUz4J4669Ute9A08i78kO4ghJqUk4toASYLnpHOOh4eBFQwoRjgUVKM919IWdwXeRwO + r7IUOoMiZDWzFzpu5DMrErMZquWwdtYa/H1OPqUnjfdC5iiyr/2RORc3D0NcQo8Zqx+H + 8hqA== +Received: by 10.112.48.36 with SMTP id i4mr6900644lbn.84.1334655918454; + Tue, 17 Apr 2012 02:45:18 -0700 (PDT) +Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id + gw17sm22284179lab.11.2012.04.17.02.45.17 + (version=TLSv1/SSLv3 cipher=OTHER); + Tue, 17 Apr 2012 02:45:17 -0700 (PDT) +From: Dmitry Kurochkin +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display + message count change +In-Reply-To: <87ehrmvgyn.fsf@nikula.org> +References: + + + <874nsioh5g.fsf@gmail.com> <87ehrmvgyn.fsf@nikula.org> +User-Agent: Notmuch/0.12+104~gf9ad237 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 17 Apr 2012 13:43:28 +0400 +Message-ID: <87vckyn16n.fsf@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +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:45:24 -0000 + +Jani Nikula writes: + +> 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? + +Well, that is what I meant by "less flexible than a hook". + +> Also, you'd have to pass no-display there too. + +Sure, we can pass it to sections. + +> 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. +> + +I think this feature should be enabled by default. + +I guess you are right that it is not a big issue. I still think we +would be better without it (and we still can isolate the feature), but I +would not object to having the extra call. + +Regards, + Dmitry + +> 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