--- /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 BF996431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 14:25:06 -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 QgKJ6--b3H4W for <notmuch@notmuchmail.org>;\r
+ Sat, 5 Apr 2014 14:24:58 -0700 (PDT)\r
+Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com\r
+ [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id AEDA0431FC7\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 14:24:52 -0700 (PDT)\r
+Received: by mail-wi0-f174.google.com with SMTP id d1so3104996wiv.7\r
+ for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 14:24:51 -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=ZGtKMQzv/4fXbY06ReixlWCJwNjbLNz3AM8G7l5IpwE=;\r
+ b=Vk18QOPt+KK+z7PkOH4xX9YPhUeDsByobolUOmQ7i9NFHOwfri0zDADd9oT7kBjZXz\r
+ Jtpsia0+/f6mM0TqBHcRD7ChzXbgROtSMCSCWqp3fazxQPJFg/Nj8mqe2FOyoe1X9TTW\r
+ iOZk3feNxIrrGH4B2gnRmRnMG4dmb31Mp5gMnF/zSupaMjtrGK3x9Nb7mjs29m8f6ppy\r
+ Bf69hohyJ/ZEXaIK8QmpUl2BymPUiYY6ISDsAEzejgwUxUCzdvhr5r0m/WCgBJ5x0RI5\r
+ JqBWIfu3o40UOdcxV85XXLfbZ5/BWHiiiLKGG43vH2qRbs+wDVM3Sk9i7sGci745OUMg\r
+ AXWw==\r
+X-Received: by 10.180.96.200 with SMTP id du8mr14433808wib.43.1396733091623;\r
+ Sat, 05 Apr 2014 14:24:51 -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 gi8sm6779580wib.8.2014.04.05.14.24.50\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 05 Apr 2014 14:24:51 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 5/5] emacs: Add a sort-order option to saved-searches\r
+Date: Sat, 5 Apr 2014 22:24:25 +0100\r
+Message-Id: <1396733065-32602-6-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:25:07 -0000\r
+\r
+This adds a sort-order option to saved-searches, stores it in the\r
+saved-search buttons (widgets), and uses the stored value when the\r
+button is pressed.\r
+\r
+Storing the sort-order in the widget was suggested by Jani in\r
+id:4c3876274126985683e888641b29cf18142a5eb8.1391771337.git.jani@nikula.org.\r
+---\r
+ emacs/notmuch-hello.el | 11 ++++++++++-\r
+ emacs/notmuch-lib.el | 7 ++++++-\r
+ 2 files changed, 16 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index aa40e6f..6a28372 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -364,7 +364,8 @@ (defun notmuch-hello-reflect (list ncols)\r
+ (defun notmuch-hello-widget-search (widget &rest ignore)\r
+ (notmuch-search (widget-get widget\r
+ :notmuch-search-terms)\r
+- notmuch-search-oldest-first))\r
++ (widget-get widget\r
++ :notmuch-search-oldest-first)))\r
+ \r
+ (defun notmuch-saved-search-count (search)\r
+ (car (process-lines notmuch-command "count" search)))\r
+@@ -496,12 +497,20 @@ (defun notmuch-hello-insert-buttons (searches)\r
+ (widget-insert (make-string column-indent ? )))\r
+ (let* ((name (plist-get elem :name))\r
+ (query (plist-get elem :query))\r
++ (oldest-first (cond\r
++ ((eq (plist-get elem :sort-order) 'newest-first)\r
++ nil)\r
++ ((eq (plist-get elem :sort-order) 'oldest-first)\r
++ t)\r
++ (t\r
++ notmuch-search-oldest-first)))\r
+ (msg-count (plist-get elem :count)))\r
+ (widget-insert (format "%8s "\r
+ (notmuch-hello-nice-number msg-count)))\r
+ (widget-create 'push-button\r
+ :notify #'notmuch-hello-widget-search\r
+ :notmuch-search-terms query\r
++ :notmuch-search-oldest-first oldest-first\r
+ name)\r
+ (setq column-indent\r
+ (1+ (max 0 (- column-width (length name)))))))\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 8a12f91..8aa8cfc 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -125,7 +125,12 @@ (define-widget 'notmuch-saved-search-plist 'list\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 "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
+-- \r
+1.7.10.4\r
+\r