[PATCH] emacs: new notmuch-tree-process-hook

Subject: [PATCH] emacs: new notmuch-tree-process-hook

Date: Tue, 16 Aug 2022 22:40:23 +0100

To: notmuch@notmuchmail.org

Cc: jao

From: jao


Hook run when the tree insertion process finishes its job.

--

Right now, it can be used for silly things like removing or changing
the the "End of search." hardcoded message in the tree buffer.  But
also for more sophisticated things like folding all threads in add-ons
like my outline mode for tree buffers (to be submitted).

Signed-off-by: jao <jao@gnu.org>
---
 emacs/notmuch-tree.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index f63ac9a5..265f7c1f 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1084,6 +1084,12 @@ Complete list of currently available key bindings:
   (setq buffer-read-only t)
   (setq truncate-lines t))
 
+(defvar notmuch-tree-process-hook nil
+  "Hook executed when the process inserting a tree of results finishes.
+
+Functions in this hook are called with one argument, the process
+object, with the tree results buffer as the current buffer.")
+
 (defun notmuch-tree-process-sentinel (proc _msg)
   "Add a message to let user know when \"notmuch tree\" exits."
   (let ((buffer (process-buffer proc))
@@ -1102,7 +1108,8 @@ Complete list of currently available key bindings:
 		(insert "End of search results.")
 		(unless (= exit-status 0)
 		  (insert (format " (process returned %d)" exit-status)))
-		(insert "\n")))))))))
+		(insert "\n"))))
+	  (run-hook-with-args 'notmuch-tree-process-hook proc))))))
 
 (defun notmuch-tree-process-filter (proc string)
   "Process and filter the output of \"notmuch show\" for tree view."
-- 
2.37.2

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: