notmuch-search-change-order pops up a completing-read minibuffer
completion window for choosing sort-orders.
---
 emacs/notmuch.el | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 334458b7..93b4e582 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -178,6 +178,7 @@ there will be called at other points of notmuch execution."
     (define-key map "r" 'notmuch-search-reply-to-thread-sender)
     (define-key map "R" 'notmuch-search-reply-to-thread)
     (define-key map "o" 'notmuch-search-toggle-order)
+    (define-key map "O" 'notmuch-search-change-order)
     (define-key map "c" 'notmuch-search-stash-map)
     (define-key map "t" 'notmuch-search-filter-by-tag)
     (define-key map "l" 'notmuch-search-filter)
@@ -1044,6 +1045,19 @@ same relative position within the new buffer."
     (subject-ascending 'subject-descending)
     (subject-descending 'subject-ascending)))
 
+(defun notmuch-search-change-order (&optional sort-order)
+  "Change the current search order.
+
+This command changes the order for current search. The default
+sort order is defuned by `notmuch-search-sort-order'."
+  (interactive)
+  (let ((so (if sort-order sort-order
+             (cdr (assoc (completing-read
+                          "Select a sort order:" notmuch-sort-orders)
+                         notmuch-sort-orders)))))
+    (set 'notmuch-search-sort-order so)
+    (notmuch-search-refresh-view)))
+
 (defun notmuch-search-toggle-order ()
   "Toggle the current search order.
 
-- 
2.13.2

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to