--- /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 arlo.cworth.org (Postfix) with ESMTP id 1FF266DE1588\r
+ for <notmuch@notmuchmail.org>; Fri, 26 Jun 2015 15:51:06 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.142\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.142 tagged_above=-999 required=5 tests=[AWL=0.712, \r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id PlIayiOC20wA for <notmuch@notmuchmail.org>;\r
+ Fri, 26 Jun 2015 15:51:04 -0700 (PDT)\r
+Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com\r
+ [74.125.82.43]) by arlo.cworth.org (Postfix) with ESMTPS id 9ED0B6DE1533 for\r
+ <notmuch@notmuchmail.org>; Fri, 26 Jun 2015 15:50:53 -0700 (PDT)\r
+Received: by wgck11 with SMTP id k11so99251974wgc.0\r
+ for <notmuch@notmuchmail.org>; Fri, 26 Jun 2015 15:50:52 -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=lF9AseiHbV1HOOIykphuGEHHiwpWoqzziRK7Hhr5rfo=;\r
+ b=NudNPUpPjIZEYV8bkVHH3SIlNZjLRDkNkfJm3ijIs9HuH3qp7ZZnU72cFhd71ZfIEj\r
+ AHoJ0KdtnYPTWrWlU9kPLHK8lh0VtWrY2eHQLDEV73jESgeF2MEeEP88zHWgBZGfCOtE\r
+ 80MV0D0fymWa+YBZNIpJ3p8f46/KNJ4etiKnmtRmZfgr75ewLuWPDECjhyYXQ+hhUvQD\r
+ HieqQrBIlkEJ4hmC9hxkIJ96NT7/DPeyruM27oCH1WyZe5WbZmhOc3wBJ1+mgUAyKN1g\r
+ fUm6dDDwNRreASnUWwG/2YyABGPPaZOLdqnnUB7H0bvWwo9jaLj/e674KZwMIpSPbRkb\r
+ qNXQ==\r
+X-Received: by 10.194.200.194 with SMTP id ju2mr6622844wjc.61.1435359050925;\r
+ Fri, 26 Jun 2015 15:50:50 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by mx.google.com with ESMTPSA id m2sm405830wiy.7.2015.06.26.15.50.50\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Fri, 26 Jun 2015 15:50:50 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/4] emacs: tree: add sort argument to notmuch-tree\r
+Date: Fri, 26 Jun 2015 23:50:34 +0100\r
+Message-Id: <1435359035-6767-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1435359035-6767-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1435359035-6767-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Fri, 26 Jun 2015 22:51:06 -0000\r
+\r
+This is used by the the notmuch-search command\r
+notmuch-tree-from-search-current-query which now keeps the sort order\r
+the same when calling tree mode with the current search query.\r
+\r
+It also uses the customize variable notmuch-search-oldest-first as the\r
+default for sort order of a tree search (only relevant for interactive\r
+use).\r
+---\r
+ emacs/notmuch-tree.el | 21 +++++++++++++++------\r
+ emacs/notmuch.el | 2 +-\r
+ 2 files changed, 16 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el\r
+index 6afed76..b9d9b91 100644\r
+--- a/emacs/notmuch-tree.el\r
++++ b/emacs/notmuch-tree.el\r
+@@ -565,7 +565,9 @@ (defun notmuch-tree-refresh-view ()\r
+ (erase-buffer)\r
+ (notmuch-tree-worker basic-query\r
+ query-context\r
+- target)))\r
++ target\r
++ nil\r
++ notmuch-tree-oldest-first)))\r
+ \r
+ (defun notmuch-tree-toggle-order ()\r
+ "Toggle the current search order.\r
+@@ -865,7 +867,7 @@ (defun notmuch-tree-process-filter (proc string)\r
+ (notmuch-sexp-parse-partial-list 'notmuch-tree-insert-forest-thread\r
+ results-buf)))))\r
+ \r
+-(defun notmuch-tree-worker (basic-query &optional query-context target open-target)\r
++(defun notmuch-tree-worker (basic-query &optional query-context target open-target oldest-first)\r
+ "Insert the tree view of the search in the current buffer.\r
+ \r
+ This is is a helper function for notmuch-tree. The arguments are\r
+@@ -876,6 +878,7 @@ (defun notmuch-tree-worker (basic-query &optional query-context target open-targ\r
+ (setq notmuch-tree-query-context query-context)\r
+ (setq notmuch-tree-target-msg target)\r
+ (setq notmuch-tree-open-target open-target)\r
++ (setq notmuch-tree-oldest-first oldest-first)\r
+ \r
+ (erase-buffer)\r
+ (goto-char (point-min))\r
+@@ -911,7 +914,7 @@ (defun notmuch-tree-get-query ()\r
+ ")")\r
+ notmuch-tree-basic-query))\r
+ \r
+-(defun notmuch-tree (&optional query query-context target buffer-name open-target)\r
++(defun notmuch-tree (&optional query query-context target buffer-name open-target oldest-first)\r
+ "Display threads matching QUERY in Tree View.\r
+ \r
+ The arguments are:\r
+@@ -924,8 +927,14 @@ (defun notmuch-tree (&optional query query-context target buffer-name open-targe\r
+ current if it appears in the tree view results.\r
+ BUFFER-NAME: the name of the buffer to display the tree view. If\r
+ it is nil \"*notmuch-tree\" followed by QUERY is used.\r
+- OPEN-TARGET: If TRUE open the target message in the message pane."\r
+- (interactive)\r
++ OPEN-TARGET: If TRUE open the target message in the message pane.\r
++ OLDEST-FIRST: If TRUE display threads sorted oldest first"\r
++ (interactive\r
++ (list\r
++ ;; Prompt for a query\r
++ nil\r
++ ;; use default search order\r
++ nil nil nil nil (default-value 'notmuch-search-oldest-first)))\r
+ (if (null query)\r
+ (setq query (notmuch-read-query "Notmuch tree view search: ")))\r
+ (let ((buffer (get-buffer-create (generate-new-buffer-name\r
+@@ -937,7 +946,7 @@ (defun notmuch-tree (&optional query query-context target buffer-name open-targe\r
+ ;; Don't track undo information for this buffer\r
+ (set 'buffer-undo-list t)\r
+ \r
+- (notmuch-tree-worker query query-context target open-target)\r
++ (notmuch-tree-worker query query-context target open-target oldest-first)\r
+ \r
+ (setq truncate-lines t))\r
+ \r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 6564816..f1035dc 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -478,7 +478,7 @@ (defun notmuch-search-show-thread (&optional elide-toggle)\r
+ (defun notmuch-tree-from-search-current-query ()\r
+ "Call notmuch tree with the current query"\r
+ (interactive)\r
+- (notmuch-tree notmuch-search-query-string))\r
++ (notmuch-tree notmuch-search-query-string nil nil nil nil notmuch-search-oldest-first))\r
+ \r
+ (defun notmuch-tree-from-search-thread ()\r
+ "Show the selected thread with notmuch-tree"\r
+-- \r
+2.1.4\r
+\r