]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-tree.el
Use https instead of http where possible
[notmuch] / emacs / notmuch-tree.el
index e859cc244f8f46f501b750746416ec65f64be4f1..52313199c50f039192b81500c37236d795afb9c8 100644 (file)
@@ -1,4 +1,4 @@
-;; notmuch-tree.el --- displaying notmuch forests.
+;;; notmuch-tree.el --- displaying notmuch forests.
 ;;
 ;; Copyright © Carl Worth
 ;; Copyright © David Edmondson
 ;; General Public License for more details.
 ;;
 ;; You should have received a copy of the GNU General Public License
-;; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.
+;; along with Notmuch.  If not, see <https://www.gnu.org/licenses/>.
 ;;
 ;; Authors: David Edmondson <dme@dme.org>
 ;;          Mark Walters <markwalters1009@gmail.com>
 
+;;; Code:
+
 (require 'mail-parse)
 
 (require 'notmuch-lib)
@@ -234,12 +236,14 @@ FUNC."
     ;; Override because we want to close message pane first.
     (define-key map [remap notmuch-help] (notmuch-tree-close-message-pane-and #'notmuch-help))
     ;; Override because we first close message pane and then close tree buffer.
-    (define-key map [remap notmuch-kill-this-buffer] 'notmuch-tree-quit)
+    (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit)
     ;; Override because we close message pane after the search query is entered.
     (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))
 
+    (define-key map "S" 'notmuch-search-from-tree-current-query)
+
     ;; these use notmuch-show functions directly
     (define-key map "|" 'notmuch-show-pipe-message)
     (define-key map "w" 'notmuch-show-save-attachments)
@@ -402,6 +406,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 +423,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)
@@ -855,10 +872,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 +947,5 @@ The arguments are:
 ;;
 
 (provide 'notmuch-tree)
+
+;;; notmuch-tree.el ends here