--- /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 17D10431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 17:58:29 -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 OvvoJ5CJKs6a for <notmuch@notmuchmail.org>;\r
+ Sat, 5 Apr 2014 17:58:25 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-1.mit.edu (dmz-mailsec-scanner-1.mit.edu\r
+ [18.9.25.12])\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 23143431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 17:58:25 -0700 (PDT)\r
+X-AuditID: 1209190c-f794a6d000000c27-88-5340a6b00a96\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 14.61.03111.0B6A0435; Sat, 5 Apr 2014 20:58:24 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s360wMlr028426; \r
+ Sat, 5 Apr 2014 20:58:23 -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 s360wKZ2013328\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Sat, 5 Apr 2014 20:58:21 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1WWbPg-0006wI-5q; Sat, 05 Apr 2014 20:58:20 -0400\r
+Date: Sat, 5 Apr 2014 20:58:20 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH 1/5] emacs: hello: add helper functions for saved-searches\r
+Message-ID: <20140406005820.GD15472@mit.edu>\r
+References: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com>\r
+ <1396733065-32602-2-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-2-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hTV1t2wzCHY4OxnPovVc3ksrt+cyezA\r
+ 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZfz82sZW0CZZ0Xp7AmMD4wPhLkZODgkBE4lp\r
+ J68wQ9hiEhfurWfrYuTiEBKYzSRx4swxZghnA6PE6rMPmCCcU0wS6/YsZgJpERJYwihxeBYP\r
+ iM0ioCJxddM0FhCbTUBDYtv+5YwgtoiAjsTtQwvYQWxmAWmJb7+bwXqFBfwkDkw7DWbzAtWc\r
+ /9UDtaCTUeLWj/WMEAlBiZMzn7BANGtJ3Pj3EqiIA2zQ8n8cIGFOAS+J3ct3gM0XBbphyslt\r
+ bBMYhWYh6Z6FpHsWQvcCRuZVjLIpuVW6uYmZOcWpybrFyYl5ealFuoZ6uZkleqkppZsYwWEt\r
+ ybOD8c1BpUOMAhyMSjy8F/IcgoVYE8uKK3MPMUpyMCmJ8nbNAArxJeWnVGYkFmfEF5XmpBYf\r
+ YpTgYFYS4X0SBJTjTUmsrEotyodJSXOwKInzvrW2ChYSSE8sSc1OTS1ILYLJynBwKEnw7l0K\r
+ 1ChYlJqeWpGWmVOCkGbi4AQZzgM0/B5IDW9xQWJucWY6RP4Uo6KUOO+MJUAJAZBERmkeXC8s\r
+ 7bxiFAd6RZhXB6SdB5iy4LpfAQ1mAhrcEGYHMrgkESEl1cBYWCwwe5LGS+s3+hqbcmWn/Lqe\r
+ dLX9cMtXPYMIK+8vrG+Vtm172JrV0r5mhrVqnmfRzA33PJse7pR/Kbtk/+ygOXMWF8e3JkfM\r
+ t9hdxJe4+tP5kNTlsc3TEn1mJTQ2ZJT9bNoY2rn3zfp/50+q2+j+nG+wZtKT5Czla6kXfzM8\r
+ KtJfl1qxpm+KEktxRqKhFnNRcSIAT+c/TBYDAAA=\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 00:58:29 -0000\r
+\r
+Quoth Mark Walters on Apr 05 at 10:24 pm:\r
+> Add helper functions to for saved searches to ease the transition to\r
+> the new plist form while maintaining backwards compatibility. They\r
+> will be used in the next patch.\r
+> ---\r
+> emacs/notmuch-hello.el | 39 +++++++++++++++++++++++++++++++++++++++\r
+> 1 file changed, 39 insertions(+)\r
+> \r
+> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+> index e325cd3..0b9ed16 100644\r
+> --- a/emacs/notmuch-hello.el\r
+> +++ b/emacs/notmuch-hello.el\r
+> @@ -269,6 +269,45 @@ (defun notmuch-hello-search (&optional search)\r
+> (add-to-history 'notmuch-search-history search)))\r
+> (notmuch-search search notmuch-search-oldest-first))\r
+> \r
+> +(defun notmuch-saved-search-get (saved-search field)\r
+> + "Get FIELD from SAVED-SEARCH.\r
+> +\r
+> +In the new style saved-search (a plist) this is just plist-get\r
+\r
+It won't be "new style" once this has been in for a while. Perhaps\r
+"If SAVED-SEARCH is a plist, this is just `plist-get', but for\r
+backwards compatibility, ..."\r
+\r
+> +but, for backwards compatibility, this deals with the two\r
+> +old-style forms: cons cells (NAME . QUERY) and lists (NAME QUERY\r
+> +COUNT-QUERY)."\r
+> + (cond\r
+> + ((plist-get saved-search :name)\r
+\r
+Rather than depending on :name, maybe this should be a more generic\r
+plist test like (keywordp (car saved-search))?\r
+\r
+> + (plist-get saved-search field))\r
+> + ;; It is not a plist so it is an old-style entry.\r
+> + ((consp (cdr saved-search)) ;; It is a list (NAME QUERY COUNT-QUERY)\r
+> + (case field\r
+> + (:name (car saved-search))\r
+\r
+Use `first' for consistency with the other case cases?\r
+\r
+> + (:query (second saved-search))\r
+> + (:count-query (third saved-search))\r
+> + (t nil)))\r
+> + (t ;; It is a cons-cell (NAME . QUERY)\r
+> + (case field\r
+> + (:name (car saved-search))\r
+> + (:query (cdr saved-search))\r
+> + (t nil)))))\r
+> +\r
+> +(defun notmuch-hello-saved-search-to-plist (saved-search)\r
+> + "Convert a saved-search variable into plist form.\r
+\r
+This takes a value, not a variable. But it could be more succinct and\r
+more accurate: "Return a copy of SAVED-SEARCH in plist form."\r
+\r
+> +\r
+> +The new style saved search is just a plist, but for backwards\r
+\r
+Same comment about "new style".\r
+\r
+> +compatatibility we use this function to give them in\r
+> +plist-form. In all cases a new copy is returned so it is safe to\r
+\r
+Grammar error?\r
+\r
+> +modify the returned value."\r
+> + (if (and (listp (cdr saved-search)) (plist-member saved-search :name))\r
+> + (copy-seq saved-search)\r
+> + (let ((fields (list :name :query :count-query))\r
+> + (plist-search))\r
+\r
+Personally I prefer to either explicitly initialize nil variables or\r
+to list them without the parenthesis at all (for some reason my brain\r
+automatically reads this as an application), but if you prefer this,\r
+that's fine, too.\r
+\r
+> + (dolist (field fields plist-search)\r
+> + (let ((string (notmuch-saved-search-get saved-search field)))\r
+> + (when string\r
+> + (setq plist-search (append plist-search (list field string)))))))))\r
+> +\r
+> (defun notmuch-hello-add-saved-search (widget)\r
+> (interactive)\r
+> (let ((search (widget-value\r