[PATCH v1 0/2] `notmuch-mua-send-hook' was ignored

classic Classic list List threaded Threaded
8 messages Options
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|

[PATCH v1 0/2] `notmuch-mua-send-hook' was ignored


`notmuch-mua-send-hook' was ignored

Whilst looking at the attachment warning patches
(id:[hidden email]), bremner pointed out in
#notmuch that anything attached to `notmuch-mua-send-hook' was not
getting run. It seems that this has always been broken. Add a test and
a fix.


David Edmondson (2):
  test: Check that `notmuch-mua-send-hook' is called on sending a
    message
  emacs: Call `notmuch-mua-send-hook' hooks when sending a message

 emacs/notmuch-mua.el |  1 +
 test/T310-emacs.sh   | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

--
2.19.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|

[PATCH v1 1/2] test: Check that `notmuch-mua-send-hook' is called on sending a message

---
 test/T310-emacs.sh | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index 9bf68b48..d743abb7 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -1106,4 +1106,30 @@ output=$(test_emacs "(mapcar 'notmuch-escape-boolean-term (list
  \"\\x201cxyz\\x201d\"))")
 test_expect_equal "$output" '("\"\"" "abc`~!@#$%^&*-=_+123" "\"(abc\"" "\")abc\"" "\"\"\"abc\"" "\"'$'\x01''xyz\"" "\"“xyz”\"")'
 
+test_begin_subtest "Sending a message calls the send message hooks"
+test_subtest_known_broken
+emacs_deliver_message \
+    'Testing message sending hooks' \
+    'This is a test of the message sending hooks.' \
+    "(message-goto-to)
+     (kill-whole-line)
+     (insert \"To: [hidden email]\n\")
+     (add-hook 'notmuch-mua-send-hook (lambda () (goto-char (point-max)) (insert \"\nThis text added by the hook.\")))"
+sed \
+    -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' \
+    -e s',^\(Content-Type: text/plain\); charset=us-ascii$,\1,' < sent_message >OUTPUT
+cat <<EOF >EXPECTED
+From: Notmuch Test Suite <[hidden email]>
+To: [hidden email]
+Subject: Testing message sending hooks
+Date: 01 Jan 2000 12:00:00 -0000
+Message-ID: <XXX>
+MIME-Version: 1.0
+Content-Type: text/plain
+
+This is a test of the message sending hooks.
+This text added by the hook.
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
--
2.19.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|

[PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when sending a message

In reply to this post by David Edmondson
Previously any hook functions attached to `notmuch-mua-send-hook' were
ignored.
---
 emacs/notmuch-mua.el | 1 +
 test/T310-emacs.sh   | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index fc8ac687..df2ac447 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -543,6 +543,7 @@ unencrypted.  Really send? "))))
 
 (defun notmuch-mua-send-common (arg &optional exit)
   (interactive "P")
+  (run-hooks 'notmuch-mua-send-hook)
   (when (and (notmuch-mua-check-no-misplaced-secure-tag)
      (notmuch-mua-check-secure-tag-has-newline))
     (letf (((symbol-function 'message-do-fcc) #'notmuch-maildir-message-do-fcc))
diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index d743abb7..5935819f 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -1107,7 +1107,6 @@ output=$(test_emacs "(mapcar 'notmuch-escape-boolean-term (list
 test_expect_equal "$output" '("\"\"" "abc`~!@#$%^&*-=_+123" "\"(abc\"" "\")abc\"" "\"\"\"abc\"" "\"'$'\x01''xyz\"" "\"“xyz”\"")'
 
 test_begin_subtest "Sending a message calls the send message hooks"
-test_subtest_known_broken
 emacs_deliver_message \
     'Testing message sending hooks' \
     'This is a test of the message sending hooks.' \
--
2.19.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v1 1/2] test: Check that `notmuch-mua-send-hook' is called on sending a message

In reply to this post by David Edmondson
David Edmondson <[hidden email]> writes:

> ---
>  test/T310-emacs.sh | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)

I get kind of odd output from this failing test

 PASS   Term escaping
 BROKEN Sending a message calls the send message hooks
        --- T310-emacs.70.EXPECTED 2018-09-27 01:26:24.838961735 +0000
        +++ T310-emacs.70.OUTPUT 2018-09-27 01:26:24.838961735 +0000
        @@ -7,4 +7,3 @@
         Content-Type: text/plain
         
         This is a test of the message sending hooks.
        -This text added by the hook.
t
./test-lib.sh: line 338: kill: (11196) - No such process

I guess that's not really a problem, it's just odd that I never noticed
that output in another test. Maybe it's only visible because the test is broken.
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when sending a message

In reply to this post by David Edmondson
$David Edmondson <[hidden email]> writes:

> Previously any hook functions attached to `notmuch-mua-send-hook' were
> ignored.
> ---
>  emacs/notmuch-mua.el | 1 +
>  test/T310-emacs.sh   | 1 -
>  2 files changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index fc8ac687..df2ac447 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -543,6 +543,7 @@ unencrypted.  Really send? "))))
>  
>  (defun notmuch-mua-send-common (arg &optional exit)
>    (interactive "P")
> +  (run-hooks 'notmuch-mua-send-hook)
>    (when (and (notmuch-mua-check-no-misplaced-secure-tag)
>       (notmuch-mua-check-secure-tag-has-newline))
>      (letf (((symbol-function 'message-do-fcc) #'notmuch-maildir-message-do-fcc))
> diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
> index d743abb7..5935819f 100755
> --- a/test/T310-emacs.sh
> +++ b/test/T310-emacs.sh
> @@ -1107,7 +1107,6 @@ output=$(test_emacs "(mapcar 'notmuch-escape-boolean-term (list
>  test_expect_equal "$output" '("\"\"" "abc`~!@#$%^&*-=_+123" "\"(abc\"" "\")abc\"" "\"\"\"abc\"" "\"'$'\x01''xyz\"" "\"“xyz”\"")'
>  

This looks plausible to me, and of course the test passes. I did wonder
if this means that people actually using notmuch-user-agent would run
the hook twice now?

On a related topic, I'd like to stop globally setting mail-user-agent in
notmuch.el. Notmuch users are still welcome to customize it, but we
don't need this side effect for regular notmuch use.

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when sending a message

David Bremner <[hidden email]> writes:

>
> This looks plausible to me, and of course the test passes. I did wonder
> if this means that people actually using notmuch-user-agent would run
> the hook twice now?

After a certain amount of re-reading the docstring of
define-mail-user-agent, and the source for compose-mail, I see that the
HOOKVAR parameter is something that users of the mail-agent can tweak,
rather than something that e.g. compose-mail promises to run. So I think
your patch is fine. And I'm 99% sure the issue with the spurious output
is just a little bug in test-lib.sh

d


_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when sending a message

David Bremner <[hidden email]> writes:

> David Bremner <[hidden email]> writes:
>
>>
>> This looks plausible to me, and of course the test passes. I did wonder
>> if this means that people actually using notmuch-user-agent would run
>> the hook twice now?
>
> After a certain amount of re-reading the docstring of
> define-mail-user-agent, and the source for compose-mail, I see that the
> HOOKVAR parameter is something that users of the mail-agent can tweak,
> rather than something that e.g. compose-mail promises to run. So I think
> your patch is fine. And I'm 99% sure the issue with the spurious output
> is just a little bug in test-lib.sh

pushed to master

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when sending a message

In reply to this post by David Bremner-2
On Friday, 2018-09-28 at 21:12:53 -03, David Bremner wrote:

> David Bremner <[hidden email]> writes:
>
>>
>> This looks plausible to me, and of course the test passes. I did wonder
>> if this means that people actually using notmuch-user-agent would run
>> the hook twice now?
>
> After a certain amount of re-reading the docstring of
> define-mail-user-agent, and the source for compose-mail, I see that the
> HOOKVAR parameter is something that users of the mail-agent can tweak,
> rather than something that e.g. compose-mail promises to run.

Yes, I came to the same conclusion (this time!).

dme.
--
I had my eyes closed in the dark.
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch