--- /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 4FE9A431FC2\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 22:45:35 -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 sDtzSEzRbAc4 for <notmuch@notmuchmail.org>;\r
+ Sat, 5 Apr 2014 22:45:28 -0700 (PDT)\r
+Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com\r
+ [209.85.212.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 8386E431FCB\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 22:45:12 -0700 (PDT)\r
+Received: by mail-wi0-f176.google.com with SMTP id r20so3354395wiv.3\r
+ for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 22:45:11 -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=cvOGaj5FMk+DCB/r36KSs/XY/pjMLi35LiNhnr0ok6w=;\r
+ b=ibFDmxNIzxLiO0ZjP2Y33DkNFjYzTqyZc8weO4I19hTO0rn3AZ6rWBO+9WHbFgAUHv\r
+ yRBr3KK9RhBEI7ryN4e9ehza2Ea0VFEHnvm9WHhLF9IsktL7xAyiV518A4sKePMsInbK\r
+ OR45RdxD1cFKS83LGn/KOom2WMraiqKDxNyV5C3IBg9YKi4IdFPHM6v81sYxXXeNpQV2\r
+ NIg3KboEh4I0LTwTZdvXuV44Af39EXyYo1nYiRCnfxAvMahycTWr8XuhR7nElmFBf3C6\r
+ ANCU0XhOfaQT0jT7Z/dcjm72ZlasMfBvd5XB3swv44iMSaIFoZJvLo0eXrDl+xeDNu3L\r
+ hv+w==\r
+X-Received: by 10.180.219.44 with SMTP id pl12mr16574095wic.12.1396763111466; \r
+ Sat, 05 Apr 2014 22:45:11 -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 v6sm15204280wif.0.2014.04.05.22.45.10\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 05 Apr 2014 22:45:11 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+ amdragon@MIT.EDU\r
+Subject: [PATCH v2 5/5] emacs: Add a sort-order option to saved-searches\r
+Date: Sun, 6 Apr 2014 06:44:49 +0100\r
+Message-Id: <1396763089-32452-6-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1396763089-32452-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: Sun, 06 Apr 2014 05:45:35 -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 | 8 +++++++-\r
+ emacs/notmuch-lib.el | 10 +++++++++-\r
+ 2 files changed, 16 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index f440352..f0675f2 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -363,7 +363,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
+@@ -495,12 +496,17 @@ (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 (case (plist-get elem :sort-order)\r
++ (newest-first nil)\r
++ (oldest-first t)\r
++ (otherwise 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 a54a055..3a3c69d 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
+@@ -139,6 +144,9 @@ (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\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
+-- \r
+1.7.10.4\r
+\r