I have a pipeline that opens an emacs client in notmuch-mode
when new mail comes in, currently using (notmuch-show "thread:...")
.
I'd rather use tree view with the most recent message displayed. In two steps this is easy.
- run
notmuch-thread-view
(automatic) - then manually run
notmuch-thread-view-in-tree
.
I'd like for it to be automatic, but I cannot seem to combine the functions. I imagine notmuch-thread-view-in-tree
runs before notmuch-thread-view
has filled the buffer. So I think a hook is necessary. But how?
(defun notmuch-thread-view ()
(interactive)
(notmuch-tree "thread:0000000000000384")
;(notmuch-thread-view-in-tree) ; doesn't work
)
(defun notmuch-thread-view-in-tree ()
"Open the most recent message in a thread when in tree view.
will not work for nested threads."
(interactive)
(goto-char (point-max))
(notmuch-tree-prev-message)
(notmuch-tree-prev-message)
(notmuch-tree-show-message-in)
)
; not run?
(add-hook 'notmuch-thread-view 'notmuch-thread-view-in-tree)
; also not helpful
(add-hook 'post-notmuch-thread-view 'notmuch-thread-view-in-tree)
advice
using:after
, but since I don't usenotmuch
, I cannot test anything. See: emacswiki.org/emacs/AdvisingFunctions . There may be no need for a hook per se, unless you plan on adding/removing stuff frequently -- i.e., just run your function:after
using theadvice
. If you are running a sub-process and want to execute something when the process ends, then it may be necessary to examine the process filters and/or sentinels to decide where to plug in your custom modification.