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 21CF9431FC7 for ; Mon, 12 May 2014 06:58:47 -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 veUIdAVJoUZu for ; Mon, 12 May 2014 06:58:40 -0700 (PDT) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id C6F50431FC2 for ; Mon, 12 May 2014 06:58:39 -0700 (PDT) Received: by mail-wi0-f174.google.com with SMTP id r20so4517656wiv.13 for ; Mon, 12 May 2014 06:58:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:subject:in-reply-to:references:user-agent :from:date:message-id:mime-version:content-type; bh=Sqxap8cx20K/O0+JdFRsREY5AdjKgP4vEgwpw4wf20w=; b=cZRrCMawU/ak+yHZQL2EzK8yIklKtsNsKnVUrRLU9OtHvXm2p4MDBSJIYrhZSEh01d qNzsNl2HNlwsP8cK018m94+8xaS7arqKnrZGcFEmtvbS4aCseOkXpg7E13qIlY8oPwO2 lgGS1kE/G3fleVdd/I9KxDEE2uj8b0en4+zL65SblH2p/2y8jm8y0UXXa1ht26L8Ov8h tZ4lzU4NOb8dKbjNuDNRQyvv7KUXeWFFx/3fOQNGvCfku9UvbTbC+E0Luvm2/tu8sH80 Ulp7C3COxMm8GMSx8gODXkl+mDLvVMjfH0rryPTI8rphJ7B+4Pt1QpeXhMtCqwsbuMdk W3LQ== X-Gm-Message-State: ALoCoQnaWIxzkWjJjccMrLtEOhW+PJD4U5RqoIUcDYx2R16onA+6RySctLubwnD6XYoxjW2Fgr1y X-Received: by 10.180.14.199 with SMTP id r7mr16055266wic.0.1399903117436; Mon, 12 May 2014 06:58:37 -0700 (PDT) Received: from localhost ([2a01:348:1a2:1:a288:b4ff:fe8a:77d8]) by mx.google.com with ESMTPSA id ej2sm18053459wjd.21.2014.05.12.06.58.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 May 2014 06:58:34 -0700 (PDT) To: Mark Walters , notmuch@notmuchmail.org Subject: Re: [PATCH 6/7] emacs: hello: add highlight newly arrived messages option In-Reply-To: <1399797282-20389-7-git-send-email-markwalters1009@gmail.com> References: <1399797282-20389-1-git-send-email-markwalters1009@gmail.com> <1399797282-20389-7-git-send-email-markwalters1009@gmail.com> User-Agent: Notmuch/0.18 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) From: David Edmondson Date: Mon, 12 May 2014 14:58:28 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" 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: Mon, 12 May 2014 13:58:48 -0000 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sun, May 11 2014, Mark Walters wrote: > This adds a function that highlights searches which have newly arrived > messages (ones which arrived since the previous refresh of > notmuch-hello). It does that by getting a full list of matching > message ids and checking whether any new messages have appeared. Thus > it will be slow on large saved searches. > --- > emacs/notmuch-hello.el | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el > index 28e16be..265b879 100644 > --- a/emacs/notmuch-hello.el > +++ b/emacs/notmuch-hello.el > @@ -96,6 +96,8 @@ (define-widget 'notmuch-saved-search-plist 'list > (const :tag "Default (messages)" nil) > (function-item :tag "messages/threads" > notmuch-hello-display-count-threads-and-messages) > + (function-item :tag "highlight newly arrived messages" > + notmuch-hello-display-new-messages) > function))))) >=20=20 > (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox") > @@ -507,6 +509,25 @@ (defun notmuch-hello-display-count-threads-and-messa= ges (&rest args) > (notmuch-hello-nice-number threads)))) > (plist-put current :count display))) >=20=20 > +(defun notmuch-hello-display-new-messages (&rest args) > + "Highlight saved searches which have new messages. > + > +New messages are ones which have appeared since the last time > +notmuch hello was refreshed. This will be slow on large queries." > + (let* ((current (plist-get args :current)) > + (old (plist-get args :old)) > + (query (plist-get current :query)) > + (name (plist-get current :name)) > + (new-list (notmuch-call-notmuch-sexp "search" > + "--output=3Dmessages" > + "--format=3Dsexp" > + query)) > + (old-list (plist-get old :message-list))) > + (unless (subsetp new-list old-list :test 'equal) > + (plist-put current :name (propertize name 'face '(:foreground "red= ")))) > + (plist-put current :count (notmuch-hello-nice-number (length new-lis= t))) > + (plist-put current :message-list new-list))) I wonder if it would be better to store a hash value derived from the message list rather than the list itself. The list could be large. > + > (defun notmuch-hello-batch-message-count (elem-plist options) > "Update the message count for a saved search. >=20=20 > --=20 > 1.7.10.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iKYEARECAGYFAlNw04RfFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3Bl bnBncC5maWZ0aGhvcnNlbWFuLm5ldDc1M0Y5NDJDMEExNjc3MDE4OURGMUYyMDY5 RUNEMEFCRjA0OTY1MTYACgkQaezQq/BJZRbrdACgiT712Cb8m2ZHfF/q8+1vlhTG 5mQAn0q2cyqZ4EyAfg+LSX3vXjgfPk2M =+NxA -----END PGP SIGNATURE----- --=-=-=--