[PATCH] Add hook inside notmuch-mua-reply

Subject: [PATCH] Add hook inside notmuch-mua-reply

Date: Sun, 10 Dec 2023 23:40:24 +0100

To: notmuch@notmuchmail.org

Cc: Sandra Snan

From: Sandra Snan


This hook is run after `notmuch reply` has been successfully called
with the headers from the original message.
---
Can we please get a hook inside notmuch-mua-reply in the Emacs
frontend to notmuch? But not a hook for thunks but a hook that has
access to the message-id for the message we are replying to.

A little bit of `run-hook-with-args`.♥

I know that I can solve the problem with add-advice and I'm gonna do
that for now, but a hook here would save one call to the notmuch
binary when the user hits `r` on a thread with multiple mails.

What I am trying to implement specifically is a plugin for Emacs
autocrypt package. It needs headers from the message you're replying
to, headers beyond what notmuch-reply returns in its sexp.

 emacs/notmuch-mua.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index e4b7e9d1..c40e60af 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -44,6 +44,11 @@
 (defvar notmuch-show-max-text-part-size)
 (defvar notmuch-show-insert-text/plain-hook)
 
+(defvar in-notmuch-mua-reply-functions nil
+  "Functions to run after `notmuch-reply' was called successfully
+without erroring. The functions get the message-id as a string
+argument.")
+
 ;;; Options
 
 (defcustom notmuch-mua-send-hook nil
@@ -256,6 +261,8 @@ Typically this is added to `notmuch-mua-send-hook'."
     ;; Extract the headers of both the reply and the original message.
     (let* ((original-headers (plist-get original :headers))
 	   (reply-headers (plist-get reply :reply-headers)))
+      ;; Run hook here with the original message-id
+      (run-hook-with-args 'in-notmuch-mua-reply-functions (plist-get original :id))
       ;; If sender is non-nil, set the From: header to its value.
       (when sender
 	(plist-put reply-headers :From sender))
-- 
2.39.2

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

Thread: