unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Remove notmuch-mua-message-send-hook
@ 2020-09-12  4:45 Tim Quelch
  2020-09-13  9:53 ` Tomi Ollila
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Quelch @ 2020-09-12  4:45 UTC (permalink / raw)
  To: notmuch; +Cc: Tim Quelch

Currently `message-send-hook` functions are being called twice: In
notmuch send common when `notmuch-mua-send-hook` functions are
run (which by default includes `notmuch-mua-message-send-hook`) and in
`message-send` itself.

Because `message-send-hook` functions are run in `message-send` itself,
we don't need also need to run them before we delegate to `message-send`

Calling `notmuch-mua-message-send-hook` resulted in functions in
`message-send-hook` to be called twice. This causes bugs in
non-idempotent hook functions.
---
 emacs/notmuch-mua.el | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index dcddca76..03c7cc97 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -40,7 +40,7 @@
 
 ;;
 
-(defcustom notmuch-mua-send-hook '(notmuch-mua-message-send-hook)
+(defcustom notmuch-mua-send-hook nil
   "Hook run before sending messages."
   :type 'hook
   :group 'notmuch-send
@@ -601,11 +601,6 @@ unencrypted.  Really send? "))))
   (interactive)
   (message-kill-buffer))
 
-(defun notmuch-mua-message-send-hook ()
-  "The default function used for `notmuch-mua-send-hook', this
-simply runs the corresponding `message-mode' hook functions."
-  (run-hooks 'message-send-hook))
-
 ;;
 
 (define-mail-user-agent 'notmuch-user-agent
-- 
2.28.0

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

* Re: [PATCH] emacs: Remove notmuch-mua-message-send-hook
  2020-09-12  4:45 [PATCH] emacs: Remove notmuch-mua-message-send-hook Tim Quelch
@ 2020-09-13  9:53 ` Tomi Ollila
  2020-09-13 23:56   ` Tim Quelch
  2020-09-19  9:56   ` David Bremner
  0 siblings, 2 replies; 4+ messages in thread
From: Tomi Ollila @ 2020-09-13  9:53 UTC (permalink / raw)
  To: Tim Quelch, notmuch; +Cc: Tim Quelch

On Sat, Sep 12 2020, Tim Quelch wrote:

> Currently `message-send-hook` functions are being called twice: In
> notmuch send common when `notmuch-mua-send-hook` functions are
> run (which by default includes `notmuch-mua-message-send-hook`) and in
> `message-send` itself.
>
> Because `message-send-hook` functions are run in `message-send` itself,
> we don't need also need to run them before we delegate to `message-send`
>
> Calling `notmuch-mua-message-send-hook` resulted in functions in
> `message-send-hook` to be called twice. This causes bugs in
> non-idempotent hook functions.

Looks good to me. everyone who rewrote notmuch-mua-message-send-hook
(i hope none) have to find better solution (or just...)

Hmm, this is defcustom. If that (old default) is stored in 
custom-set-variables have to remove it -- at least my  
custom-set-variables does not reference to this hook variable, so
most probably the effect (if any) is small...

Tomi

> ---
>  emacs/notmuch-mua.el | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index dcddca76..03c7cc97 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -40,7 +40,7 @@
>  
>  ;;
>  
> -(defcustom notmuch-mua-send-hook '(notmuch-mua-message-send-hook)
> +(defcustom notmuch-mua-send-hook nil
>    "Hook run before sending messages."
>    :type 'hook
>    :group 'notmuch-send
> @@ -601,11 +601,6 @@ unencrypted.  Really send? "))))
>    (interactive)
>    (message-kill-buffer))
>  
> -(defun notmuch-mua-message-send-hook ()
> -  "The default function used for `notmuch-mua-send-hook', this
> -simply runs the corresponding `message-mode' hook functions."
> -  (run-hooks 'message-send-hook))
> -
>  ;;
>  
>  (define-mail-user-agent 'notmuch-user-agent
> -- 
> 2.28.0
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org

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

* Re: [PATCH] emacs: Remove notmuch-mua-message-send-hook
  2020-09-13  9:53 ` Tomi Ollila
@ 2020-09-13 23:56   ` Tim Quelch
  2020-09-19  9:56   ` David Bremner
  1 sibling, 0 replies; 4+ messages in thread
From: Tim Quelch @ 2020-09-13 23:56 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

> Looks good to me. everyone who rewrote notmuch-mua-message-send-hook
> (i hope none) have to find better solution (or just...)

I think that would be an incredibly small minority of people who did
that. The obvious (and easiest) customisation point has been to add a
function to `notmuch-message-send-hook` or to `message-send-hook` rather
than actually relying on overwriting or advising
`notmuch-mua-message-send-hook`


> Hmm, this is defcustom. If that (old default) is stored in 
> custom-set-variables have to remove it -- at least my  
> custom-set-variables does not reference to this hook variable, so
> most probably the effect (if any) is small...

A safer route I guess would be to just change the default value of the
hook and mark the function as obsolete.


Tim Quelch

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

* Re: [PATCH] emacs: Remove notmuch-mua-message-send-hook
  2020-09-13  9:53 ` Tomi Ollila
  2020-09-13 23:56   ` Tim Quelch
@ 2020-09-19  9:56   ` David Bremner
  1 sibling, 0 replies; 4+ messages in thread
From: David Bremner @ 2020-09-19  9:56 UTC (permalink / raw)
  To: Tomi Ollila, Tim Quelch, notmuch; +Cc: Tim Quelch

Tomi Ollila <tomi.ollila@iki.fi> writes:

> On Sat, Sep 12 2020, Tim Quelch wrote:
>
>> Currently `message-send-hook` functions are being called twice: In
>> notmuch send common when `notmuch-mua-send-hook` functions are
>> run (which by default includes `notmuch-mua-message-send-hook`) and in
>> `message-send` itself.
>>
>> Because `message-send-hook` functions are run in `message-send` itself,
>> we don't need also need to run them before we delegate to `message-send`
>>
>> Calling `notmuch-mua-message-send-hook` resulted in functions in
>> `message-send-hook` to be called twice. This causes bugs in
>> non-idempotent hook functions.
>
> Looks good to me. everyone who rewrote notmuch-mua-message-send-hook
> (i hope none) have to find better solution (or just...)
>

applied to master

d

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

end of thread, other threads:[~2020-09-19  9:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-12  4:45 [PATCH] emacs: Remove notmuch-mua-message-send-hook Tim Quelch
2020-09-13  9:53 ` Tomi Ollila
2020-09-13 23:56   ` Tim Quelch
2020-09-19  9:56   ` David Bremner

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