Re: [PATCH 6/7] emacs: hello: add highlight newly arrived messages option
authorDavid Edmondson <dme@dme.org>
Mon, 12 May 2014 13:58:28 +0000 (14:58 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:02:45 +0000 (10:02 -0800)
9c/163a0d09910475a79f341cdd8988e245bee31f [new file with mode: 0644]

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