Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / e6 / fc9f620053b954e085447581e180dd055b962d
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 84831431FD5\r
6         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 22:45:20 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id CfXx6GGjWlwg for <notmuch@notmuchmail.org>;\r
18         Sat,  5 Apr 2014 22:45:16 -0700 (PDT)\r
19 Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com\r
20  [74.125.82.44])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  E1C75431FAF    for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 22:45:10 -0700\r
23  (PDT)\r
24 Received: by mail-wg0-f44.google.com with SMTP id m15so5331842wgh.27\r
25         for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 22:45:09 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
28         bh=0ixTu9gmiCezx2AQ7mHuWucjQ51oJw9p/jAdvg824c0=;\r
29         b=MS+0+o+0UbPXP/EjNIajx9Qmg+efYc3fikkLFS0X1gkFDjaL4xcn/lP0FJiZcuZbfZ\r
30         bEcV6mu8FyqfkdoCXxLetsszqaX3duWQBA2GkwE3PiKTSBxSvgGfgS9u/jkTfqQkNGKi\r
31         plpHPiWTklK3Xn048VC/13QEYhUktRJFHqRqo7/+v0mPcrf/8cngpIdkzY/s+UbnsMj0\r
32         +24F9uT0+x3WCazaziFGGUt6nsyA/GS4aZLCKTZjU6p+RqA22TcHvAXYt1AmPBqTn9fx\r
33         OW2E18Z7zfFQ+nXRVz0vWf50/7/0IVsd2VChjn9vVlOAN296jZkxmZAWk0lSyeh/r0Ia\r
34         /vLw==\r
35 X-Received: by 10.180.101.134 with SMTP id fg6mr16465233wib.6.1396763109831;\r
36         Sat, 05 Apr 2014 22:45:09 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id u6sm15187135wif.6.2014.04.05.22.45.08\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sat, 05 Apr 2014 22:45:09 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org,\r
44         amdragon@MIT.EDU\r
45 Subject: [PATCH v2 4/5] emacs: hello: switch notmuch-hello-insert-buttons to\r
46         plists\r
47 Date: Sun,  6 Apr 2014 06:44:48 +0100\r
48 Message-Id: <1396763089-32452-5-git-send-email-markwalters1009@gmail.com>\r
49 X-Mailer: git-send-email 1.7.10.4\r
50 In-Reply-To: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com>\r
51 References: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com>\r
52 X-BeenThere: notmuch@notmuchmail.org\r
53 X-Mailman-Version: 2.1.13\r
54 Precedence: list\r
55 List-Id: "Use and development of the notmuch mail system."\r
56         <notmuch.notmuchmail.org>\r
57 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
59 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
60 List-Post: <mailto:notmuch@notmuchmail.org>\r
61 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
62 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
64 X-List-Received-Date: Sun, 06 Apr 2014 05:45:20 -0000\r
65 \r
66 Switching notmuch-hello-insert-buttons to plists means we can easily\r
67 pass extra options through to the buttons.\r
68 ---\r
69  emacs/notmuch-hello.el |   35 ++++++++++++++++++++---------------\r
70  1 file changed, 20 insertions(+), 15 deletions(-)\r
71 \r
72 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
73 index 30f26db..f440352 100644\r
74 --- a/emacs/notmuch-hello.el\r
75 +++ b/emacs/notmuch-hello.el\r
76 @@ -424,7 +424,9 @@ (defun notmuch-hello-query-counts (query-list &rest options)\r
77  these is a plist but other options are available for backwards\r
78  compatibility: see `notmuch-saved-searches' for details.\r
79  \r
80 -The result is the list of elements of the form (NAME QUERY COUNT).\r
81 +The result is a list of plists each of which includes the\r
82 +properties :name NAME, :query QUERY and :count COUNT, together\r
83 +with any properties in the original saved-search.\r
84  \r
85  The values :show-empty-searches, :filter and :filter-count from\r
86  options will be handled as specified for\r
87 @@ -454,23 +456,26 @@ (defun notmuch-hello-query-counts (query-list &rest options)\r
88       #'identity\r
89       (mapcar\r
90        (lambda (elem)\r
91 -       (let ((name (notmuch-saved-search-get elem :name))\r
92 -             (search-query (notmuch-saved-search-get elem :query))\r
93 -             (message-count (prog1 (read (current-buffer))\r
94 +       (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))\r
95 +              (search-query (plist-get elem-plist :query))\r
96 +              (filtered-query (notmuch-hello-filtered-query\r
97 +                               search-query (plist-get options :filter)))\r
98 +              (message-count (prog1 (read (current-buffer))\r
99                                 (forward-line 1))))\r
100 -         (and (or (plist-get options :show-empty-searches) (> message-count 0))\r
101 -              (list name (notmuch-hello-filtered-query\r
102 -                          search-query (plist-get options :filter))\r
103 -                    message-count))))\r
104 +         (when (and filtered-query (or (plist-get options :show-empty-searches) (> message-count 0)))\r
105 +           (setq elem-plist (plist-put elem-plist :query filtered-query))\r
106 +           (plist-put elem-plist :count message-count))))\r
107        query-list))))\r
108  \r
109  (defun notmuch-hello-insert-buttons (searches)\r
110    "Insert buttons for SEARCHES.\r
111  \r
112 -SEARCHES must be a list containing lists of the form (NAME QUERY COUNT), where\r
113 -QUERY is the query to start when the button for the corresponding entry is\r
114 -activated. COUNT should be the number of messages matching the query.\r
115 -Such a list can be computed with `notmuch-hello-query-counts'."\r
116 +SEARCHES must be a list of plists each of which should contain at\r
117 +least the properties :name NAME :query QUERY and :count COUNT,\r
118 +where QUERY is the query to start when the button for the\r
119 +corresponding entry is activated, and COUNT should be the number\r
120 +of messages matching the query.  Such a plist can be computed\r
121 +with `notmuch-hello-query-counts'."\r
122    (let* ((widest (notmuch-hello-longest-label searches))\r
123          (tags-and-width (notmuch-hello-tags-per-line widest))\r
124          (tags-per-line (car tags-and-width))\r
125 @@ -488,9 +493,9 @@ (defun notmuch-hello-insert-buttons (searches)\r
126             (when elem\r
127               (if (> column-indent 0)\r
128                   (widget-insert (make-string column-indent ? )))\r
129 -             (let* ((name (first elem))\r
130 -                    (query (second elem))\r
131 -                    (msg-count (third elem)))\r
132 +             (let* ((name (plist-get elem :name))\r
133 +                    (query (plist-get elem :query))\r
134 +                    (msg-count (plist-get elem :count)))\r
135                 (widget-insert (format "%8s "\r
136                                        (notmuch-hello-nice-number msg-count)))\r
137                 (widget-create 'push-button\r
138 -- \r
139 1.7.10.4\r
140 \r