From 9c85668c77bb62b0a003490d5a138d50a224158d Mon Sep 17 00:00:00 2001 From: Dmitry Kurochkin Date: Tue, 17 Apr 2012 13:13:15 +0400 Subject: [PATCH] Re: [RFC PATCH 3/4] emacs: add notmuch hello refresh hook to display message count change --- c0/415f6f67961d7f16c8a94ed21751450f67e3f0 | 138 ++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 c0/415f6f67961d7f16c8a94ed21751450f67e3f0 diff --git a/c0/415f6f67961d7f16c8a94ed21751450f67e3f0 b/c0/415f6f67961d7f16c8a94ed21751450f67e3f0 new file mode 100644 index 000000000..04b173d32 --- /dev/null +++ b/c0/415f6f67961d7f16c8a94ed21751450f67e3f0 @@ -0,0 +1,138 @@ +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 3FAE9431FB6 + for ; Tue, 17 Apr 2012 02:15:12 -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 RCf9MelaOOJY for ; + Tue, 17 Apr 2012 02:15:07 -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 94BCC431FAE + for ; Tue, 17 Apr 2012 02:15:07 -0700 (PDT) +Received: by lahc1 with SMTP id c1so4765502lah.26 + for ; Tue, 17 Apr 2012 02:15:06 -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=990vjPpnDm9P+RsMbwGOjAQEsYqB1PzKu6MCSN829Jo=; + b=ilRX6A19bxQW5rlWt3sYmKRCY8Uw+pQBzK7p76dRSJjlTGxJsTH3NoB4kTgNzYfO0L + WmYCzTyIA2Y0bIVVpmRvZczNlhjij1S+yZHYFeDbtZ549C+zhavlUwWg+BF/OeBvqnO+ + wrXfvsPOQcsbXzKFRXosu7eN8FhEs1r8KrUC7vzSTaOqJOtc94jqAoK6gfXaEF5yBzhu + n9zI2jB2Gc3ZMTqp4Y6HAgnUSNqAJB51I6ctzzTJD/8Awq7Xtukd0yWscYSAAjelXkwY + 6w3AsL5qWJze6rt7pu+c1+5qnIVzSLUsvz5iXpUAc8FC2RQ8CH5Rs+RvqipnJzYzipX+ + tsvw== +Received: by 10.112.99.38 with SMTP id en6mr6884321lbb.48.1334654105990; + Tue, 17 Apr 2012 02:15:05 -0700 (PDT) +Received: from localhost ([91.144.186.21]) + by mx.google.com with ESMTPS id nv7sm10605563lab.9.2012.04.17.02.15.04 + (version=TLSv1/SSLv3 cipher=OTHER); + Tue, 17 Apr 2012 02:15:05 -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: + +References: + + +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:13:15 +0400 +Message-ID: <874nsioh5g.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:15:12 -0000 + +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. + +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 -- 2.26.2