--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 57389431FC7\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 14:24:52 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ 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 JNMFvRJTGPNT for <notmuch@notmuchmail.org>;\r
+ Sat, 5 Apr 2014 14:24:46 -0700 (PDT)\r
+Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com\r
+ [209.85.212.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 9AD69431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 14:24:46 -0700 (PDT)\r
+Received: by mail-wi0-f171.google.com with SMTP id q5so3098582wiv.10\r
+ for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 14:24:45 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=sXN0e30DKMzSQdAzlHeB7T7l6fbaI3z0oV++oHNt1FY=;\r
+ b=GAUC65LOhvVBQkrZ0FXXyexLY4cZNbWST3yr5uBT+7fEGMwEYDG9/AUH/PjLkMESjQ\r
+ c0142kgoMDi5KkKiWlUVLFEf8QgLAoMjMCItLx/5DXmTNgYDeWNjxkVTG3BkVGdic8D1\r
+ miGj40B99/PNRvsAmlb8s9UR454wdzCvyPaWIEA2koywxgymrebMPHjqy3IMJGQOs+O1\r
+ 7oXWlUZ+oqDgeLygfMKAC+lOzdXCcDxtMd9yY9e2CQPS5yISU5PA1qsSgjhEy9p9yQDW\r
+ jnyDDlP+iXGz6qMVr2bOLfHhFiqk7/7pKiGYVxTnXMSATmCmee2o5oHOU5+AKD8xKUlR\r
+ wHgA==\r
+X-Received: by 10.194.76.10 with SMTP id g10mr30350660wjw.67.1396733085160;\r
+ Sat, 05 Apr 2014 14:24:45 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id\r
+ l12sm18567425wjr.35.2014.04.05.14.24.44 for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 05 Apr 2014 14:24:44 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/5] emacs: hello: add helper functions for saved-searches\r
+Date: Sat, 5 Apr 2014 22:24:21 +0100\r
+Message-Id: <1396733065-32602-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com>\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: Sat, 05 Apr 2014 21:24:52 -0000\r
+\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
++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
++ (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
++ (: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
++The new style saved search is just a plist, but for backwards\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
++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
++ (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
+-- \r
+1.7.10.4\r
+\r