Re: [PATCH 6/7] emacs: hello: add highlight newly arrived messages option

Subject: Re: [PATCH 6/7] emacs: hello: add highlight newly arrived messages option

Date: Mon, 12 May 2014 14:58:28 +0100

To: Mark Walters, notmuch@notmuchmail.org

Cc:

From: David Edmondson


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)))))
>  
>  (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")
> @@ -507,6 +509,25 @@ (defun notmuch-hello-display-count-threads-and-messages (&rest args)
>  			  (notmuch-hello-nice-number threads))))
>      (plist-put current :count display)))
>  
> +(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=messages"
> +					      "--format=sexp"
> +					      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-list)))
> +    (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.
>  
> -- 
> 1.7.10.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
signature.asc (application/pgp-signature)

Thread: