Subject: Re: bug#14166: 24.3.50; report-emacs-bug and mail-user-agent == 'gnus-user-agent

From: Katsumi Yamaoka <[email-masked]>
Date: Thu, 11 Apr 2013 09:41:38 +0900

Michael Heerdegen wrote:
> Katsumi Yamaoka <[email-masked]> writes:

>> There seem to be several solutions, however ideas I have are not
>> so good.  For example:
>>
>> 1. To make `report-emacs-bug' bind `gnus-posting-styles' to nil
>>    unconditionally while performing `compose-mail'.  It has to load
>>    gnus-msg.el, that provides `gnus-posting-styles', before binding
>>    it to nil if Gnus is not running yet even if `mail-user-agent'
>>    is not `gnus-user-agent'.  Otherwise, `gnus-posting-styles' will
>>    be made unbound.  Note that a function `gnus-user-agent' uses,
>>    that is `gnus-msg-mail', is autoloaded, and it involves many other
>>    Gnus modules loading.
>>
>> 2. Similar to 1.  But load gnus-msg.el and bind `gnus-posting-styles'
>>    to nil if and only if `mail-user-agent' equals `gnus-user-agent'.
>>    I think the source code for it will get ugly.
>>
>> 3. To make `gnus-msg-mail' bind `gnus-posting-styles' to nil if and
>>    only if `this-command' is `report-emacs-bug'.  It won't work if
>>    `report-emacs-bug' is called non-interactively.
>>
>> My second best is 2.  What do others think?

> Just want to mention `gnus-inhibit-posting-styles'.  Maybe binding it isThat
> more comfortable?  Dunno, just an idea.

That will cause a problem similar to the one I mentioned in 1.
If Gnus is neither running nor loaded when performing
`report-emacs-bug', gnus-msg.el will be autoloaded under the condition
where `gnus-inhibit-posting-styles' is let-bound (to non-nil), and
`gnus-inhibit-posting-styles' will get void afterward.

Besides this, I came to realize that a user may want to use
`gnus-posting-styles' so as to add something like `Bcc: me', as
you do.  So, either way is not so good.

Oh, I hit on a good idea!  That's somewhat kludgy but works.
A quick hack is below.  It binds the newsgroup name to
"report-emacs-bug" temporarily while performing `report-emacs-bug'.
So, if you want to add `Bcc: me' to a bug report, you can use
this element in `gnus-posting-styles':

	("report-emacs-bug"
	 (Bcc "[email-masked]"))

WDYT?

--- emacsbug.el~	2013-02-11 22:45:54.714731000 +0000
+++ emacsbug.el	2013-04-11 00:37:32.109258200 +0000
@@ -162,7 +162,12 @@
     (setq message-end-point
 	  (with-current-buffer (get-buffer-create "*Messages*")
 	    (point-max-marker)))
-    (compose-mail report-emacs-bug-address topic)
+    (if (eq mail-user-agent 'gnus-user-agent)
+	(progn
+	  (require 'gnus) ;; It defines `gnus-newsgroup-name'.
+	  (let ((gnus-newsgroup-name "report-emacs-bug"))
+	    (compose-mail report-emacs-bug-address topic)))
+      (compose-mail report-emacs-bug-address topic))
     ;; The rest of this does not execute if the user was asked to
     ;; confirm and said no.
     (when (eq major-mode 'message-mode)