From: Mark Walters Date: Sun, 11 May 2014 08:34:38 +0000 (+0100) Subject: [PATCH 3/7] emacs: hello: store previous saved-search results X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f7cfa38279995f55c70ce18d9ecd0e3244f673f9;p=notmuch-archives.git [PATCH 3/7] emacs: hello: store previous saved-search results --- diff --git a/31/ab5aeaa3dbd40d876e71b80382917d8f469b78 b/31/ab5aeaa3dbd40d876e71b80382917d8f469b78 new file mode 100644 index 000000000..ddf86fa62 --- /dev/null +++ b/31/ab5aeaa3dbd40d876e71b80382917d8f469b78 @@ -0,0 +1,110 @@ +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 045A2431FC0 + for ; Sun, 11 May 2014 01:35:03 -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 8Ba8lDYgDcmq for ; + Sun, 11 May 2014 01:34:57 -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 06B83431FC3 + for ; Sun, 11 May 2014 01:34:53 -0700 (PDT) +Received: by mail-we0-f176.google.com with SMTP id q59so5485305wes.7 + for ; Sun, 11 May 2014 01:34:52 -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=D0/2AqwSy12chsRku2rIQ6KCll+oD4VHK0vyVbj9Cv8=; + b=K01CM7yf1K+96sheCj1P8eWfhOEVqKEO3QD2FLexeCexK5l0p2vHO19kbfiPkGAafA + Gk42Ujr+UMwhurY6ZCEuHIwY7m/7TdpycLV3iyFObWgifEmszNBTLjOk+DfvfkE+PtZP + pGJ1DvfF/ekaMXv9d0ImEaKaXDHJSTmBPfo3KHJ1f6pxswVgWVe8k4M1p88wiVK04VTZ + HGRQbCCfWz7xbkU3uaRa6MdPyKKADeo+tP5BgggfjCESj75rcZUozTcDRQPv33JZHKWO + KkLGexrlW7YRWqBc3maPc+WlUQ2021MrnvUnjQG1EUKrHVODIRzkMx6bWdroFQ2HNlS5 + yMNQ== +X-Received: by 10.180.36.212 with SMTP id s20mr10650438wij.18.1399797292931; + Sun, 11 May 2014 01:34:52 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by mx.google.com with ESMTPSA id + gr2sm12751610wjc.12.2014.05.11.01.34.51 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 11 May 2014 01:34:52 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 3/7] emacs: hello: store previous saved-search results +Date: Sun, 11 May 2014 09:34:38 +0100 +Message-Id: <1399797282-20389-4-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:03 -0000 + +This adds a variable which keeps track of the previous saved search +results. It is stored as a plist with keys being the saved +searches. The result the saved search display function gave last time +is passed to the display-function as the the keyword :old argument. + +This is useful for display functions that want to keep some state: eg +to show that the count has changed, new messages have arrived etc. The +function returns a saved search style plist so it can store any +information it likes inside this plist. +--- + emacs/notmuch-hello.el | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +index 7075860..e11006b 100644 +--- a/emacs/notmuch-hello.el ++++ b/emacs/notmuch-hello.el +@@ -127,6 +127,10 @@ (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox") + :tag "List of Saved Searches" + :group 'notmuch-hello) + ++(defvar notmuch-hello-saved-search-results nil ++ "Current saved search counts as a plist") ++(make-local-variable 'notmuch-hello-saved-search-results) ++ + (defcustom notmuch-hello-recent-searches-max 10 + "The number of recent searches to display." + :type 'integer +@@ -541,11 +545,15 @@ (defun notmuch-hello-query-counts (query-list &rest options) + (lambda (elem) + (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem)) + (display-function (plist-get elem-plist :display-function)) ++ (old-result (plist-get notmuch-hello-saved-search-results elem)) + (result (if display-function + (funcall display-function + :current elem-plist ++ :old old-result + :option options) + (notmuch-hello-batch-message-count elem-plist options)))) ++ (setq notmuch-hello-saved-search-results ++ (plist-put notmuch-hello-saved-search-results elem result)) + result)) + query-list)))) + +-- +1.7.10.4 +