From 446a95fb3dcc591412337ff5b15d067e6d3feb59 Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 16 Aug 2021 21:04:57 +0100 Subject: notmuch: outline mode to toggle threads --- lib/net/jao-notmuch.el | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'lib/net') diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el index 48ba775..cedd2cf 100644 --- a/lib/net/jao-notmuch.el +++ b/lib/net/jao-notmuch.el @@ -25,6 +25,7 @@ ;;; Code: (require 'eww) +(require 'outline) (require 'notmuch) (require 'notmuch-tree) @@ -166,6 +167,25 @@ (funcall fn (completing-read "Browse URL: " urls)) (message "No URLs in this message"))))) + +;; Outline mode for tree view + +(defun jao-notmuch--setup-outline () + (setq-local outline-regexp ".+ [┬─] ") + (outline-minor-mode 1)) + +(add-hook 'notmuch-tree-mode-hook #'jao-notmuch--setup-outline) + +(defun jao-notmuch--tree-toggle (&rest _args) + (when outline-minor-mode + (outline-toggle-children))) + +(advice-add 'notmuch-tree-matching-message :before #'jao-notmuch--tree-toggle) +(advice-add 'notmuch-tree-matching-message :after #'jao-notmuch--tree-toggle) + +(define-key notmuch-tree-mode-map (kbd "T TAB") 'outline-cycle) +(define-key notmuch-tree-mode-map (kbd "T t") 'outline-cycle) + ;; Toggling mime parts and images @@ -263,7 +283,10 @@ (let ((buffer (process-buffer proc)) (status (process-status proc))) (when (and (eq status 'exit) (buffer-live-p buffer)) - (with-current-buffer buffer (jao-notmuch--tree-update-buffer-name))))) + (with-current-buffer buffer + (jao-notmuch--tree-update-buffer-name) + (outline-hide-body) + (outline-toggle-children))))) (advice-add 'notmuch-tree-process-sentinel :after #'jao-notmuch--tree-sentinel) -- cgit v1.2.3