From: Mark Walters Date: Sat, 5 Apr 2014 21:24:24 +0000 (+0100) Subject: [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=32e8060c2b82164262a2c075f3f2563ffe1a4d2d;p=notmuch-archives.git [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists --- diff --git a/72/d1baad4dff57e4b263553b9b784ad9b5e79d8a b/72/d1baad4dff57e4b263553b9b784ad9b5e79d8a new file mode 100644 index 000000000..fb332dc92 --- /dev/null +++ b/72/d1baad4dff57e4b263553b9b784ad9b5e79d8a @@ -0,0 +1,138 @@ +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 5BC83431FDE + for ; Sat, 5 Apr 2014 14:25:02 -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 He7YdcA5VSdB for ; + Sat, 5 Apr 2014 14:24:57 -0700 (PDT) +Received: from mail-we0-f173.google.com (mail-we0-f173.google.com + [74.125.82.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 9B7FF431FAF + for ; Sat, 5 Apr 2014 14:24:52 -0700 (PDT) +Received: by mail-we0-f173.google.com with SMTP id w61so4950022wes.4 + for ; Sat, 05 Apr 2014 14:24:51 -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=UWuT3ixcgYokK94vpuueVIlsaznA24sP2RjU8bwoyYE=; + b=iEEawt6oVNLpgzgZHvN4nqJUPhdu838taKdwBbFv/rzzDiGShlVLA1T5ekYfeC9AIQ + Xokp0k7DCAlcfCvnnsS8wijim031e03bLaRRZyFouF3Dc/b7821CO6m/nbj5wy7LFni5 + x7WB5S4Hi6oKVKZYfL6U0kSfzldnvg57GdhE2vXyBNubtrPY+o682y0Gc/CCvzMTKUyn + JFg0B3RgXuaUM6deFDNx2OYVf8NFZOh7cig3nq2/YyJH/H5Np1QXD+kowjgV/VAKGOhC + HCFL3/qObNMvrvpcxJVz1BwU07Fw5NGl/ThOrwvzmrDKCTIccGtpWdtlsczowtTq8/Fn + qTSQ== +X-Received: by 10.194.24.194 with SMTP id w2mr30614493wjf.25.1396733090103; + Sat, 05 Apr 2014 14:24:50 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id q2sm13065203wix.5.2014.04.05.14.24.49 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 05 Apr 2014 14:24:49 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to + plists +Date: Sat, 5 Apr 2014 22:24:24 +0100 +Message-Id: <1396733065-32602-5-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com> +References: <1396733065-32602-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: Sat, 05 Apr 2014 21:25:02 -0000 + +Switching notmuch-hello-insert-buttons to plists means we can easily +pass extra options through to the buttons. +--- + emacs/notmuch-hello.el | 33 +++++++++++++++++++-------------- + 1 file changed, 19 insertions(+), 14 deletions(-) + +diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +index c729af2..aa40e6f 100644 +--- a/emacs/notmuch-hello.el ++++ b/emacs/notmuch-hello.el +@@ -425,7 +425,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-search-get 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 ++pairs :name NAME, :query QUERY and :count COUNT, together with ++any pairs in the original saved-search. + + The values :show-empty-searches, :filter and :filter-count from + options will be handled as specified for +@@ -455,23 +457,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)))) ++ (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 pairs for :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)) +@@ -489,9 +494,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 +