From: Mark Walters Date: Sun, 8 Jul 2012 06:57:20 +0000 (+0100) Subject: Re: [PATCH 3/3] emacs: add notmuch hello refresh hook to display message count change X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=caa65ae24d227003c6c519d6b6be6f69c00d7662;p=notmuch-archives.git Re: [PATCH 3/3] emacs: add notmuch hello refresh hook to display message count change --- diff --git a/47/f1bc010f3d2d2c63cfa78b8d211e8f5cd6d228 b/47/f1bc010f3d2d2c63cfa78b8d211e8f5cd6d228 new file mode 100644 index 000000000..dcc1fcdd9 --- /dev/null +++ b/47/f1bc010f3d2d2c63cfa78b8d211e8f5cd6d228 @@ -0,0 +1,155 @@ +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 1814E431FB6 + for ; Sat, 7 Jul 2012 23:57:27 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 ESvES6RZMBoy for ; + Sat, 7 Jul 2012 23:57:26 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 3A767431FAE + for ; Sat, 7 Jul 2012 23:57:26 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1SnlQq-0006Kf-BJ; Sun, 08 Jul 2012 07:57:24 +0100 +Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] + helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) + (envelope-from ) + id 1SnlQq-0006OQ-0z; Sun, 08 Jul 2012 07:57:24 +0100 +From: Mark Walters +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [PATCH 3/3] emacs: add notmuch hello refresh hook to display + message count change +In-Reply-To: + <627aea74b0080dcd903b801042a4b2fd3868c049.1339775602.git.jani@nikula.org> +References: + <37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani@nikula.org> + <627aea74b0080dcd903b801042a4b2fd3868c049.1339775602.git.jani@nikula.org> +User-Agent: Notmuch/0.13.2+61~gf708609 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Sun, 08 Jul 2012 07:57:20 +0100 +Message-ID: <87zk7aviy7.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 94.192.233.223 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 51b6354b5f1f903cb2c156519837ed22 (of first 20000 bytes) +X-SpamAssassin-Score: -1.8 +X-SpamAssassin-SpamBar: - +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -1.8 points. + Summary of the scoring: + * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, + * medium trust + * [138.37.6.40 listed in list.dnswl.org] + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * 0.5 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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, 08 Jul 2012 06:57:27 -0000 + +On Fri, 15 Jun 2012, Jani Nikula wrote: +> 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 + +Hi + +I just have a couple of comments/queries. First, since it breaks +existing hooks I think it needs a NEWS item. + +Secondly, I, personally, would much prefer the hook with the slight +tweak that it counts inbox messages rather than all messages. Is that +an option that could be put in the defcustom? + +Best wishes + +Mark + +> --- +> emacs/notmuch-hello.el | 27 +++++++++++++++++++++++++++ +> 1 file changed, 27 insertions(+) +> +> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +> index bc43178..bcca044 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,32 @@ 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. +> + +> +Display a status message about the difference in message count in +> +the database since the last call." +> + (unless no-display +> + (let* ((new-count +> + (string-to-number (car (process-lines notmuch-command "count")))) +> + (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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch