--- /dev/null
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1ED8C431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 18:06:18 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id KXfLHtTvCbNf for <notmuch@notmuchmail.org>;\r
+ Sat, 5 Apr 2014 18:06:14 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu\r
+ [18.7.68.37])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id AA810431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 18:06:13 -0700 (PDT)\r
+X-AuditID: 12074425-f79906d000000cf9-15-5340a884b2aa\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id C5.B4.03321.488A0435; Sat, 5 Apr 2014 21:06:12 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s3616B8B006806; \r
+ Sat, 5 Apr 2014 21:06:12 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s36169R9015178\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Sat, 5 Apr 2014 21:06:11 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1WWbXF-00071G-MA; Sat, 05 Apr 2014 21:06:09 -0400\r
+Date: Sat, 5 Apr 2014 21:06:09 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH 2/5] emacs: hello: use the saved-search helper functions\r
+Message-ID: <20140406010609.GE15472@mit.edu>\r
+References: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com>\r
+ <1396733065-32602-3-git-send-email-markwalters1009@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1396733065-32602-3-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42IRYrdT121Z4RBs8GSThsXquTwW12/OZHZg\r
+ 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4Mp5+fclWMM+0omf1FOYGxiatLkZODgkBE4lF\r
+ R1azQNhiEhfurWfrYuTiEBKYzSTxZu9SdpCEkMAGRom2BS4QiVNMEn8+/maFSCxhlNgyJx/E\r
+ ZhFQkVhy7xUbiM0moCGxbf9yRhBbREBH4vahBWCDmAWkJb79bmYCsYUFfCQOPmoEq+EFqjn/\r
+ 7SMjxIJORonVu36xQyQEJU7OfMIC0awlcePfS6BmDrBBy/9xgIQ5Bbwk3l9bzAxiiwLdMOXk\r
+ NrYJjEKzkHTPQtI9C6F7ASPzKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl0LvdzMEr3UlNJNjOCg\r
+ dlHdwTjhkNIhRgEORiUe3gt5DsFCrIllxZW5hxglOZiURHm7ZgCF+JLyUyozEosz4otKc1KL\r
+ DzFKcDArifA+CQLK8aYkVlalFuXDpKQ5WJTEed9aWwULCaQnlqRmp6YWpBbBZGU4OJQkeK8v\r
+ B2oULEpNT61Iy8wpQUgzcXCCDOcBGv4TpIa3uCAxtzgzHSJ/ilFRSpy3ESQhAJLIKM2D64Ul\r
+ nVeM4kCvCPP+AaniASYsuO5XQIOZgAY3hNmBDC5JREhJNTD6bHGM081VTXzEMXmjegOnyiXZ\r
+ U/u3t235tuZZutm+qnebHtRNaLmVoLO5PPVi1+ftIvphjPHr3qrvLTivcdD6KNdNtUmPF1lN\r
+ sJ8b8adks8PvEvPb5Uq7n76ybfS31DpmfrFAI/jMA8OjL8K8bnvmNU+9uydXkL0h+59JkI7J\r
+ d985IvOrd+sosRRnJBpqMRcVJwIA4BakoBUDAAA=\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 06 Apr 2014 01:06:18 -0000\r
+\r
+Quoth Mark Walters on Apr 05 at 10:24 pm:\r
+> This uses the helper functions: the saved searches format has not\r
+> changed yet but backwards compatibility means everything still works.\r
+> ---\r
+> emacs/notmuch-hello.el | 48 ++++++++++++++++++++++--------------------------\r
+> emacs/notmuch.el | 6 +++---\r
+> 2 files changed, 25 insertions(+), 29 deletions(-)\r
+> \r
+> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+> index 0b9ed16..733208b 100644\r
+> --- a/emacs/notmuch-hello.el\r
+> +++ b/emacs/notmuch-hello.el\r
+> @@ -319,7 +319,7 @@ (defun notmuch-hello-add-saved-search (widget)\r
+> (setq notmuch-saved-searches\r
+> (loop for elem in notmuch-saved-searches\r
+> if (not (equal name\r
+> - (car elem)))\r
+> + (notmuch-saved-search-get elem :name)))\r
+> collect elem))\r
+> ;; Add the new one.\r
+> (customize-save-variable 'notmuch-saved-searches\r
+> @@ -339,7 +339,7 @@ (defun notmuch-hello-delete-search-from-history (widget)\r
+> \r
+> (defun notmuch-hello-longest-label (searches-alist)\r
+> (or (loop for elem in searches-alist\r
+> - maximize (length (car elem)))\r
+> + maximize (length (notmuch-saved-search-get elem :name)))\r
+> 0))\r
+> \r
+> (defun notmuch-hello-reflect-generate-row (ncols nrows row list)\r
+> @@ -418,13 +418,12 @@ (defun notmuch-hello-filtered-query (query filter)\r
+> (concat "(" query ") and (" filter ")"))\r
+> (t query)))\r
+> \r
+> -(defun notmuch-hello-query-counts (query-alist &rest options)\r
+> - "Compute list of counts of matched messages from QUERY-ALIST.\r
+> +(defun notmuch-hello-query-counts (query-list &rest options)\r
+> + "Compute list of counts of matched messages from QUERY-LIST.\r
+> \r
+> -QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)\r
+> -or (NAME QUERY COUNT-QUERY). If the latter form is used,\r
+> -COUNT-QUERY specifies an alternate query to be used to generate\r
+> -the count for the associated query.\r
+> +QUERY-LIST must be a list of saved-searches. Ideally each of\r
+> +these is a plist but other options are available for backwards\r
+> +compatibility: see notmuch-saved-search-get for details.\r
+\r
+s/:/./ Also `'s around notmuch-saved-search-get.\r
+\r
+Actually, the accepted formats (including the understood keys in plist\r
+form) should be documented in `notmuch-saved-searches' and this\r
+information should be cited elsewhere and not duplicated.\r
+\r
+> \r
+> The result is the list of elements of the form (NAME QUERY COUNT).\r
+> \r
+> @@ -432,11 +431,9 @@ (defun notmuch-hello-query-counts (query-alist &rest options)\r
+> options will be handled as specified for\r
+> `notmuch-hello-insert-searches'."\r
+> (with-temp-buffer\r
+> - (dolist (elem query-alist nil)\r
+> - (let ((count-query (if (consp (cdr elem))\r
+> - ;; do we have a different query for the message count?\r
+> - (third elem)\r
+> - (cdr elem))))\r
+> + (dolist (elem query-list nil)\r
+> + (let ((count-query (or (notmuch-saved-search-get elem :count-query)\r
+> + (notmuch-saved-search-get elem :query))))\r
+> (insert\r
+> (replace-regexp-in-string\r
+> "\n" " "\r
+> @@ -458,18 +455,15 @@ (defun notmuch-hello-query-counts (query-alist &rest options)\r
+> #'identity\r
+> (mapcar\r
+> (lambda (elem)\r
+> - (let ((name (car elem))\r
+> - (search-query (if (consp (cdr elem))\r
+> - ;; do we have a different query for the message count?\r
+> - (second elem)\r
+> - (cdr elem)))\r
+> + (let ((name (notmuch-saved-search-get elem :name))\r
+> + (search-query (notmuch-saved-search-get elem :query))\r
+> (message-count (prog1 (read (current-buffer))\r
+> (forward-line 1))))\r
+> (and (or (plist-get options :show-empty-searches) (> message-count 0))\r
+> (list name (notmuch-hello-filtered-query\r
+> search-query (plist-get options :filter))\r
+> message-count))))\r
+> - query-alist))))\r
+> + query-list))))\r
+> \r
+> (defun notmuch-hello-insert-buttons (searches)\r
+> "Insert buttons for SEARCHES.\r
+> @@ -728,13 +722,15 @@ (defun notmuch-hello-insert-recent-searches ()\r
+> (indent-rigidly start (point) notmuch-hello-indent))\r
+> nil))\r
+> \r
+> -(defun notmuch-hello-insert-searches (title query-alist &rest options)\r
+> - "Insert a section with TITLE showing a list of buttons made from QUERY-ALIST.\r
+> +(defun notmuch-hello-insert-searches (title query-list &rest options)\r
+> + "Insert a section with TITLE showing a list of buttons made from QUERY-LIST.\r
+> \r
+> -QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)\r
+> -or (NAME QUERY COUNT-QUERY). If the latter form is used,\r
+> -COUNT-QUERY specifies an alternate query to be used to generate\r
+> -the count for the associated item.\r
+> +QUERY-LIST should ideally be a plist but for backwards\r
+> +compatibility other forms are also accepted (see\r
+> +`notmuch-saved-search-get' for details). The plist should\r
+> +contain keys :name and :query; if :count-query is also present\r
+> +then it specifies an alternate query to be used to generate the\r
+> +count for the associated search.\r
+\r
+Same comment about moving this format documentation to\r
+`notmuch-saved-searches'.\r
+\r
+> \r
+> Supports the following entries in OPTIONS as a plist:\r
+> :initially-hidden - if non-nil, section will be hidden on startup\r
+> @@ -768,7 +764,7 @@ (defun notmuch-hello-insert-searches (title query-alist &rest options)\r
+> "hide"))\r
+> (widget-insert "\n")\r
+> (when (not is-hidden)\r
+> - (let ((searches (apply 'notmuch-hello-query-counts query-alist options)))\r
+> + (let ((searches (apply 'notmuch-hello-query-counts query-list options)))\r
+> (when (or (not (plist-get options :hide-if-empty))\r
+> searches)\r
+> (widget-insert "\n")\r
+> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> index 233c784..1346b90 100644\r
+> --- a/emacs/notmuch.el\r
+> +++ b/emacs/notmuch.el\r
+> @@ -823,14 +823,14 @@ (defun notmuch-search-buffer-title (query)\r
+> (let (longest\r
+> (longest-length 0))\r
+> (loop for tuple in notmuch-saved-searches\r
+> - if (let ((quoted-query (regexp-quote (cdr tuple))))\r
+> + if (let ((quoted-query (regexp-quote (notmuch-saved-search-get tuple :query))))\r
+> (and (string-match (concat "^" quoted-query) query)\r
+> (> (length (match-string 0 query))\r
+> longest-length)))\r
+> do (setq longest tuple))\r
+> longest))\r
+> - (saved-search-name (car saved-search))\r
+> - (saved-search-query (cdr saved-search)))\r
+> + (saved-search-name (notmuch-saved-search-get saved-search :name))\r
+> + (saved-search-query (notmuch-saved-search-get saved-search :query)))\r
+> (cond ((and saved-search (equal saved-search-query query))\r
+> ;; Query is the same as saved search (ignoring case)\r
+> (concat "*notmuch-saved-search-" saved-search-name "*"))\r