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 84831431FD5 for ; Sat, 5 Apr 2014 22:45:20 -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 CfXx6GGjWlwg for ; Sat, 5 Apr 2014 22:45:16 -0700 (PDT) Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E1C75431FAF for ; Sat, 5 Apr 2014 22:45:10 -0700 (PDT) Received: by mail-wg0-f44.google.com with SMTP id m15so5331842wgh.27 for ; Sat, 05 Apr 2014 22:45:09 -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=0ixTu9gmiCezx2AQ7mHuWucjQ51oJw9p/jAdvg824c0=; b=MS+0+o+0UbPXP/EjNIajx9Qmg+efYc3fikkLFS0X1gkFDjaL4xcn/lP0FJiZcuZbfZ bEcV6mu8FyqfkdoCXxLetsszqaX3duWQBA2GkwE3PiKTSBxSvgGfgS9u/jkTfqQkNGKi plpHPiWTklK3Xn048VC/13QEYhUktRJFHqRqo7/+v0mPcrf/8cngpIdkzY/s+UbnsMj0 +24F9uT0+x3WCazaziFGGUt6nsyA/GS4aZLCKTZjU6p+RqA22TcHvAXYt1AmPBqTn9fx OW2E18Z7zfFQ+nXRVz0vWf50/7/0IVsd2VChjn9vVlOAN296jZkxmZAWk0lSyeh/r0Ia /vLw== X-Received: by 10.180.101.134 with SMTP id fg6mr16465233wib.6.1396763109831; Sat, 05 Apr 2014 22:45:09 -0700 (PDT) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id u6sm15187135wif.6.2014.04.05.22.45.08 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 05 Apr 2014 22:45:09 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org, amdragon@MIT.EDU Subject: [PATCH v2 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists Date: Sun, 6 Apr 2014 06:44:48 +0100 Message-Id: <1396763089-32452-5-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com> References: <1396763089-32452-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, 06 Apr 2014 05:45:20 -0000 Switching notmuch-hello-insert-buttons to plists means we can easily pass extra options through to the buttons. --- emacs/notmuch-hello.el | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 30f26db..f440352 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -424,7 +424,9 @@ (defun notmuch-hello-query-counts (query-list &rest options) these is a plist but other options are available for backwards compatibility: see `notmuch-saved-searches' for details. -The result is the list of elements of the form (NAME QUERY COUNT). +The result is a list of plists each of which includes the +properties :name NAME, :query QUERY and :count COUNT, together +with any properties in the original saved-search. The values :show-empty-searches, :filter and :filter-count from options will be handled as specified for @@ -454,23 +456,26 @@ (defun notmuch-hello-query-counts (query-list &rest options) #'identity (mapcar (lambda (elem) - (let ((name (notmuch-saved-search-get elem :name)) - (search-query (notmuch-saved-search-get elem :query)) - (message-count (prog1 (read (current-buffer)) + (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)))) - (and (or (plist-get options :show-empty-searches) (> message-count 0)) - (list name (notmuch-hello-filtered-query - search-query (plist-get options :filter)) - message-count)))) + (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)))) query-list)))) (defun notmuch-hello-insert-buttons (searches) "Insert buttons for SEARCHES. -SEARCHES must be a list containing lists of the form (NAME QUERY COUNT), where -QUERY is the query to start when the button for the corresponding entry is -activated. COUNT should be the number of messages matching the query. -Such a list can be computed with `notmuch-hello-query-counts'." +SEARCHES must be a list of plists each of which should contain at +least the properties :name NAME :query QUERY and :count COUNT, +where QUERY is the query to start when the button for the +corresponding entry is activated, and COUNT should be the number +of messages matching the query. Such a plist can be computed +with `notmuch-hello-query-counts'." (let* ((widest (notmuch-hello-longest-label searches)) (tags-and-width (notmuch-hello-tags-per-line widest)) (tags-per-line (car tags-and-width)) @@ -488,9 +493,9 @@ (defun notmuch-hello-insert-buttons (searches) (when elem (if (> column-indent 0) (widget-insert (make-string column-indent ? ))) - (let* ((name (first elem)) - (query (second elem)) - (msg-count (third elem))) + (let* ((name (plist-get elem :name)) + (query (plist-get elem :query)) + (msg-count (plist-get elem :count))) (widget-insert (format "%8s " (notmuch-hello-nice-number msg-count))) (widget-create 'push-button -- 1.7.10.4