--- /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 4824D431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 16 Apr 2014 14:22:12 -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 3QEg4dbMyX7i for <notmuch@notmuchmail.org>;\r
+ Wed, 16 Apr 2014 14:22:06 -0700 (PDT)\r
+Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com\r
+ [74.125.83.51]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 6FF00431FBD for <notmuch@notmuchmail.org>; Wed, 16 Apr 2014 14:22:06 -0700\r
+ (PDT)\r
+Received: by mail-ee0-f51.google.com with SMTP id c13so9305363eek.38\r
+ for <notmuch@notmuchmail.org>; Wed, 16 Apr 2014 14:22:05 -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=ogfNeT/6I436Njxbadw6FF11sp30sY+nXYVTsfgFkyk=;\r
+ b=a1z+I3G9v1MQ56tptaZVv4V1g+OoWXmTXEWXtejmu0co+xuT3V0Rvs22S5iHxbYzOm\r
+ 5CsXteteEZcesEdI9Bl22wNS3SU0kjsvBtqOvtCHjjXbExpXLG0BDoi6yhNj/cWo4U8/\r
+ QGvTum+pD9Nl39OY2v82Wxf6W8gXV2Oo3WNF2EiOcyEQmKyX8fB+5hM43SqhQeXLTZzS\r
+ m70gf0YLufJnFZsQz07IfxfPk4ukXZZRylx6fW1VztPgBjQZlDg/omG2vlM5qPWXml3r\r
+ 2sJ04QCHEpNvcc6m1AxA7g87EEP1VIQct/8reokUD3T9JBR+gHVVjcsFN6J6tGq09vL+\r
+ zdwQ==\r
+X-Received: by 10.14.194.133 with SMTP id m5mr8020242een.38.1397683324120;\r
+ Wed, 16 Apr 2014 14:22:04 -0700 (PDT)\r
+Received: from localhost ([217.17.137.178])\r
+ by mx.google.com with ESMTPSA id o4sm61326273eef.20.2014.04.16.14.22.03\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Wed, 16 Apr 2014 14:22:03 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/1] emacs: hello: bugfix for saved searches defcustom\r
+Date: Wed, 16 Apr 2014 22:21:53 +0100\r
+Message-Id: <1397683313-28268-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1397683313-28268-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1397683313-28268-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: Wed, 16 Apr 2014 21:22:12 -0000\r
+\r
+The recent changes for saved searches introduced a bug when notmuch\r
+was loaded after the saved search was defined. This was caused by a\r
+utility function not being defined when the defcustom was loaded.\r
+\r
+Fix this by moving some code around: the defcustom is moved into\r
+notmuch-hello (which is a more natural place anyway), and the utility\r
+functions are moved before the defcustom in notmuch-hello. We are\r
+rather constrained as the defcustom for saved searches is the first\r
+variable in the notmuch-hello customize window; to avoid moving this\r
+customize the defcustom needs to be the first defcustom in\r
+notmuch-hello, and the utility functions come before that.\r
+\r
+This patch also renames one of the utility functions from\r
+notmuch--saved-searches-to-plist to\r
+notmuch-hello--saved-searches-to-plist (as it is purely local to\r
+notmuch-hello) and corrects a couple of typo/spelling mistakes pointed\r
+out by Tomi.\r
+---\r
+ emacs/notmuch-hello.el | 128 ++++++++++++++++++++++++++++++++++--------------\r
+ emacs/notmuch-lib.el | 52 --------------------\r
+ 2 files changed, 90 insertions(+), 90 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 4900a24..a7a8e20 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -29,6 +29,96 @@\r
+ (declare-function notmuch-search "notmuch" (&optional query oldest-first target-thread target-line continuation))\r
+ (declare-function notmuch-poll "notmuch" ())\r
+ \r
++(defun notmuch-saved-search-get (saved-search field)\r
++ "Get FIELD from SAVED-SEARCH.\r
++\r
++If SAVED-SEARCH is a plist, this is just `plist-get', but for\r
++backwards compatibility, this also deals with the two other\r
++possible formats for SAVED-SEARCH: cons cells (NAME . QUERY) and\r
++lists (NAME QUERY COUNT-QUERY)."\r
++ (cond\r
++ ((keywordp (car saved-search))\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 (first 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
++ "Return a copy of SAVED-SEARCH in plist form.\r
++\r
++If saved search is a plist then just return a copy. In other\r
++cases, for backwards compatibility, convert to plist form and\r
++return that."\r
++ (if (keywordp (car saved-search))\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--saved-searches-to-plist (symbol)\r
++ "Extract a saved-search variable into plist form.\r
++\r
++The new style saved search is just a plist, but for backwards\r
++compatibility we use this function to extract old style saved\r
++searches so they still work in customize."\r
++ (let ((saved-searches (default-value symbol)))\r
++ (mapcar #'notmuch-hello-saved-search-to-plist saved-searches)))\r
++\r
++(define-widget 'notmuch-saved-search-plist 'list\r
++ "A single saved search property list."\r
++ :tag "Saved Search"\r
++ :args '((list :inline t\r
++ :format "%v"\r
++ (group :format "%v" :inline t (const :format " Name: " :name) (string :format "%v"))\r
++ (group :format "%v" :inline t (const :format " Query: " :query) (string :format "%v")))\r
++ (checklist :inline t\r
++ :format "%v"\r
++ (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))\r
++ (group :format "%v" :inline t (const :format "" :sort-order)\r
++ (choice :tag " Sort Order"\r
++ (const :tag "Default" nil)\r
++ (const :tag "Oldest-first" oldest-first)\r
++ (const :tag "Newest-first" newest-first))))))\r
++\r
++(defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\r
++ (:name "unread" :query "tag:unread"))\r
++ "A list of saved searches to display.\r
++\r
++The saved search can be given in 3 forms. The preferred way is as\r
++a plist. Supported properties are\r
++\r
++ :name Name of the search (required).\r
++ :query Search to run (required).\r
++ :count-query Optional extra query to generate the count\r
++ shown. If not present then the :query property\r
++ is used.\r
++ :sort-order Specify the sort order to be used for the search.\r
++ Possible values are 'oldest-first 'newest-first or\r
++ nil. Nil means use the default sort order.\r
++\r
++Other accepted forms are a cons cell of the form (NAME . QUERY)\r
++or a list of the form (NAME QUERY COUNT-QUERY)."\r
++;; The saved-search format is also used by the all-tags notmuch-hello\r
++;; section. This section generates its own saved-search list in one of\r
++;; the latter two forms.\r
++\r
++ :get 'notmuch-hello--saved-searches-to-plist\r
++ :type '(repeat notmuch-saved-search-plist)\r
++ :tag "List of Saved Searches"\r
++ :group 'notmuch-hello)\r
++\r
+ (defcustom notmuch-hello-recent-searches-max 10\r
+ "The number of recent searches to display."\r
+ :type 'integer\r
+@@ -269,44 +359,6 @@ afterwards.")\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
+-If SAVED-SEARCH is a plist, this is just `plist-get', but for\r
+-backwards compatibility, this also deals with the two other\r
+-possible formats for SAVED-SEARCH: cons cells (NAME . QUERY) and\r
+-lists (NAME QUERY COUNT-QUERY)."\r
+- (cond\r
+- ((keywordp (car saved-search))\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 (first 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
+- "Return a copy of SAVED-SEARCH in plist form.\r
+-\r
+-If saved search is a plist then just return a copy. In other\r
+-cases, for backwards compatability, convert to plist form and\r
+-return that."\r
+- (if (keywordp (car saved-search))\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
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 3a3c69d..2941da3 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -107,58 +107,6 @@ Note that the recommended way of achieving the same is using\r
+ (defvar notmuch-search-history nil\r
+ "Variable to store notmuch searches history.")\r
+ \r
+-(defun notmuch--saved-searches-to-plist (symbol)\r
+- "Extract 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 extract old style saved\r
+-searches so they still work in customize."\r
+- (let ((saved-searches (default-value symbol)))\r
+- (mapcar #'notmuch-hello-saved-search-to-plist saved-searches)))\r
+-\r
+-(define-widget 'notmuch-saved-search-plist 'list\r
+- "A single saved search property list."\r
+- :tag "Saved Search"\r
+- :args '((list :inline t\r
+- :format "%v"\r
+- (group :format "%v" :inline t (const :format " Name: " :name) (string :format "%v"))\r
+- (group :format "%v" :inline t (const :format " Query: " :query) (string :format "%v")))\r
+- (checklist :inline t\r
+- :format "%v"\r
+- (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))\r
+- (group :format "%v" :inline t (const :format "" :sort-order)\r
+- (choice :tag " Sort Order"\r
+- (const :tag "Default" nil)\r
+- (const :tag "Oldest-first" oldest-first)\r
+- (const :tag "Newest-first" newest-first))))))\r
+-\r
+-(defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\r
+- (:name "unread" :query "tag:unread"))\r
+- "A list of saved searches to display.\r
+-\r
+-The saved search can be given in 3 forms. The preferred way is as\r
+-a plist. Supported properties are\r
+-\r
+- :name Name of the search (required).\r
+- :query Search to run (required).\r
+- :count-query Optional extra query to generate the count\r
+- shown. If not present then the :query property\r
+- is used.\r
+- :sort-order Specify the sort order to be used for the search.\r
+- Possible values are 'oldest-first 'newest-first or\r
+- nil. Nil means use the default sort order.\r
+-\r
+-Other accepted forms are a cons cell of the form (NAME . QUERY)\r
+-or a list of the form (NAME QUERY COUNT-QUERY)."\r
+-;; The saved-search format is also used by the all-tags notmuch-hello\r
+-;; section. This section generates its own saved-search list in one of\r
+-;; the latter two forms.\r
+-\r
+- :get 'notmuch--saved-searches-to-plist\r
+- :type '(repeat notmuch-saved-search-plist)\r
+- :tag "List of Saved Searches"\r
+- :group 'notmuch-hello)\r
+-\r
+ (defcustom notmuch-archive-tags '("-inbox")\r
+ "List of tag changes to apply to a message or a thread when it is archived.\r
+ \r
+-- \r
+1.7.10.4\r
+\r