Subject: bug#41373: GNU ELPA: Add "reporting bugs" to individual package pages

From: Eric Abrahamsen <[email-masked]>
Date: Mon, 01 Jun 2020 11:29:14 -0700

On 06/01/20 08:32 AM, Bastien wrote:
> Hi Eric,
>
> Eric Abrahamsen <[email-masked]> writes:
>
>> I think in the original discussion the patch went back and forth between
>> completing on `package-alist' and completing on `features'. The former
>> didn't offer enough, the latter offered too much.
>
> While not offering "enough", the former is already an improvement, I'd
> be in favor of implementing it.  The latter really offers too much IMO.

Yes, I've come to the same conclusion over time.

>> If we complete on `features', that's definitely an issue. I think my
>> solution in that version of the patch simply dropped the issue if the
>> Maintainer header was emacs-devel, or there was no Maintainer.
>
> Yes, it looks fine to me like this.
>
>> My pleasure -- as Dmitry notes, this might not solve the problem that
>> this thread is about, but I think it's definitely worthwhile on its own.
>
> Definitely.  What is still needed here so that you can make this change?

Here's a new version of the patch. It:

1. doesn't require a package
2. only honors the Maintainer header (not the Author header, if there's no
   Maintainer)
3. screens out "[email-masked]" as a Maintainer value (we
   could easily add more values to screen out)
4. uses X-Debbugs-CC instead of Cc
5. Adds a "Package:" pseudo-header

Remaining questions:

1. I've seen some reference to a X-Debbugs-Package header, is that
   honored?
2. Glenn mentioned the fact that some package maintainers might not want
   anything to do with debbugs. I'm not sure how to handle that
   situation, except manually. I suppose, if we do end up adding a
   package maintainer, we could also add a line of text in the
   intangible instructions saying, "If you don't want to deal with this
   bug on the Emacs bug tracker, please send a message to
   [email-masked] to close it."
3. Lastly, this is a fairly in-your-face change to how Emacs bugs are
   reported, and I'm not sure everyone agrees it's a good idea! Adding
   an extra prompt to the process is a bit intrusive.

Eric

>From ae806f23a8e8b784ed1c18a0783c563fa013f601 Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <[email-masked]>
Date: Thu, 21 Jul 2016 15:58:47 -0400
Subject: [PATCH] Cc package maintainers when reporting emacs bugs

* lisp/mail/emacsbug.el (report-emacs-bug): Prompt for a package to
  report a bug against, and cc the package maintainer, if any, on the
  bug report.
---
 lisp/mail/emacsbug.el | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index 7f3dc4454a..0a39cb682f 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -206,17 +206,30 @@ message-send-mail-function
 (defvar message-sendmail-envelope-from)
 
 ;;;###autoload
-(defun report-emacs-bug (topic &optional unused)
+(defun report-emacs-bug (topic package &optional unused)
   "Report a bug in GNU Emacs.
 Prompts for bug subject.  Leaves you in a mail buffer."
   (declare (advertised-calling-convention (topic) "24.5"))
-  (interactive "sBug Subject: ")
+  (interactive (list
+                (read-string "Bug Subject: ")
+                (completing-read
+                 "Package: "
+                 (progn
+                   (package-initialize)
+                   package-alist)
+                 nil nil)))
   ;; The syntax `version;' is preferred to `[version]' because the
   ;; latter could be mistakenly stripped by mailing software.
   (setq topic (concat emacs-version "; " topic))
   (let ((from-buffer (current-buffer))
 	(can-insert-mail (or (report-emacs-bug-can-use-xdg-email)
 			     (report-emacs-bug-can-use-osx-open)))
+        (cc (unless (or (string-empty-p package) (string= package "emacs"))
+              (require 'finder)
+              (lm-with-file (find-library-name package)
+                ;; Don't use `lm-maintainer', as that falls back on
+                ;; author.
+                (lm-header "maintainer"))))
         user-point message-end-point)
     (setq message-end-point
 	  (with-current-buffer (messages-buffer)
@@ -232,7 +245,7 @@ report-emacs-bug
     (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)
+    (when (derived-mode-p 'message-mode)
       ;; Message-mode sorts the headers before sending.  We sort now so
       ;; that report-emacs-bug-orig-text remains valid.  (Bug#5178)
       (message-sort-headers)
@@ -243,6 +256,15 @@ report-emacs-bug
       (when (and (not (message--sendmail-envelope-from))
 		 (message-bogus-recipient-p (message-make-address)))
 	(set (make-local-variable 'message-sendmail-envelope-from) 'header)))
+    (when (and cc
+               (setq cc (lm-crack-address cc))
+               (null (string= "[email-masked]" (cdr cc))))
+      (if (derived-mode-p 'message-mode)
+          (message-position-on-field "X-Debbugs-CC")
+        (mail-position-on-field "X-Debbugs-CC"))
+      (if (car cc)
+          (insert (format "%s <%s>" (car cc) (cdr cc)))
+        (insert (format "%s" (cdr cc)))))
     (rfc822-goto-eoh)
     (forward-line 1)
     ;; Move the mail signature to the proper place.
@@ -415,7 +437,9 @@ report-emacs-bug
     (make-local-variable 'report-emacs-bug-orig-text)
     (setq report-emacs-bug-orig-text
           (buffer-substring-no-properties (point-min) (point)))
-    (goto-char user-point)))
+    (goto-char user-point)
+    (unless (string-empty-p package)
+      (insert "Package: " package "\n\n"))))
 
 (define-obsolete-function-alias 'report-emacs-bug-info 'info-emacs-bug "24.3")
 
-- 
2.26.2