From: Mark Walters Date: Mon, 12 May 2014 15:33:47 +0000 (+0100) Subject: Re: [PATCH 6/7] emacs: hello: add highlight newly arrived messages option X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7a3a54b005f2080c677acaf15423788d35b6fe0e;p=notmuch-archives.git Re: [PATCH 6/7] emacs: hello: add highlight newly arrived messages option --- diff --git a/b2/d336380619f69a6505e0195d3f923d5e08e7be b/b2/d336380619f69a6505e0195d3f923d5e08e7be new file mode 100644 index 000000000..b525f4a40 --- /dev/null +++ b/b2/d336380619f69a6505e0195d3f923d5e08e7be @@ -0,0 +1,156 @@ +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 18D66431FC7 + for ; Mon, 12 May 2014 08:34:01 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=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 igpEbfHCbqDp for ; + Mon, 12 May 2014 08:33:53 -0700 (PDT) +Received: from mail-we0-f176.google.com (mail-we0-f176.google.com + [74.125.82.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id A92B0431FC2 + for ; Mon, 12 May 2014 08:33:53 -0700 (PDT) +Received: by mail-we0-f176.google.com with SMTP id q59so6893001wes.21 + for ; Mon, 12 May 2014 08:33:50 -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=OfCDL/bA1skE+aR+YArTZiAaEyXn6I3O6t/3iR2zJzY=; + b=G3uY8h5uQLehShUwfNqe2SKx7oXpZGu1/PHvAEr7xhxNK0jIJK87Q4nQ4UmYhS3vY0 + CK3scoNjpjErK8cq+JhHogq5o5KnEvuaAzXqG+K9vjVkrvdwGVAlztqFSRdtVngpST7+ + mq8lwMo8cgS27rhF3EEo2rljwP812OVwoe7A8dr6NUKS1DCmbAS3JsdLhm0c0sSz8TPG + QnzfNoLJ3TTD8/V+wfyGimsjdh5Nkadm6y/QTNcWOImizFhTUF0IgurdrnsAh12Bl9YN + mmiqIn86QvqKoL6W+E/F8WpkebcvX+x0PE4kMZ5ye+Er64pILxoIPu+DEm1Czz3UAjsi + GhHA== +X-Received: by 10.180.74.132 with SMTP id t4mr16107842wiv.30.1399908830268; + Mon, 12 May 2014 08:33:50 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by mx.google.com with ESMTPSA id + kr6sm17253114wjb.16.2014.05.12.08.33.49 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Mon, 12 May 2014 08:33:49 -0700 (PDT) +From: Mark Walters +To: David Edmondson , notmuch@notmuchmail.org +Subject: Re: [PATCH 6/7] emacs: hello: add highlight newly arrived messages + option +In-Reply-To: +References: <1399797282-20389-1-git-send-email-markwalters1009@gmail.com> + <1399797282-20389-7-git-send-email-markwalters1009@gmail.com> + +User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Mon, 12 May 2014 16:33:47 +0100 +Message-ID: <87y4y7j9k4.fsf@qmul.ac.uk> +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: Mon, 12 May 2014 15:34:01 -0000 + +On Mon, 12 May 2014, David Edmondson wrote: +> 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. + +My view was that the list was OK as a user would be foolish to set this +for any large queries anyway (as the query itself would be too +slow). Also, a hash itself wouldn't get the effect I want as I do want +to be to test "subset" for the two lists (as I don't care about messages +no longer matching, only new messages that do match: think inbox type +things) + +I could store the hash of the message-id. That might save a substantial +chunk on storage (eg 40 byte message if to 4byte hash or something) + +More generally, it is not clear to me whether we want to make it easy +for a user to cause notmuch-hello to be very slow. Perhaps we need a +timing for each display-function. If any one takes over 0.5s then we can +report it to the user! + +Best wishes + +Mark + + + + + + +> +>> + +>> (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