unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v5] Add hook inside notmuch-mua-reply
@ 2023-12-12 12:53 Sandra Snan
  2023-12-13  0:19 ` Sandra Snan
  2023-12-19 15:01 ` David Bremner
  0 siblings, 2 replies; 4+ messages in thread
From: Sandra Snan @ 2023-12-12 12:53 UTC (permalink / raw)
  To: notmuch; +Cc: Sandra Snan

This hook is run after `notmuch reply` has been successfully called
with the headers from the original message.
---
Paredit kills me. I accidentally included the following "defcustom"
sexp, someone pointed out the weird indentation, I only unintended it,
sent a patch, and someone else pointed out the way I had included a
sexp too far. What a week.

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

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index e4b7e9d1..47390cd4 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 notmuch-mua-reply-functions nil
+  "Functions to run after `notmuch-reply' was called successfully
+without erroring. The functions get the original message as a
+sexp.")
+
 ;;; 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
+      (run-hook-with-args 'notmuch-mua-reply-functions original)
       ;; If sender is non-nil, set the From: header to its value.
       (when sender
 	(plist-put reply-headers :From sender))
-- 
2.39.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v5] Add hook inside notmuch-mua-reply
  2023-12-12 12:53 [PATCH v5] Add hook inside notmuch-mua-reply Sandra Snan
@ 2023-12-13  0:19 ` Sandra Snan
  2023-12-19 15:01 ` David Bremner
  1 sibling, 0 replies; 4+ messages in thread
From: Sandra Snan @ 2023-12-13  0:19 UTC (permalink / raw)
  To: notmuch

https://lists.sr.ht/~pkal/public-inbox/patches/47695 <- This is what the
hook was for.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v5] Add hook inside notmuch-mua-reply
  2023-12-12 12:53 [PATCH v5] Add hook inside notmuch-mua-reply Sandra Snan
  2023-12-13  0:19 ` Sandra Snan
@ 2023-12-19 15:01 ` David Bremner
  1 sibling, 0 replies; 4+ messages in thread
From: David Bremner @ 2023-12-19 15:01 UTC (permalink / raw)
  To: Sandra Snan, notmuch

Sandra Snan <sandra.snan@idiomdrottning.org> writes:

> This hook is run after `notmuch reply` has been successfully called
> with the headers from the original message.


It seems like the commit message should be updated to match the changes
in the patch. With my "editor" hat on, it's also a bit ambigous what
"with the headers from the original message" applies to; it could be
read as `notmuch reply`

It would be nice to mention the motivation for the change (e.g. to
enable autocrypt). Our usual mantra (not _always_ followed, but we try),
is to say something about the "why" as well as the "what".

Thanks for your efforts,

David

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v5] Add hook inside notmuch-mua-reply
@ 2023-12-19 15:28 Sandra Snan
  0 siblings, 0 replies; 4+ messages in thread
From: Sandra Snan @ 2023-12-19 15:28 UTC (permalink / raw)
  To: notmuch; +Cc: Sandra Snan

This hook is run after `notmuch reply` has been successfully called.
The functions are called with the same sexp that `notmuch reply`
returned.

One of the uses for this hook is to make a Notmuch plugin for
Autocrypt.
---
 emacs/notmuch-mua.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index e4b7e9d1..47390cd4 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 notmuch-mua-reply-functions nil
+  "Functions to run after `notmuch-reply' was called successfully
+without erroring. The functions get the original message as a
+sexp.")
+
 ;;; 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
+      (run-hook-with-args 'notmuch-mua-reply-functions original)
       ;; If sender is non-nil, set the From: header to its value.
       (when sender
 	(plist-put reply-headers :From sender))
-- 
2.39.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-19 15:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-12 12:53 [PATCH v5] Add hook inside notmuch-mua-reply Sandra Snan
2023-12-13  0:19 ` Sandra Snan
2023-12-19 15:01 ` David Bremner
  -- strict thread matches above, loose matches on Subject: below --
2023-12-19 15:28 Sandra Snan

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).