--- /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 F20EE429E37\r
+ for <notmuch@notmuchmail.org>; Sun, 4 May 2014 05:45:36 -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 W9tOsXlm+oH4 for <notmuch@notmuchmail.org>;\r
+ Sun, 4 May 2014 05:45:31 -0700 (PDT)\r
+Received: from mail-we0-f173.google.com (mail-we0-f173.google.com\r
+ [74.125.82.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 47514431E64\r
+ for <notmuch@notmuchmail.org>; Sun, 4 May 2014 05:45:31 -0700 (PDT)\r
+Received: by mail-we0-f173.google.com with SMTP id w61so6494478wes.32\r
+ for <notmuch@notmuchmail.org>; Sun, 04 May 2014 05:45:30 -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;\r
+ bh=5XWkDVPffRn0QzYBAgtO6L8e9+prHWWV7izMFFif/M0=;\r
+ b=U+AjpYA+U30PwXm6yFtTr3SlD17F91uEdKenCmp94avKhL+YShIW/fGa9BoJDVVFOk\r
+ VNCOvHRy2fgTaCgkVgHCkmqqxemeUOqqf+ZOk1VfgHwuehbzi3Pef1AriBFZOnmbpugf\r
+ 9AqR2tYRMPXewenjAlWq4bPxSlSj0pIqpw9Ivc02VzQWVnh0+Hd68kOMezAtEQIalwnk\r
+ sruB74h52nyFHufvX+q94kuNN4yseQJjTGqM/YO2lkrLWOp4uxUXlTVgjBkPuq8CkmGw\r
+ ntFGTBvDsAmEtu0NwSHaQVEqr/iVh4ZYCQkjMnGE7iBVLZroieuQ6f7TeudmMFq2deHr\r
+ UOVQ==\r
+X-Received: by 10.180.211.207 with SMTP id ne15mr11416866wic.31.1399207529903;\r
+ Sun, 04 May 2014 05:45:29 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by mx.google.com with ESMTPSA id ej7sm10658697wib.9.2014.05.04.05.45.28\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 04 May 2014 05:45:28 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: hello: allow extras to add to saved-search defcustom\r
+Date: Sun, 4 May 2014 13:45:21 +0100\r
+Message-Id: <1399207521-24611-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\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, 04 May 2014 12:45:37 -0000\r
+\r
+This adds an extra variable notmuch-saved-search-extras that allows\r
+the user to add extra options to the saved-search customize\r
+variable. Of course it is up to them to make these extra options do\r
+anything afterwards.\r
+\r
+The difficulty is that the code definining a defcustom is executed\r
+when the the file is first read which would normally occur before any\r
+optional extras are loaded.\r
+\r
+To get around this I suggest that extras that wish to use this\r
+infrastucture add a helper loader file that does something like\r
+the following (this example is for a tweaked version of Austin's notmuch-go)\r
+\r
+(defvar notmuch-saved-search-extras nil)\r
+\r
+(setq notmuch-saved-search-extras\r
+ (append notmuch-saved-search-extras\r
+ '((checklist :inline t\r
+ :format "%v"\r
+ (group :format "%v"\r
+ :inline t\r
+ (const :format " Go key: " :go.key)\r
+ (key-sequence :format "%v"))))))\r
+\r
+(eval-after-load 'notmuch '(require 'notmuch-go))\r
+\r
+(provide 'notmuch-go-loader)\r
+\r
+The user should then (require 'notmuch-go-loader) before loading notmuch.\r
+---\r
+\r
+The patch below is quite simple: almost all of the diff is\r
+whitespace. The more difficult part to get right was the above code\r
+snippet. It would be nice if a single file could say "don't read the\r
+following code until feature 'notmuch is present" but I don't know how\r
+to do that cleanly.\r
+\r
+The above at least means that it is simple from a user's\r
+perspective. And all that happens if they do load the extension after\r
+notmuch is that the defcustom is not updated and that is unavoidable.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+ emacs/notmuch-hello.el | 28 ++++++++++++++++------------\r
+ 1 file changed, 16 insertions(+), 12 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 3de5238..e627f42 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -76,21 +76,25 @@ (defun notmuch-hello--saved-searches-to-plist (symbol)\r
+ (let ((saved-searches (default-value symbol)))\r
+ (mapcar #'notmuch-hello-saved-search-to-plist saved-searches)))\r
+ \r
++(defvar notmuch-saved-search-extras nil\r
++ "Extra formats to add to defcustom saved search widget")\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
++ :args (append '((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
++ notmuch-saved-search-extras))\r
+ \r
+ (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\r
+ (:name "unread" :query "tag:unread"))\r
+-- \r
+1.7.10.4\r
+\r