From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id F2ED9431FD5 for ; Sun, 11 May 2014 01:35:32 -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 3UTlV-+6PzfX for ; Sun, 11 May 2014 01:35:26 -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 0E8C3431FD8 for ; Sun, 11 May 2014 01:34:59 -0700 (PDT) Received: by mail-wi0-f174.google.com with SMTP id r20so3110706wiv.7 for ; Sun, 11 May 2014 01:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+G915XYvV22C6eVdqzno2RwGphrqXZ4LpBN05H+0od0=; b=lAscZ4ZNXI73FeObVu2/VNzHroy4I8cGqnzh9pFkcp77sBQlFN4WX4iUwlV3Zm8epj GqLJEUCyzswzVpGmTaf3c7eV6AwsyQzL1VC0a6G0We5UNe3fzSL1bZm+GaKx+JpPytfL P2BGjEe6QnJAwtfcfXC2oy+jEugRnf9WZB+fG7qdMH7mwjzRj5bu2Y8I4DHt0g8/tN1b DXaHfaajxg8YcmEPV2gDmdPzYTw/sDKAUx6usv80GCpqt3CxNGpbe1rSJ/Sp6ZBf31G0 7GLOdUJwf/35qsaysdqQKB/DyPeDl+nRrqiRzWYzMEGp4Y6fqHuss2l9YjCz/FMaesuW UBTg== X-Received: by 10.194.243.3 with SMTP id wu3mr16170932wjc.29.1399797297796; Sun, 11 May 2014 01:34:57 -0700 (PDT) Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) by mx.google.com with ESMTPSA id cv4sm12741202wjc.34.2014.05.11.01.34.56 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 11 May 2014 01:34:57 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH 6/7] emacs: hello: add highlight newly arrived messages option Date: Sun, 11 May 2014 09:34:41 +0100 Message-Id: <1399797282-20389-7-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399797282-20389-1-git-send-email-markwalters1009@gmail.com> References: <1399797282-20389-1-git-send-email-markwalters1009@gmail.com> 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, 11 May 2014 08:35:33 -0000 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))) + (defun notmuch-hello-batch-message-count (elem-plist options) "Update the message count for a saved search. -- 1.7.10.4