X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-tree.el;h=6e5797e970f6377ba0ba5ca79d7504c07c7dc755;hp=8b6cd51017947c27ff90dbff44bde1fbdac98add;hb=7b2d7d65126b11ce08079b7cf235e1073fb1c22b;hpb=30f1c43efe32c83193a6b9ae1f31ab2667e4195d diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 8b6cd510..6e5797e9 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -1,4 +1,4 @@ -;; notmuch-tree.el --- displaying notmuch forests. +;;; notmuch-tree.el --- displaying notmuch forests. ;; ;; Copyright © Carl Worth ;; Copyright © David Edmondson @@ -17,11 +17,13 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: David Edmondson ;; Mark Walters +;;; Code: + (require 'mail-parse) (require 'notmuch-lib) @@ -239,6 +241,10 @@ FUNC." (define-key map [remap notmuch-search] 'notmuch-tree-to-search) ;; Override because we want to close message pane first. (define-key map [remap notmuch-mua-new-mail] (notmuch-tree-close-message-pane-and #'notmuch-mua-new-mail)) + ;; Override because we want to close message pane first. + (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) ;; these use notmuch-show functions directly (define-key map "|" 'notmuch-show-pipe-message) @@ -402,6 +408,12 @@ Does NOT change the database." (notmuch-tree-close-message-window) (notmuch-tree query))) +(defun notmuch-search-from-tree-current-query () + "Call notmuch search with the current query" + (interactive) + (notmuch-tree-close-message-window) + (notmuch-search (notmuch-tree-get-query))) + (defun notmuch-tree-message-window-kill-hook () "Close the message pane when exiting the show buffer." (let ((buffer (current-buffer))) @@ -413,6 +425,13 @@ Does NOT change the database." (ignore-errors (delete-window notmuch-tree-message-window))))) +(defun notmuch-tree-command-hook () + (when (eq major-mode 'notmuch-tree-mode) + ;; We just run the notmuch-show-command-hook on the message pane. + (when (buffer-live-p notmuch-tree-message-buffer) + (with-current-buffer notmuch-tree-message-buffer + (notmuch-show-command-hook))))) + (defun notmuch-tree-show-message-in () "Show the current message (in split-pane)." (interactive) @@ -786,7 +805,7 @@ This function inserts a collection of several complete threads as passed to it by notmuch-tree-process-filter." (mapc 'notmuch-tree-insert-forest-thread forest)) -(defun notmuch-tree-mode () +(define-derived-mode notmuch-tree-mode fundamental-mode "notmuch-tree" "Major mode displaying messages (as opposed to threads) of of a notmuch search. This buffer contains the results of a \"notmuch tree\" of your @@ -800,12 +819,7 @@ Complete list of currently available key bindings: \\{notmuch-tree-mode-map}" - (interactive) - (kill-all-local-variables) (setq notmuch-buffer-refresh-function #'notmuch-tree-refresh-view) - (use-local-map notmuch-tree-mode-map) - (setq major-mode 'notmuch-tree-mode - mode-name "notmuch-tree") (hl-line-mode 1) (setq buffer-read-only t truncate-lines t)) @@ -855,10 +869,16 @@ This is is a helper function for notmuch-tree. The arguments are the same as for the function notmuch-tree." (interactive) (notmuch-tree-mode) + (add-hook 'post-command-hook #'notmuch-tree-command-hook t t) (setq notmuch-tree-basic-query basic-query) (setq notmuch-tree-query-context query-context) (setq notmuch-tree-target-msg target) (setq notmuch-tree-open-target open-target) + ;; Set the default value for `notmuch-show-process-crypto' in this + ;; buffer. Although we don't use this some of the functions we call + ;; (such as reply) do. It is a buffer local variable so setting it + ;; will not affect genuine show buffers. + (setq notmuch-show-process-crypto notmuch-crypto-process-mime) (erase-buffer) (goto-char (point-min)) @@ -924,3 +944,5 @@ The arguments are: ;; (provide 'notmuch-tree) + +;;; notmuch-tree.el ends here