(define-key map [remap notmuch-mua-new-mail] 'notmuch-tree-new-mail)
(define-key map [remap notmuch-jump-search] 'notmuch-tree-jump-search)
+ (define-key map "o" 'notmuch-tree-toggle-order)
(define-key map "S" 'notmuch-search-from-tree-current-query)
(define-key map "U" 'notmuch-unthreaded-from-tree-current-query)
(define-key map "Z" 'notmuch-tree-from-unthreaded-current-query)
(define-key map "r" 'notmuch-tree-reply-sender)
(define-key map "R" 'notmuch-tree-reply)
(define-key map "V" 'notmuch-tree-view-raw-message)
+ (define-key map "l" 'notmuch-tree-filter)
;; The main tree view bindings
(define-key map (kbd "RET") 'notmuch-tree-show-message)
query-context
target
nil
- unthreaded)))
+ unthreaded
+ notmuch-search-oldest-first)))
(defun notmuch-tree-thread-top ()
(when (notmuch-tree-get-message-properties)
(goto-char (point-max))
(forward-line -1)
(when notmuch-tree-open-target
- (notmuch-tree-show-message-in)))))
+ (notmuch-tree-show-message-in)
+ (notmuch-tree-command-hook)))))
(defun notmuch-tree-insert-tree (tree depth tree-status first last)
"Insert the message tree TREE at depth DEPTH in the current thread.
(defun notmuch-tree-insert-forest-thread (forest-thread)
"Insert a single complete thread."
- (let (tree-status)
- ;; Reset at the start of each main thread.
- (setq notmuch-tree-previous-subject nil)
- (notmuch-tree-insert-thread forest-thread 0 tree-status)))
+ ;; Reset at the start of each main thread.
+ (setq notmuch-tree-previous-subject nil)
+ (notmuch-tree-insert-thread forest-thread 0 nil))
(defun notmuch-tree-insert-forest (forest)
"Insert a forest of threads.
(interactive)
(notmuch-tree-mode)
(add-hook 'post-command-hook #'notmuch-tree-command-hook t t)
+ (setq notmuch-search-oldest-first oldest-first)
(setq notmuch-tree-unthreaded unthreaded)
(setq notmuch-tree-basic-query basic-query)
(setq notmuch-tree-query-context (if (or (string= query-context "")
")")
notmuch-tree-basic-query))
+(defun notmuch-tree-toggle-order ()
+ "Toggle the current search order.
+
+This command toggles the sort order for the current search. The
+default sort order is defined by `notmuch-search-oldest-first'."
+ (interactive)
+ (setq notmuch-search-oldest-first (not notmuch-search-oldest-first))
+ (notmuch-tree-refresh-view))
+
(defun notmuch-tree (&optional query query-context target buffer-name
open-target unthreaded parent-buffer oldest-first)
"Display threads matching QUERY in tree view.
(interactive)
(notmuch-tree query query-context target buffer-name open-target t))
+(defun notmuch-tree-filter (query)
+ "Filter or LIMIT the current search results based on an additional query string.
+
+Runs a new tree search matching only messages that match both the
+current search results AND the additional query string provided."
+ (interactive (list (notmuch-read-query "Filter search: ")))
+ (let ((notmuch-show-process-crypto (notmuch-tree--message-process-crypto))
+ (grouped-query (notmuch-group-disjunctive-query-string query))
+ (grouped-original-query (notmuch-group-disjunctive-query-string
+ (notmuch-tree-get-query))))
+ (notmuch-tree-close-message-window)
+ (notmuch-tree (if (string= grouped-original-query "*")
+ grouped-query
+ (concat grouped-original-query " and " grouped-query)))))
+
;;; _
(provide 'notmuch-tree)