unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v1 0/2] `notmuch-mua-send-hook' was ignored
@ 2018-09-25 15:09 David Edmondson
  2018-09-25 15:09 ` [PATCH v1 1/2] test: Check that `notmuch-mua-send-hook' is called on sending a message David Edmondson
  2018-09-25 15:09 ` [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when " David Edmondson
  0 siblings, 2 replies; 8+ messages in thread
From: David Edmondson @ 2018-09-25 15:09 UTC (permalink / raw)
  To: notmuch


`notmuch-mua-send-hook' was ignored

Whilst looking at the attachment warning patches
(id:20180908214041.19959-1-dme@dme.org), 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

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

* [PATCH v1 1/2] test: Check that `notmuch-mua-send-hook' is called on sending a message
  2018-09-25 15:09 [PATCH v1 0/2] `notmuch-mua-send-hook' was ignored David Edmondson
@ 2018-09-25 15:09 ` David Edmondson
  2018-09-27  1:29   ` David Bremner
  2018-09-25 15:09 ` [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when " David Edmondson
  1 sibling, 1 reply; 8+ messages in thread
From: David Edmondson @ 2018-09-25 15:09 UTC (permalink / raw)
  To: notmuch

---
 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: user@example.com\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 <test_suite@notmuchmail.org>
+To: user@example.com
+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

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

* [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when sending a message
  2018-09-25 15:09 [PATCH v1 0/2] `notmuch-mua-send-hook' was ignored David Edmondson
  2018-09-25 15:09 ` [PATCH v1 1/2] test: Check that `notmuch-mua-send-hook' is called on sending a message David Edmondson
@ 2018-09-25 15:09 ` David Edmondson
  2018-09-27  1:39   ` David Bremner
  1 sibling, 1 reply; 8+ messages in thread
From: David Edmondson @ 2018-09-25 15:09 UTC (permalink / raw)
  To: notmuch

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

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

* Re: [PATCH v1 1/2] test: Check that `notmuch-mua-send-hook' is called on sending a message
  2018-09-25 15:09 ` [PATCH v1 1/2] test: Check that `notmuch-mua-send-hook' is called on sending a message David Edmondson
@ 2018-09-27  1:29   ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2018-09-27  1:29 UTC (permalink / raw)
  To: David Edmondson, notmuch

David Edmondson <dme@dme.org> 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.

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

* Re: [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when sending a message
  2018-09-25 15:09 ` [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when " David Edmondson
@ 2018-09-27  1:39   ` David Bremner
  2018-09-29  0:12     ` David Bremner
  0 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2018-09-27  1:39 UTC (permalink / raw)
  To: David Edmondson, notmuch

$David Edmondson <dme@dme.org> 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

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

* Re: [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when sending a message
  2018-09-27  1:39   ` David Bremner
@ 2018-09-29  0:12     ` David Bremner
  2018-09-30  1:06       ` David Bremner
  2018-10-01  9:56       ` David Edmondson
  0 siblings, 2 replies; 8+ messages in thread
From: David Bremner @ 2018-09-29  0:12 UTC (permalink / raw)
  To: David Edmondson, notmuch

David Bremner <david@tethera.net> 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

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

* Re: [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when sending a message
  2018-09-29  0:12     ` David Bremner
@ 2018-09-30  1:06       ` David Bremner
  2018-10-01  9:56       ` David Edmondson
  1 sibling, 0 replies; 8+ messages in thread
From: David Bremner @ 2018-09-30  1:06 UTC (permalink / raw)
  To: David Edmondson, notmuch

David Bremner <david@tethera.net> writes:

> David Bremner <david@tethera.net> 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

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

* Re: [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when sending a message
  2018-09-29  0:12     ` David Bremner
  2018-09-30  1:06       ` David Bremner
@ 2018-10-01  9:56       ` David Edmondson
  1 sibling, 0 replies; 8+ messages in thread
From: David Edmondson @ 2018-10-01  9:56 UTC (permalink / raw)
  To: David Bremner, notmuch

On Friday, 2018-09-28 at 21:12:53 -03, David Bremner wrote:

> David Bremner <david@tethera.net> 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.

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

end of thread, other threads:[~2018-10-01  9:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-25 15:09 [PATCH v1 0/2] `notmuch-mua-send-hook' was ignored David Edmondson
2018-09-25 15:09 ` [PATCH v1 1/2] test: Check that `notmuch-mua-send-hook' is called on sending a message David Edmondson
2018-09-27  1:29   ` David Bremner
2018-09-25 15:09 ` [PATCH v1 2/2] emacs: Call `notmuch-mua-send-hook' hooks when " David Edmondson
2018-09-27  1:39   ` David Bremner
2018-09-29  0:12     ` David Bremner
2018-09-30  1:06       ` David Bremner
2018-10-01  9:56       ` David Edmondson

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).