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 4E2BF431FBF for ; Sun, 11 May 2014 01:34:57 -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 g6vWVQpyH0TF for ; Sun, 11 May 2014 01:34:51 -0700 (PDT) Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 99F51431FC0 for ; Sun, 11 May 2014 01:34:51 -0700 (PDT) Received: by mail-wg0-f47.google.com with SMTP id x12so5511982wgg.6 for ; Sun, 11 May 2014 01:34:49 -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=N1+1WnnbCmlsWbuJns99+T3NGsJZvexJr6Fu1BEjHW8=; b=OZ2On+P3Pnq7wDfmR6yQB1+wGpy+va4AJYo4YP+Q/cC37AVfJKtOUJ2/n+GNUxKwTJ 11hxLfHRjZ5AkAe9vRjMgtPChZON6Y6hRkHkq62vDTUUDkOdkNH/qlWOXhRCM045BOOO fuyk2IgsZQIk4MXXgQFxA/CSgTgNgJjOwZn4nj3i9gOtkV/pQ1Ds7DAEkrzKxzHT4z9s 9tf0uE3crxAOJ9tHChOZLhKN9vjg1sdKA44PDnGRu/yEXMfjqIMneRENq0c/Kgt8khYW dKI8y3l6jhIVtztWN1c3IT266ddAv83ySmacgKS2zN/pFqLNJukQWzABSqBb08Ce5rhf WThA== X-Received: by 10.194.206.2 with SMTP id lk2mr15971349wjc.33.1399797289354; Sun, 11 May 2014 01:34:49 -0700 (PDT) Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) by mx.google.com with ESMTPSA id gz1sm9091621wib.14.2014.05.11.01.34.48 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 11 May 2014 01:34:48 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH 1/7] emacs: hello: separate out the saved-search display function Date: Sun, 11 May 2014 09:34:36 +0100 Message-Id: <1399797282-20389-2-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:34:57 -0000 Separate the code that prints a saved-search and count into its own function. --- emacs/notmuch-hello.el | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 3de5238..0a7004c 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -475,6 +475,22 @@ (defun notmuch-hello-filtered-query (query filter) (concat "(" query ") and (" filter ")")) (t query))) +(defun notmuch-hello-batch-message-count (elem-plist options) + "Update the message count for a saved search. + +This takes the next line in the current buffer (the output from a +call to notmuch count --batch) as the message count and sets +the :count property in ELEM-PLIST to it." + (let* ((count (prog1 (read (current-buffer)) + (forward-line 1))) + (search-query (plist-get elem-plist :query)) + (filtered-query (notmuch-hello-filtered-query + search-query (plist-get options :filter)))) + (when (and filtered-query (or (plist-get options :show-empty-searches) + (> count 0))) + (setq elem-plist (plist-put elem-plist :query filtered-query)) + (plist-put elem-plist :count (notmuch-hello-nice-number count))))) + (defun notmuch-hello-query-counts (query-list &rest options) "Compute list of counts of matched messages from QUERY-LIST. @@ -514,15 +530,8 @@ (defun notmuch-hello-query-counts (query-list &rest options) #'identity (mapcar (lambda (elem) - (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem)) - (search-query (plist-get elem-plist :query)) - (filtered-query (notmuch-hello-filtered-query - search-query (plist-get options :filter))) - (message-count (prog1 (read (current-buffer)) - (forward-line 1)))) - (when (and filtered-query (or (plist-get options :show-empty-searches) (> message-count 0))) - (setq elem-plist (plist-put elem-plist :query filtered-query)) - (plist-put elem-plist :count message-count)))) + (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))) + (notmuch-hello-batch-message-count elem-plist options))) query-list)))) (defun notmuch-hello-insert-buttons (searches) @@ -558,8 +567,7 @@ (defun notmuch-hello-insert-buttons (searches) (oldest-first t) (otherwise notmuch-search-oldest-first))) (msg-count (plist-get elem :count))) - (widget-insert (format "%8s " - (notmuch-hello-nice-number msg-count))) + (widget-insert (format "%8s " msg-count)) (widget-create 'push-button :notify #'notmuch-hello-widget-search :notmuch-search-terms query -- 1.7.10.4