all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Mail mode and message mode hooks
@ 2009-12-01  2:18 Chong Yidong
  2009-12-01  3:40 ` Stefan Monnier
  2009-12-01 19:07 ` Chong Yidong
  0 siblings, 2 replies; 11+ messages in thread
From: Chong Yidong @ 2009-12-01  2:18 UTC (permalink / raw)
  To: emacs-devel

I'd like to hear some opinions on how to treat the mail mode and message
mode hooks, given that message-mode is to be the default.

As it stands, anyone using feedmail will likely suffer breakage in
upgrading to Emacs 23.2, as shown in bug#3942.  The feedmail package
relies on hooks, and contains documentation like this:

   feedmail-mail-send-hook-splitter is a Lisp function in `feedmail.el'.

   (feedmail-mail-send-hook-splitter)

   Facilitate dividing `mail-send-hook' things into queued and immediate
   cases.  If you have `mail-send-hook' functions that should only be
   called for sending/ queueing messages or only be called for the
   sending of queued messages, this is for you.  Add this function to
   `mail-send-hook' with something like this:

       (add-hook 'mail-send-hook 'feedmail-mail-send-hook-splitter)

So, the message-*-hook variables should probably be aliased to the
mail-*-hook variables.

One problem that I can see with this is that code intended for one mode
may not work properly for the other mode, but I can't think of any
concrete examples.  Any thoughts?




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

* Re: Mail mode and message mode hooks
  2009-12-01  2:18 Mail mode and message mode hooks Chong Yidong
@ 2009-12-01  3:40 ` Stefan Monnier
  2009-12-05  3:37   ` Chong Yidong
  2009-12-01 19:07 ` Chong Yidong
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2009-12-01  3:40 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

> So, the message-*-hook variables should probably be aliased to the
> mail-*-hook variables.

Yes.  Generally, message-mode should be considered as a derived-mode of
mail-mode, I think.  On this basis, it would make sense to run mail
mail-*-hook.

> One problem that I can see with this is that code intended for one mode
> may not work properly for the other mode, but I can't think of any
> concrete examples.  Any thoughts?

I have no idea what kind of code people may run from such hooks.

The main thing to remember: the old behavior is just one setq away.

And as a strong supporter of message-mode, I see nothing wrong with
people preferring mail-mode for themselves.  Heck, I've been living with
exactly such a setq in my .emacs for many years now because I preferred
message-mode over the default mail-mode.

So there is really no need to work that hard at making message-mode work
like mail-mode.  Such a thing would only be needed if we were to drop
mail-mode in favor of message-mode, whereas we're just changing
the default.
Changing defaults is not that big a deal.  We've been doing it for
decades.  Every time some people bitch, of course, but as long as it is
an improvement for the average user, the transient inconvenience is
nothing to worry about.


        Stefan




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

* Re: Mail mode and message mode hooks
  2009-12-01  2:18 Mail mode and message mode hooks Chong Yidong
  2009-12-01  3:40 ` Stefan Monnier
@ 2009-12-01 19:07 ` Chong Yidong
  2009-12-01 20:41   ` Davis Herring
  1 sibling, 1 reply; 11+ messages in thread
From: Chong Yidong @ 2009-12-01 19:07 UTC (permalink / raw)
  To: emacs-devel

Chong Yidong <cyd@stupidchicken.com> writes:

> So, the message-*-hook variables should probably be aliased to the
> mail-*-hook variables.

On further thought, there is a problem with this.  If we defvaralias
(e.g.) message-send-hook in message.el, any (add-hook message-send-hook foo)
statement in a user's .emacs file will be overwritten when message.el is
loaded.

One solution is to make message-mode run the mail-*-hooks explicitly,
but this may conflict with user customizations that set up both hooks

  (add-hook 'message-send-hook 'foo)
  (add-hook 'mail-send-hook 'foo)

which is not outside the realm of probability.  In this case, running
both hooks is clearly not what we want.




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

* Re: Mail mode and message mode hooks
  2009-12-01 19:07 ` Chong Yidong
@ 2009-12-01 20:41   ` Davis Herring
  0 siblings, 0 replies; 11+ messages in thread
From: Davis Herring @ 2009-12-01 20:41 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

> On further thought, there is a problem with this.  If we defvaralias
> (e.g.) message-send-hook in message.el, any (add-hook message-send-hook
> foo) statement in a user's .emacs file will be overwritten when message.el
> is loaded.

Why not, just before doing the defvaralias, merge any value the hook has
into the hook it is about to alias?

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.




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

* Re: Mail mode and message mode hooks
  2009-12-01  3:40 ` Stefan Monnier
@ 2009-12-05  3:37   ` Chong Yidong
  2009-12-05  4:55     ` Stefan Monnier
                       ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Chong Yidong @ 2009-12-05  3:37 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> One problem that I can see with this is that code intended for one mode
>> may not work properly for the other mode, but I can't think of any
>> concrete examples.  Any thoughts?
>
> I have no idea what kind of code people may run from such hooks.
>
> The main thing to remember: the old behavior is just one setq away.
>
> And as a strong supporter of message-mode, I see nothing wrong with
> people preferring mail-mode for themselves.  Heck, I've been living with
> exactly such a setq in my .emacs for many years now because I preferred
> message-mode over the default mail-mode.
>
> So there is really no need to work that hard at making message-mode work
> like mail-mode.

I am also a supporter of message-mode.  But a user moving from Emacs
23.1 to Emacs 23.2---a minor version upgrade!---should not experience
breakage.  And as the feedmail example shows, there is at least one
not-unreasonable setup that currently does break.




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

* Re: Mail mode and message mode hooks
  2009-12-05  3:37   ` Chong Yidong
@ 2009-12-05  4:55     ` Stefan Monnier
  2009-12-05  9:22     ` Eli Zaretskii
  2009-12-05 18:34     ` Davis Herring
  2 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2009-12-05  4:55 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

>>> One problem that I can see with this is that code intended for one mode
>>> may not work properly for the other mode, but I can't think of any
>>> concrete examples.  Any thoughts?
>> 
>> I have no idea what kind of code people may run from such hooks.
>> 
>> The main thing to remember: the old behavior is just one setq away.
>> 
>> And as a strong supporter of message-mode, I see nothing wrong with
>> people preferring mail-mode for themselves.  Heck, I've been living with
>> exactly such a setq in my .emacs for many years now because I preferred
>> message-mode over the default mail-mode.
>> 
>> So there is really no need to work that hard at making message-mode work
>> like mail-mode.

> I am also a supporter of message-mode.  But a user moving from Emacs
> 23.1 to Emacs 23.2---a minor version upgrade!---should not experience
> breakage.  And as the feedmail example shows, there is at least one
> not-unreasonable setup that currently does break.

I think this is a small price to pay compared to the overall benefit of
properly supporting arbitrary chars and coding-systems, and other
MIME features.
Maybe we should try and add some ad-hoc checks à la bad-package-check to
catch the few known problematic cases.


        Stefan




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

* Re: Mail mode and message mode hooks
  2009-12-05  3:37   ` Chong Yidong
  2009-12-05  4:55     ` Stefan Monnier
@ 2009-12-05  9:22     ` Eli Zaretskii
  2009-12-05 18:34     ` Davis Herring
  2 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2009-12-05  9:22 UTC (permalink / raw)
  To: Chong Yidong; +Cc: monnier, emacs-devel

> From: Chong Yidong <cyd@stupidchicken.com>
> Date: Fri, 04 Dec 2009 22:37:24 -0500
> Cc: emacs-devel@gnu.org
> 
> I am also a supporter of message-mode.  But a user moving from Emacs
> 23.1 to Emacs 23.2---a minor version upgrade!---should not experience
> breakage.  And as the feedmail example shows, there is at least one
> not-unreasonable setup that currently does break.

I cannot say I'm a supporter of message-mode, but I can say I don't
mind the change that makes it the default.  However, I agree with
Yidong that a minor version upgrade should not cause a known breakage.




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

* Re: Mail mode and message mode hooks
  2009-12-05  3:37   ` Chong Yidong
  2009-12-05  4:55     ` Stefan Monnier
  2009-12-05  9:22     ` Eli Zaretskii
@ 2009-12-05 18:34     ` Davis Herring
  2009-12-06 23:10       ` Chong Yidong
  2 siblings, 1 reply; 11+ messages in thread
From: Davis Herring @ 2009-12-05 18:34 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Stefan Monnier, emacs-devel

>> So there is really no need to work that hard at making message-mode work
>> like mail-mode.
>
> I am also a supporter of message-mode.  But a user moving from Emacs
> 23.1 to Emacs 23.2---a minor version upgrade!---should not experience
> breakage.  And as the feedmail example shows, there is at least one
> not-unreasonable setup that currently does break.

Does my suggestion not help here?  The merge of hook values could even
check for functions registered on each.  Even if the user loads both (so
the merge and defvaralias have already happened) and then tries to add the
same function to each, she will only get one copy.

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.




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

* Re: Mail mode and message mode hooks
  2009-12-05 18:34     ` Davis Herring
@ 2009-12-06 23:10       ` Chong Yidong
  2009-12-06 23:52         ` Chong Yidong
  0 siblings, 1 reply; 11+ messages in thread
From: Chong Yidong @ 2009-12-06 23:10 UTC (permalink / raw)
  To: herring; +Cc: Stefan Monnier, emacs-devel

"Davis Herring" <herring@lanl.gov> writes:

>> I am also a supporter of message-mode.  But a user moving from Emacs
>> 23.1 to Emacs 23.2---a minor version upgrade!---should not experience
>> breakage.  And as the feedmail example shows, there is at least one
>> not-unreasonable setup that currently does break.
>
> Does my suggestion not help here?  The merge of hook values could even
> check for functions registered on each.  Even if the user loads both (so
> the merge and defvaralias have already happened) and then tries to add the
> same function to each, she will only get one copy.

It's workable, but not very elegant.

Another idea I had is to change compose-mail to check for hook
duplication, and pop up a warning window telling the user that the
default mail-user-agent has changed.





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

* Re: Mail mode and message mode hooks
  2009-12-06 23:10       ` Chong Yidong
@ 2009-12-06 23:52         ` Chong Yidong
  2009-12-07  2:16           ` Stefan Monnier
  0 siblings, 1 reply; 11+ messages in thread
From: Chong Yidong @ 2009-12-06 23:52 UTC (permalink / raw)
  To: Stefan Monnier, emacs-devel

Chong Yidong <cyd@stupidchicken.com> writes:

> Another idea I had is to change compose-mail to check for hook
> duplication, and pop up a warning window telling the user that the
> default mail-user-agent has changed.

To flesh out this idea a bit more, here is a patch that implements it.
Opinions?

*** emacs/lisp/simple.el.~1.1035.~	2009-12-06 13:48:05.000000000 -0500
--- emacs/lisp/simple.el	2009-12-06 18:48:37.000000000 -0500
***************
*** 5558,5563 ****
--- 5558,5572 ----
    :version "23.2"                       ; sendmail->message
    :group 'mail)
  
+ (defcustom compose-mail-user-agent-warnings t
+   "If non-nil, `compose-mail' warns about changes in `mail-user-agent'.
+ If the value of `mail-user-agent' is the default, and the user
+ appears to have customizations applying to the old default,
+ `compose-mail' issues a warning."
+   :type 'boolean
+   :version "23.2"
+   :group 'mail)
+ 
  (define-mail-user-agent 'sendmail-user-agent
    'sendmail-user-agent-compose
    'mail-send-and-exit)
***************
*** 5627,5632 ****
--- 5636,5667 ----
  Each action has the form (FUNCTION . ARGS)."
    (interactive
     (list nil nil nil current-prefix-arg))
+ 
+   ;; In Emacs 23.2, the default value of `mail-user-agent' changed
+   ;; from sendmail-user-agent to message-user-agent.  Some users may
+   ;; encounter incompatibilities.  This hack tries to detect problems
+   ;; and warn about them.
+   (and compose-mail-user-agent-warnings
+        (eq mail-user-agent 'message-user-agent)
+        (let (warn-vars)
+ 	 (dolist (var '(mail-send-hook mail-setup-hook mail-yank-hooks
+ 		        mail-citation-hook mail-mode-hook
+ 			mail-default-reply-to mail-archive-file-name
+ 			mail-self-blind mail-mailing-lists))
+ 	   (and (boundp var)
+ 		(symbol-value var)
+ 		(push var warn-vars)))
+ 	 (when warn-vars
+ 	   (display-warning 'mail
+ 			    (format "\
+ The default mail mode is now Message mode.
+ You have the following Mail mode variable%s customized:
+ \n%s\n\nTo use Mail mode, set `mail-user-agent' to sendmail-user-agent.
+ To disable this warning, set `compose-mail-check-user-agent' to nil."
+ 				    (if (> (length warn-vars) 1) "s" "")
+ 				    (mapconcat 'symbol-name
+ 					       warn-vars " "))))))
+ 
    (let ((function (get mail-user-agent 'composefunc)))
      (funcall function to subject other-headers continue
  	     switch-function yank-action send-actions)))




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

* Re: Mail mode and message mode hooks
  2009-12-06 23:52         ` Chong Yidong
@ 2009-12-07  2:16           ` Stefan Monnier
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2009-12-07  2:16 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

>> Another idea I had is to change compose-mail to check for hook
>> duplication, and pop up a warning window telling the user that the
>> default mail-user-agent has changed.
> To flesh out this idea a bit more, here is a patch that implements it.
> Opinions?

Sounds good to me.  It's not ideal, but at least it will avoid
silent surprises.  And will make it obvious to people who might care,
how to revert to mail-mode.
It's clearly the best "fix" so far,


        Stefan




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

end of thread, other threads:[~2009-12-07  2:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-01  2:18 Mail mode and message mode hooks Chong Yidong
2009-12-01  3:40 ` Stefan Monnier
2009-12-05  3:37   ` Chong Yidong
2009-12-05  4:55     ` Stefan Monnier
2009-12-05  9:22     ` Eli Zaretskii
2009-12-05 18:34     ` Davis Herring
2009-12-06 23:10       ` Chong Yidong
2009-12-06 23:52         ` Chong Yidong
2009-12-07  2:16           ` Stefan Monnier
2009-12-01 19:07 ` Chong Yidong
2009-12-01 20:41   ` Davis Herring

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.