emacs: new notmuch-tree-process-exit-functions

Hook run when the tree insertion process finishes its job.

--
This patch supersedes <id:20220816214023.1523322-1-jao@gnu.org>, but
changing the new variable name.

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>
This commit is contained in:
jao 2022-08-21 04:06:18 +01:00 committed by David Bremner
parent 76c3147613
commit 684eeb65c7

View file

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