Add a U binding to switch to unthreaded from other views

We have shortcuts S and Z to let the user switch to Search view and
Tree view with the current search. Add U to let the user switch to
unthreaded view from the current search, and ensure that S and Z
switch from unthreaded to search and tree veiew respectively.
This commit is contained in:
Mark Walters 2020-02-27 17:16:51 +00:00 committed by David Bremner
parent c36e91d9d4
commit c578c32e3b
3 changed files with 37 additions and 2 deletions

View file

@ -50,6 +50,8 @@
(declare-function notmuch-tree "notmuch-tree"
(&optional query query-context target buffer-name open-target unthreaded))
(declare-function notmuch-tree-get-message-properties "notmuch-tree" nil)
(declare-function notmuch-unthreaded
(&optional query query-context target buffer-name open-target))
(declare-function notmuch-read-query "notmuch" (prompt))
(declare-function notmuch-draft-resume "notmuch-draft" (id))
@ -1471,6 +1473,7 @@ reset based on the original query."
(let ((map (make-sparse-keymap)))
(set-keymap-parent map notmuch-common-keymap)
(define-key map "Z" 'notmuch-tree-from-show-current-query)
(define-key map "U" 'notmuch-unthreaded-from-show-current-query)
(define-key map (kbd "<C-tab>") 'widget-backward)
(define-key map (kbd "M-TAB") 'notmuch-show-previous-button)
(define-key map (kbd "<backtab>") 'notmuch-show-previous-button)
@ -1559,6 +1562,13 @@ All currently available key bindings:
notmuch-show-query-context
(notmuch-show-get-message-id)))
(defun notmuch-unthreaded-from-show-current-query ()
"Call notmuch unthreaded with the current query"
(interactive)
(notmuch-unthreaded notmuch-show-thread-id
notmuch-show-query-context
(notmuch-show-get-message-id)))
(defun notmuch-show-move-to-message-top ()
(goto-char (notmuch-show-message-top)))

View file

@ -294,6 +294,8 @@ FUNC."
(define-key map [remap notmuch-jump-search] (notmuch-tree-close-message-pane-and #'notmuch-jump-search))
(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)
;; these use notmuch-show functions directly
(define-key map "|" 'notmuch-show-pipe-message)
@ -474,6 +476,18 @@ NOT change the database."
(notmuch-tree-close-message-window)
(notmuch-tree query)))
(defun notmuch-unthreaded-from-tree-current-query ()
"Switch from tree view to unthreaded view"
(interactive)
(unless notmuch-tree-unthreaded
(notmuch-tree-refresh-view 'unthreaded)))
(defun notmuch-tree-from-unthreaded-current-query ()
"Switch from unthreaded view to tree view"
(interactive)
(when notmuch-tree-unthreaded
(notmuch-tree-refresh-view 'tree)))
(defun notmuch-search-from-tree-current-query ()
"Call notmuch search with the current query"
(interactive)
@ -635,19 +649,24 @@ message will be \"unarchived\", i.e. the tag changes in
(when (window-live-p notmuch-tree-message-window)
(notmuch-tree-show-message-in)))
(defun notmuch-tree-refresh-view ()
(defun notmuch-tree-refresh-view (&optional view)
"Refresh view."
(interactive)
(when (get-buffer-process (current-buffer))
(error "notmuch tree process already running for current buffer"))
(let ((inhibit-read-only t)
(basic-query notmuch-tree-basic-query)
(unthreaded (cond ((eq view 'unthreaded) t)
((eq view 'tree) nil)
(t notmuch-tree-unthreaded)))
(query-context notmuch-tree-query-context)
(target (notmuch-tree-get-message-id)))
(erase-buffer)
(notmuch-tree-worker basic-query
query-context
target)))
target
nil
unthreaded)))
(defun notmuch-tree-thread-top ()
(when (notmuch-tree-get-message-properties)

View file

@ -190,6 +190,7 @@ there will be called at other points of notmuch execution."
(define-key map (kbd "RET") 'notmuch-search-show-thread)
(define-key map (kbd "M-RET") 'notmuch-tree-from-search-thread)
(define-key map "Z" 'notmuch-tree-from-search-current-query)
(define-key map "U" 'notmuch-unthreaded-from-search-current-query)
map)
"Keymap for \"notmuch search\" buffers.")
(fset 'notmuch-search-mode-map notmuch-search-mode-map)
@ -523,6 +524,11 @@ thread."
(interactive)
(notmuch-tree notmuch-search-query-string))
(defun notmuch-unthreaded-from-search-current-query ()
"Call notmuch tree with the current query"
(interactive)
(notmuch-unthreaded notmuch-search-query-string))
(defun notmuch-tree-from-search-thread ()
"Show the selected thread with notmuch-tree"
(interactive)