unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33225: [debbugs.el] Don't send control message immediately
@ 2018-11-01 12:29 Noam Postavsky
  2018-11-01 14:28 ` Garreau, Alexandre
  2018-11-02 10:23 ` Michael Albinus
  0 siblings, 2 replies; 17+ messages in thread
From: Noam Postavsky @ 2018-11-01 12:29 UTC (permalink / raw)
  To: 33225; +Cc: michael albinus, garreau, alexandre

[-- Attachment #1: Type: text/plain, Size: 594 bytes --]

Tags: patch
Severity: wishlist
X-Debbugs-CC: "Garreau, Alexandre" <galex-713@galex-713.eu>, Michael Albinus <michael.albinus@gmx.de>

As mentioned in [1], I have a modified version of
debbugs-gnu-send-control-message which just creates the message (or
edits the current one) rather than sending it right away.  I'm posting
it here as a patch to debbugs-gnu.el.  It might make sense to replace
the current debbugs-gnu-send-control-message, or just factor out the
common parts, I haven't really thought much about that.

[1]: http://lists.gnu.org/archive/html/help-debbugs/2018-10/msg00014.html


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 8875 bytes --]

From 2c01285eff8b098f3753d66ad6c18d526508e15c Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@users.sourceforge.net>
Date: Thu, 1 Nov 2018 08:03:57 -0400
Subject: [PATCH v1] New command debbugs-control-make-message

* packages/debbugs/debbugs-gnu.el (debbugs-control-message-keywords):
(debbugs-control-message-commands-regexp)
(debbugs-control-message-end-regexp): New constants.
(debbugs-gnus-implicit-ids): New function.
(debbugs-control-make-message): New command.
---
 packages/debbugs/debbugs-gnu.el | 168 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 168 insertions(+)

diff --git a/packages/debbugs/debbugs-gnu.el b/packages/debbugs/debbugs-gnu.el
index 5466d6518..2f9967281 100644
--- a/packages/debbugs/debbugs-gnu.el
+++ b/packages/debbugs/debbugs-gnu.el
@@ -1591,6 +1591,174 @@ (defun debbugs-gnu-send-control-message (message &optional reverse)
       (message "Control message sent:\n%s"
 	       (buffer-substring-no-properties (point) (1- (point-max)))))))
 
+(defconst debbugs-control-message-keywords
+  '("serious" "important" "normal" "minor" "wishlist"
+    "done" "donenotabug" "donewontfix" "doneunreproducible"
+    "invalid" ; done+notabug+wontfix
+    "unarchive" "unmerge" "reopen" "close"
+    "merge" "forcemerge"
+    "block" "unblock"
+    "owner" "noowner"
+    "reassign"
+    "retitle"
+    "forwarded"
+    ;; 'notfixed <bugnum> <version>' works, even though it's
+    ;; undocumented at debbugs.gnu.org.
+    "fixed" "found" "notfound" "notfixed"
+    "patch" "wontfix" "moreinfo" "unreproducible" "notabug"
+    "pending" "help" "security" "confirmed" "easy"
+    "usertag" "user"
+    "documentation" ;; usertag:emacs.documentation
+    ))
+(defconst debbugs-control-message-commands-regexp
+  (concat "^" (regexp-opt (cl-list* "#" "tags" "severity"
+                                    debbugs-control-message-keywords))
+          " .*$"))
+(defconst debbugs-control-message-end-regexp
+  (concat "^" (regexp-opt '("--" "quit" "stop"
+                            "thank" "thanks" "thankyou" "thank you"))
+          "$"))
+
+(defun debbugs-gnus-implicit-ids ()
+  "Return a list of bug IDs guessed from the current buffer."
+  (delq nil (list (debbugs-gnu-current-id t)
+                  debbugs-gnu-bug-number ; Set on group entry.
+                  (debbugs-gnu-guess-current-id)
+                  (let ((bugnum-re "\\([0-9]+\\)\\(?:-done\\)?@debbugs.gnu.org")
+                        (addr nil))
+                    (and (eq major-mode 'message-mode)
+                         (save-restriction
+                           (message-narrow-to-headers)
+                           (or (let ((addr (message-fetch-field "to")))
+                                 (and addr (string-match bugnum-re addr)
+                                      (match-string 1 addr)))
+                               (let ((addr (message-fetch-field "cc")))
+                                 (and addr (string-match bugnum-re addr)
+                                      (match-string 1 addr))))))))))
+
+(defun debbugs-control-make-message (message bugid &optional reverse)
+  "Make a control message for the current bug report.
+If called from a `message-mode' buffer, add the control command
+to the current buffer, and adjust Bcc as needed.
+
+You can set the severity or add a tag, or close the report.  If
+you use the special \"done\" MESSAGE, the report will be marked as
+fixed, and then closed.
+
+If given a prefix, and given a tag to set, the tag will be
+removed instead."
+  (interactive
+   (save-excursion                 ; Point can change while prompting!
+     (list (completing-read
+            "Control message: " debbugs-control-message-keywords nil t)
+           (let ((implicit-ids (debbugs-gnus-implicit-ids)))
+             (string-to-number
+              (completing-read "Bug #ID: " (mapcar #'prin1-to-string implicit-ids)
+                               (lambda (s) (string-match-p "\\`[0-9]+\\'" s))
+                               nil nil nil (car implicit-ids))))
+           current-prefix-arg)))
+  (let* ((version
+          (when (member message '("done" "fixed" "found"))
+            (save-excursion
+              (read-string
+               "Version: "
+               (pcase (version-to-list emacs-version)
+                 ;; Emacs development versions.
+                 ((and `(,major ,minor ,micro . ,_))
+                  (format "%d.%d" major (+ (if (> micro 1) 1 0) minor)))
+                 (_ emacs-version))))))
+	 (status (debbugs-gnu-current-status))
+         (subject (format "Subject: control message for bug #%d" bugid)))
+    (unless (derived-mode-p 'message-mode)
+      (set-buffer (pop-to-buffer "*Debbugs Control Message for #%d*" bugid))
+      (insert "To: control@debbugs.gnu.org\n"
+	      "From: " (message-make-from) "\n"
+	      (format "Subject: control message for bug #%d\n" bugid)
+	      mail-header-separator
+	      "\n")
+      (message-mode))
+    (let ((ctrl-addr "control@debbugs.gnu.org")
+          (id bugid)
+          to-addr bcc-addr)
+      (save-restriction
+        (message-narrow-to-head)
+        (setq  to-addr (message-fetch-field "to")
+              bcc-addr (message-fetch-field "bcc"))
+        (let* ((ctrl-re (regexp-quote ctrl-addr)))
+          (unless (or (and  to-addr (string-match-p ctrl-re to-addr))
+                      (and bcc-addr (string-match-p ctrl-re bcc-addr)))
+            (message-add-header
+             (format "%s: %s" (if to-addr "Bcc" "To") ctrl-addr)))))
+      (message-goto-body)
+      (while (looking-at-p debbugs-control-message-commands-regexp)
+        (forward-line))
+      (insert
+       (save-excursion             ; Point can change while prompting!
+         (cond
+          ((member message '("unarchive" "unmerge" "noowner"))
+           (format "%s %d\n" message id))
+          ((equal message "reopen")
+           (format "reopen %d\ntag %d - fixed patch\n" id id))
+          ((member message '("merge" "forcemerge"))
+           (format "%s %d %s\n" message id
+                   (read-string "Merge with bug #: ")))
+          ((member message '("block" "unblock"))
+           (format
+            "%s %d by %s\n" message id
+            (mapconcat
+             'identity
+             (completing-read-multiple
+              (format "%s with bug(s) #: " (capitalize message))
+              (if (equal message "unblock")
+                  (mapcar 'number-to-string
+                          (cdr (assq 'blockedby status))))
+              nil (and (equal message "unblock") status))
+             " ")))
+          ((equal message "owner")
+           (format "owner %d !\n" id))
+          ((equal message "retitle")
+           (format "retitle %d %s\n" id (read-string "New title: ")))
+          ((equal message "forwarded")
+           (format "forwarded %d %s\n" id (read-string "Forward to: ")))
+          ((equal message "reassign")
+           (format "reassign %d %s\n" id (read-string "Package(s): ")))
+          ((equal message "close")
+           (format "close %d\n" id))
+          ((equal message "done")
+           (format "tags %d fixed\nclose %d %s\n" id id version))
+          ((member message '("found" "notfound" "fixed" "notfixed"))
+           (format "%s %d %s\n" message id version))
+          ((member message '("donenotabug" "donewontfix"
+                             "doneunreproducible"))
+           (format "tags %d %s\nclose %d\n" id (substring message 4) id))
+          ((member message '("serious" "important" "normal"
+                             "minor" "wishlist"))
+           (format "severity %d %s\n" id message))
+          ((equal message "invalid")
+           (format "tags %d notabug wontfix\nclose %d\n"
+                   id id))
+          ((equal message "documentation")
+           (concat (unless (save-excursion
+                             (message-goto-body)
+                             (re-search-forward "^user emacs$"))
+                     "user emacs\n")
+                   (format "usertag %d %s\n" id "documentation")))
+          ((equal message "usertag")
+           (format "user %s\nusertag %d %s\n"
+                   (completing-read
+                    "Package name or email address: "
+                    (append
+                     debbugs-gnu-all-packages (list user-mail-address))
+                    nil nil (car debbugs-gnu-default-packages))
+                   id (read-string "User tag: ")))
+          (t
+           (format "tags %d %c %s\n"
+                   id (if reverse ?- ?+)
+                   message)))))
+      (unless (looking-at-p debbugs-control-message-end-regexp)
+        (insert "quit\n\n")))))
+
+
 (defvar debbugs-gnu-usertags-mode-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map tabulated-list-mode-map)
-- 
2.11.0


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

* bug#33225: [debbugs.el] Don't send control message immediately
  2018-11-01 12:29 bug#33225: [debbugs.el] Don't send control message immediately Noam Postavsky
@ 2018-11-01 14:28 ` Garreau, Alexandre
  2018-11-02 10:30   ` Michael Albinus
  2018-11-02 10:23 ` Michael Albinus
  1 sibling, 1 reply; 17+ messages in thread
From: Garreau, Alexandre @ 2018-11-01 14:28 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33225, michael albinus

[-- Attachment #1: Type: text/plain, Size: 1986 bytes --]

On 2018-11-01 at 08:29, Noam Postavsky wrote:
> As mentioned in [1], I have a modified version of
> debbugs-gnu-send-control-message which just creates the message (or
> edits the current one) rather than sending it right away.

I believe this is the most straightforward solution to the problem of
control messages sending too fast for the newcomer user.  However, I
guess this is a feature more than a bug for most used users, and this
would have been only useful for the first time to me, when I wanted to
“test it to see how it looks” thinking of “cancelling at the last
moment”, and discovered the mail was already sent before I could even
understand what was happening (and take the time to document more myself
on what was the control message really meaning).  Sure if I saw a
message-mode buffer before, at this moment, I’d have canceled, but that
would only have been useful the first time: then it would have become
tiring, so I would have disabled it to come back the simple behavior,
and loose the benefit of the additional security-check step.

> I'm posting it here as a patch to debbugs-gnu.el.  It might make sense
> to replace the current debbugs-gnu-send-control-message, or just
> factor out the common parts, I haven't really thought much about that.
>
> [1]: http://lists.gnu.org/archive/html/help-debbugs/2018-10/msg00014.html

What I suggested later instead was asking for confirmation for certain
control messages that might uselessly garble and bloat the bug history,
while letting go more common and useful messages that might otherwise
anyway be undone without semantic overhead [2], first suggestion was
just about asking for confirmation about certain messages and not
others, so I attach the already suggested [3] patch here for better
referencing of it.  But in last message [2] I argued in favor of better
discrimination among control messages and potentially clarifying their
meaning and better linking doc.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: debbugs-gnu_confirm-control.patch --]
[-- Type: text/x-diff, Size: 3149 bytes --]

diff --git a/packages/debbugs/debbugs-gnu.el b/packages/debbugs/debbugs-gnu.el
index 5466d6518..ea61e96bb 100644
--- a/packages/debbugs/debbugs-gnu.el
+++ b/packages/debbugs/debbugs-gnu.el
@@ -1462,6 +1462,32 @@ returned by `debbugs-gnu-bugs'."
 	       (number-sequence (string-to-number from) (string-to-number to)))
 	      result))))))))
 
+(defconst debbugs-gnu-control-messages
+  '("serious" "important" "normal" "minor" "wishlist"
+    "done" "donenotabug" "donewontfix" "doneunreproducible"
+    "unarchive" "unmerge" "reopen" "close"
+    "merge" "forcemerge"
+    "block" "unblock"
+    "owner" "noowner"
+    "forwarded" "notforwarded"
+    "invalid"
+    "reassign"
+    "retitle"
+    "patch" "wontfix" "moreinfo" "unreproducible" "fixed" "notabug"
+    "pending" "help" "security" "confirmed" "easy"
+    "usertag")
+  "List of control messages accepted by Debbugs.
+All are accepted and processed by `debbugs-gnu-send-control-message'
+accordingly.")
+
+(defcustom debbugs-gnu-confirm-control-messages '("owner")
+  "List of control messages asking for confirmation.
+Each message listed will make `debbugs-gnu-send-control-message'
+ask for confirmation before sending control message mail."
+  :type (cons 'set (mapcar (apply-partially #'list 'const)
+                           debbugs-gnu-control-messages))
+  :group 'debbugs-gnu)
+
 (defun debbugs-gnu-send-control-message (message &optional reverse)
   "Send a control message for the current bug report.
 You can set the severity or add a tag, or close the report.  If
@@ -1473,19 +1499,7 @@ removed instead."
   (interactive
    (list (completing-read
 	  "Control message: "
-	  '("serious" "important" "normal" "minor" "wishlist"
-	    "done" "donenotabug" "donewontfix" "doneunreproducible"
-	    "unarchive" "unmerge" "reopen" "close"
-	    "merge" "forcemerge"
-	    "block" "unblock"
-	    "owner" "noowner"
-	    "forwarded" "notforwarded"
-	    "invalid"
-	    "reassign"
-	    "retitle"
-	    "patch" "wontfix" "moreinfo" "unreproducible" "fixed" "notabug"
-	    "pending" "help" "security" "confirmed" "easy"
-	    "usertag")
+	  debbugs-gnu-control-messages
 	  nil t)
 	 current-prefix-arg))
   (let* ((id (or (debbugs-gnu-current-id t)
@@ -1585,11 +1599,14 @@ removed instead."
 		(format "tags %d%s %s\n"
 			id (if reverse " -" "")
 			message))))
-      (funcall (or debbugs-gnu-send-mail-function send-mail-function))
-      (remhash id debbugs-cache-data)
-      (message-goto-body)
-      (message "Control message sent:\n%s"
-	       (buffer-substring-no-properties (point) (1- (point-max)))))))
+      (unless (and (member message debbugs-gnu-confirm-control-messages)
+                   (not (y-or-n-p (format "Really send `%s' control message? "
+                                          message))))
+        (funcall (or debbugs-gnu-send-mail-function send-mail-function))
+        (remhash id debbugs-cache-data)
+        (message-goto-body)
+        (message "Control message sent:\n%s"
+                 (buffer-substring-no-properties (point) (1- (point-max))))))))
 
 (defvar debbugs-gnu-usertags-mode-map
   (let ((map (make-sparse-keymap)))

[-- Attachment #3: Type: text/plain, Size: 147 bytes --]


[2] http://lists.gnu.org/archive/html/help-debbugs/2018-11/msg00006.html
[3] http://lists.gnu.org/archive/html/help-debbugs/2018-11/msg00001.html

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

* bug#33225: [debbugs.el] Don't send control message immediately
  2018-11-01 12:29 bug#33225: [debbugs.el] Don't send control message immediately Noam Postavsky
  2018-11-01 14:28 ` Garreau, Alexandre
@ 2018-11-02 10:23 ` Michael Albinus
  2019-01-04 14:38   ` Michael Albinus
  2019-03-30  2:43   ` Noam Postavsky
  1 sibling, 2 replies; 17+ messages in thread
From: Michael Albinus @ 2018-11-02 10:23 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33225, garreau, alexandre

Noam Postavsky <npostavs@gmail.com> writes:

Hi Noam,

> As mentioned in [1], I have a modified version of
> debbugs-gnu-send-control-message which just creates the message (or
> edits the current one) rather than sending it right away.  I'm posting
> it here as a patch to debbugs-gnu.el.

Looks interesting. It seems better suited to extend existing messages,
when replying to another bug-related message.

However, when I call it interactively for control message
"documentation", I get an error:

save-excursion: Search failed: "^user emacs$"

Maybe you could fix it? Furthermore, it asks me for the bug id, even if
the Cc: header contains already such. I guess it could retrieve this
there, and show me as default if it is unique.

> It might make sense to replace the current
> debbugs-gnu-send-control-message, or just factor out the common parts,
> I haven't really thought much about that.

I believe we should keep both functions (with a common basic function),
with different key bindings. "C" for debbugs-gnu-send-control-message,
and maybe "E" for debbugs-control-make-message.

I like also your extensions of the control messages. Would you like to
document them in debbugs-ug.texi?

Best regards, Michael.





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2018-11-01 14:28 ` Garreau, Alexandre
@ 2018-11-02 10:30   ` Michael Albinus
  0 siblings, 0 replies; 17+ messages in thread
From: Michael Albinus @ 2018-11-02 10:30 UTC (permalink / raw)
  To: Garreau, Alexandre; +Cc: 33225, Noam Postavsky

"Garreau, Alexandre" <galex-713@galex-713.eu> writes:

Hi Alexandre,

>> As mentioned in [1], I have a modified version of
>> debbugs-gnu-send-control-message which just creates the message (or
>> edits the current one) rather than sending it right away.
>
> I believe this is the most straightforward solution to the problem of
> control messages sending too fast for the newcomer user.

As you have seen the other message, I'm also in favor of this solution.

> However, I guess this is a feature more than a bug for most used
> users, and this would have been only useful for the first time to me,
> when I wanted to “test it to see how it looks” thinking of “cancelling
> at the last moment”, and discovered the mail was already sent before I
> could even understand what was happening (and take the time to
> document more myself on what was the control message really meaning).
> Sure if I saw a message-mode buffer before, at this moment, I’d have
> canceled, but that would only have been useful the first time: then it
> would have become tiring, so I would have disabled it to come back the
> simple behavior, and loose the benefit of the additional
> security-check step.

In fact I believe we shall offer both
functions. debbugs-gnu-send-control-message, without any confirmation,
is good for experienced users. When you are working on a bug triage, for
example, you need a fluid workflow, w/o interruption for confirmation
and alike.

> What I suggested later instead was asking for confirmation for certain
> control messages that might uselessly garble and bloat the bug history,
> while letting go more common and useful messages that might otherwise
> anyway be undone without semantic overhead [2], first suggestion was
> just about asking for confirmation about certain messages and not
> others, so I attach the already suggested [3] patch here for better
> referencing of it.  But in last message [2] I argued in favor of better
> discrimination among control messages and potentially clarifying their
> meaning and better linking doc.

I believe it is a matter of personal taste, which control messages need
a confirmation, and which not. And this will change also over the
time. Oce you know what "owner" is intended for, you don't need to
confirm this again and again.

What I could imagine is, that you implement an explanation for the
control messages, based on Noam's debbugs-control-make-message. This
needs an emhancement in the manuals, but I'm working on.

Best regards, Michael.





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2018-11-02 10:23 ` Michael Albinus
@ 2019-01-04 14:38   ` Michael Albinus
  2019-02-27  8:45     ` Michael Albinus
  2019-03-30  2:43   ` Noam Postavsky
  1 sibling, 1 reply; 17+ messages in thread
From: Michael Albinus @ 2019-01-04 14:38 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33225, garreau, alexandre

Michael Albinus <michael.albinus@gmx.de> writes:

Hi Noam,

>> As mentioned in [1], I have a modified version of
>> debbugs-gnu-send-control-message which just creates the message (or
>> edits the current one) rather than sending it right away.  I'm posting
>> it here as a patch to debbugs-gnu.el.
>
> Looks interesting. It seems better suited to extend existing messages,
> when replying to another bug-related message.
>
> However, when I call it interactively for control message
> "documentation", I get an error:
>
> save-excursion: Search failed: "^user emacs$"
>
> Maybe you could fix it? Furthermore, it asks me for the bug id, even if
> the Cc: header contains already such. I guess it could retrieve this
> there, and show me as default if it is unique.
>
>> It might make sense to replace the current
>> debbugs-gnu-send-control-message, or just factor out the common parts,
>> I haven't really thought much about that.
>
> I believe we should keep both functions (with a common basic function),
> with different key bindings. "C" for debbugs-gnu-send-control-message,
> and maybe "E" for debbugs-control-make-message.
>
> I like also your extensions of the control messages. Would you like to
> document them in debbugs-ug.texi?

This is lying around. Do you plan to commit it to elpa? If not, what do
you want to do with this?

Best regards, Michael.





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-01-04 14:38   ` Michael Albinus
@ 2019-02-27  8:45     ` Michael Albinus
  2019-02-28  1:10       ` Noam Postavsky
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Albinus @ 2019-02-27  8:45 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33225, garreau, alexandre

Michael Albinus <michael.albinus@gmx.de> writes:

> This is lying around. Do you plan to commit it to elpa? If not, what do
> you want to do with this?

Ping.

Best regards, Michael.





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-02-27  8:45     ` Michael Albinus
@ 2019-02-28  1:10       ` Noam Postavsky
  2019-02-28  7:10         ` Michael Albinus
  0 siblings, 1 reply; 17+ messages in thread
From: Noam Postavsky @ 2019-02-28  1:10 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 33225, garreau, alexandre

Michael Albinus <michael.albinus@gmx.de> writes:

> Michael Albinus <michael.albinus@gmx.de> writes:
>
>> This is lying around. Do you plan to commit it to elpa? If not, what do
>> you want to do with this?
>
> Ping.

Hi, I've been on break from Emacs development for personal reasons, but
I do plan on getting this cleaned up and committed within the next few
weeks.





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-02-28  1:10       ` Noam Postavsky
@ 2019-02-28  7:10         ` Michael Albinus
  0 siblings, 0 replies; 17+ messages in thread
From: Michael Albinus @ 2019-02-28  7:10 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33225, garreau, alexandre

Noam Postavsky <npostavs@gmail.com> writes:

Hi Noam,

> Hi, I've been on break from Emacs development for personal reasons, but

Yes, I was missing you ...

> I do plan on getting this cleaned up and committed within the next few
> weeks.

Thanks!

Best regards, Michael.





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2018-11-02 10:23 ` Michael Albinus
  2019-01-04 14:38   ` Michael Albinus
@ 2019-03-30  2:43   ` Noam Postavsky
  2019-03-31 10:21     ` Michael Albinus
  1 sibling, 1 reply; 17+ messages in thread
From: Noam Postavsky @ 2019-03-30  2:43 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 33225, garreau, alexandre

[-- Attachment #1: Type: text/plain, Size: 2128 bytes --]

Michael Albinus <michael.albinus@gmx.de> writes:

>> As mentioned in [1], I have a modified version of
>> debbugs-gnu-send-control-message which just creates the message (or
>> edits the current one) rather than sending it right away.  I'm posting
>> it here as a patch to debbugs-gnu.el.
>
> Looks interesting. It seems better suited to extend existing messages,
> when replying to another bug-related message.

Yes, though it can also be used to make a control message with more than
one command in it.  And I personally find the way
debbugs-gnu-send-control-message sends the message right away without
even any chance to inspect or modify it rather uncomfortable.  I guess
I'm a bit of a control freak. ;)

> However, when I call it interactively for control message
> "documentation", I get an error:
>
> save-excursion: Search failed: "^user emacs$"
>
> Maybe you could fix it?

Oops, that was a silly mistake.  I didn't end up using the documentation
tag very much.  Obviously not well-tested.

> Furthermore, it asks me for the bug id, even if
> the Cc: header contains already such. I guess it could retrieve this
> there, and show me as default if it is unique.

Ah, it already puts the inferred bug id as default input, but the prompt
doesn't show it.  I use ido completion, which shows the default already
as a completion candidate, so I didn't notice that.  I've added it to
the prompt now.

>> It might make sense to replace the current
>> debbugs-gnu-send-control-message, or just factor out the common parts,
>> I haven't really thought much about that.
>
> I believe we should keep both functions (with a common basic function),
> with different key bindings. "C" for debbugs-gnu-send-control-message,
> and maybe "E" for debbugs-control-make-message.

Okay.  I think debbugs-gnu-make-control-message can be the common basic
function.

> I like also your extensions of the control messages. Would you like to
> document them in debbugs-ug.texi?

Added, though it looks like the .info file is also in git?  I haven't
regenerated it since I use texinfo 4.13, so that would trigger all sorts
of spurious changes.


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 19147 bytes --]

From d21473659cd12138828b24c5752f7302f603f520 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@users.sourceforge.net>
Date: Thu, 1 Nov 2018 08:03:57 -0400
Subject: [PATCH v2] New command debbugs-control-make-message (Bug#33225)

Add new command debbugs-control-make-message which is like
debbugs-gnu-send-control-message, but doesn't send the message
immediately.
* packages/debbugs/debbugs-ug.texi: Document additional supported
keywords: "found", "notfound", "notfixed", "user", and "documentation".
* packages/debbugs/debbugs-gnu.el (debbugs-control-message-keywords):
(debbugs-control-message-commands-regexp)
(debbugs-control-message-end-regexp): New constants.
(debbugs-gnus-implicit-ids): New function.
(debbugs-control-make-message): New command.
(debbugs-gnu-send-control-message): Move guts to new command.
(debbugs-gnu-mode-map, debbugs-read-emacs-bug-with-rmail)
(debbugs-gnu-summary-mode-map)
* packages/debbugs/debbugs-org.el (debbugs-org-mode-map): Bind
debbugs-control-make-message to "E".
---
 packages/debbugs/debbugs-gnu.el  | 322 +++++++++++++++++++++++++--------------
 packages/debbugs/debbugs-org.el  |   1 +
 packages/debbugs/debbugs-ug.texi |  21 +++
 3 files changed, 232 insertions(+), 112 deletions(-)

diff --git a/packages/debbugs/debbugs-gnu.el b/packages/debbugs/debbugs-gnu.el
index aa584b248..028e74deb 100644
--- a/packages/debbugs/debbugs-gnu.el
+++ b/packages/debbugs/debbugs-gnu.el
@@ -917,6 +917,7 @@ (defvar debbugs-gnu-mode-map
     (define-key map "g" 'debbugs-gnu-rescan)
     (define-key map "R" 'debbugs-gnu-show-all-blocking-reports)
     (define-key map "C" 'debbugs-gnu-send-control-message)
+    (define-key map "E" 'debbugs-gnu-make-control-message)
 
     (define-key map "s" 'debbugs-gnu-toggle-sort)
     (define-key map "t" 'debbugs-gnu-toggle-tag)
@@ -1324,9 +1325,11 @@ (defun debbugs-read-emacs-bug-with-rmail (id status merged)
 	 (format "Re: bug#%d: %s" id (cdr (assq 'subject status))))
     (rmail-summary)
     (define-key rmail-summary-mode-map "C" 'debbugs-gnu-send-control-message)
+    (define-key rmail-summary-mode-map "E" 'debbugs-gnu-make-control-message)
     (set-window-text-height nil 10)
     (other-window 1)
     (define-key rmail-mode-map "C" 'debbugs-gnu-send-control-message)
+    (define-key rmail-mode-map "E" 'debbugs-gnu-make-control-message)
     (rmail-show-message 1)))
 
 (defcustom debbugs-gnu-lars-workflow nil
@@ -1375,6 +1378,7 @@ (defun debbugs-gnu-select-report ()
 (defvar debbugs-gnu-summary-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "C" 'debbugs-gnu-send-control-message)
+    (define-key map "E" 'debbugs-gnu-make-control-message)
     (define-key map [(meta m)] 'debbugs-gnu-apply-patch)
     map))
 
@@ -1472,6 +1476,37 @@ (defun debbugs-gnu-expand-bug-number-list (bug-number-list)
 	       (number-sequence (string-to-number from) (string-to-number to)))
 	      result))))))))
 
+
+(defconst debbugs-control-message-keywords
+  '("serious" "important" "normal" "minor" "wishlist"
+    "done" "donenotabug" "donewontfix" "doneunreproducible"
+    "invalid" ; done+notabug+wontfix
+    "unarchive" "unmerge" "reopen" "close"
+    "merge" "forcemerge"
+    "block" "unblock"
+    "owner" "noowner"
+    "reassign"
+    "retitle"
+    "forwarded" "notforwarded"
+    ;; 'notfixed <bugnum> <version>' works, even though it's
+    ;; undocumented at debbugs.gnu.org.
+    "fixed" "found" "notfound" "notfixed"
+    "patch" "wontfix" "moreinfo" "unreproducible" "notabug"
+    "pending" "help" "security" "confirmed" "easy"
+    "usertag" "user"
+    "documentation" ;; usertag:emacs.documentation
+    ))
+
+(defconst debbugs-control-message-commands-regexp
+  (concat "^" (regexp-opt (cl-list* "#" "tags" "severity"
+                                    debbugs-control-message-keywords))
+          " .*$"))
+
+(defconst debbugs-control-message-end-regexp
+  (concat "^" (regexp-opt '("--" "quit" "stop"
+                            "thank" "thanks" "thankyou" "thank you"))
+          "$"))
+
 (defun debbugs-gnu-send-control-message (message &optional reverse)
   "Send a control message for the current bug report.
 You can set the severity or add a tag, or close the report.  If
@@ -1482,124 +1517,187 @@ (defun debbugs-gnu-send-control-message (message &optional reverse)
 removed instead."
   (interactive
    (list (completing-read
-	  "Control message: "
-	  '("serious" "important" "normal" "minor" "wishlist"
-	    "done" "donenotabug" "donewontfix" "doneunreproducible"
-	    "unarchive" "unmerge" "reopen" "close"
-	    "merge" "forcemerge"
-	    "block" "unblock"
-	    "owner" "noowner"
-	    "forwarded" "notforwarded"
-	    "invalid"
-	    "reassign"
-	    "retitle"
-	    "patch" "wontfix" "moreinfo" "unreproducible" "fixed" "notabug"
-	    "pending" "help" "security" "confirmed" "easy"
-	    "usertag")
-	  nil t)
+	  "Control message: " debbugs-control-message-keywords nil t)
 	 current-prefix-arg))
-  (let* ((id (or (debbugs-gnu-current-id t)
-		 debbugs-gnu-bug-number	; Set on group entry.
-		 (debbugs-gnu-guess-current-id)))
-	 (status (debbugs-gnu-current-status))
-	 (version
-	  (when (and
-		 (member message '("close" "done"))
-		 (member "emacs" (cdr (assq 'package status))))
-	    (read-string
-	     "Version: "
-	     (cond
-	      ;; Emacs development versions.
-	      ((if (boundp 'emacs-build-number)
-		   (string-match
-		    "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version)
-		 (string-match
-		  "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\." emacs-version))
-	       (format "%s.%d"
-		       (match-string 1 emacs-version)
-		       (1+ (string-to-number (match-string 2 emacs-version)))))
-	      ;; Emacs release versions.
-	      ((if (boundp 'emacs-build-number)
-		   (string-match
-		    "^\\([0-9]+\\)\\.\\([0-9]+\\)$" emacs-version)
-		 (string-match
-		  "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)$" emacs-version))
-	       (format "%s.%s"
-		       (match-string 1 emacs-version)
-		       (match-string 2 emacs-version)))
-	      (t emacs-version))))))
+  (let ((id (or (debbugs-gnu-current-id t)
+                debbugs-gnu-bug-number       ; Set on group entry.
+                (debbugs-gnu-guess-current-id))))
     (with-temp-buffer
-      (insert "To: control@debbugs.gnu.org\n"
-	      "From: " (message-make-from) "\n"
-	      (format "Subject: control message for bug #%d\n" id)
-	      mail-header-separator
-	      "\n"
-	      (cond
-	       ((member message '("unarchive" "unmerge" "reopen"
-				  "noowner" "notforwarded"))
-		(format "%s %d\n" message id))
-	       ((member message '("merge" "forcemerge"))
-		(format
-		 "%s %d %s\n" message id
-		 (mapconcat
-		  'identity
-		  (debbugs-gnu-expand-bug-number-list
-		   (completing-read-multiple
-		    (format "%s with bug(s) #: " (capitalize message))
-		    debbugs-gnu-completion-table))
-		  " ")))
-	       ((member message '("block" "unblock"))
-		(format
-		 "%s %d by %s\n" message id
-		 (mapconcat
-		  'identity
-		  (debbugs-gnu-expand-bug-number-list
-		   (completing-read-multiple
-		    (format "%s with bug(s) #: " (capitalize message))
-		    (if (equal message "unblock")
-			(mapcar 'number-to-string
-				(cdr (assq 'blockedby status)))
-		      debbugs-gnu-completion-table)
-		    nil (and (equal message "unblock") status)))
-		  " ")))
-	       ((equal message "owner")
-		(format "owner %d !\n" id))
-	       ((equal message "retitle")
-		(format "retitle %d %s\n" id (read-string "New title: ")))
-	       ((equal message "reassign")
-		(format "reassign %d %s\n" id (read-string "Package(s): ")))
-	       ((equal message "forwarded")
-		(format "forwarded %d %s\n" id (read-string "Forwarded to: ")))
-	       ((equal message "close")
-		(format "close %d %s\n" id (or version "")))
-	       ((equal message "done")
-		(format "tags %d fixed\nclose %d %s\n" id id (or version "")))
-	       ((member message '("donenotabug" "donewontfix"
-				  "doneunreproducible"))
-		(format "tags %d %s\nclose %d\n" id (substring message 4) id))
-	       ((member message '("serious" "important" "normal"
-				  "minor" "wishlist"))
-		(format "severity %d %s\n" id message))
-	       ((equal message "invalid")
-		(format "tags %d notabug\ntags %d wontfix\nclose %d\n"
-			id id id))
-	       ((equal message "usertag")
-		(format "user %s\nusertag %d %s\n"
-			(completing-read
-			 "Package name or email address: "
-			 (append
-			  debbugs-gnu-all-packages (list user-mail-address))
-			 nil nil (car debbugs-gnu-default-packages))
-			id (read-string "User tag: ")))
-	       (t
-		(format "tags %d%s %s\n"
-			id (if reverse " -" "")
-			message))))
+      (debbugs-control-make-message
+       message id reverse (current-buffer))
       (funcall (or debbugs-gnu-send-mail-function send-mail-function))
       (remhash id debbugs-cache-data)
       (message-goto-body)
       (message "Control message sent:\n%s"
-	       (buffer-substring-no-properties (point) (1- (point-max)))))))
+               (buffer-substring-no-properties (point) (1- (point-max)))))))
+
+(defun debbugs-gnus-implicit-ids ()
+  "Return a list of bug IDs guessed from the current buffer."
+  (delq nil (list (debbugs-gnu-current-id t)
+                  debbugs-gnu-bug-number ; Set on group entry.
+                  (debbugs-gnu-guess-current-id)
+                  (let ((bugnum-re "\\([0-9]+\\)\\(?:-done\\)?@debbugs.gnu.org")
+                        (addr nil))
+                    (when (derived-mode-p 'message-mode)
+                      (save-excursion
+                        (save-restriction
+                          (message-narrow-to-headers)
+                          (or (let ((addr (message-fetch-field "to")))
+                                (and addr (string-match bugnum-re addr)
+                                     (string-to-number (match-string 1 addr))))
+                              (let ((addr (message-fetch-field "cc")))
+                                (and addr (string-match bugnum-re addr)
+                                     (string-to-number (match-string 1 addr))))))))))))
+
+(defun debbugs-control-make-message (message bugid &optional reverse buffer)
+  "Make a control message for the current bug report.
+The message is inserted into BUFFER.  If BUFFER omitted, create
+and display a new buffer.  When called interactively, choose the
+current buffer it is in `message-mode', or create a new buffer
+otherwise.  If BUFFER is empty, add the needed headers to  `message-mode', add the control
+command to the current buffer, and adjust Bcc as needed.
+
+You can set the severity or add a tag, or close the report.  If
+you use the special \"done\" MESSAGE, the report will be marked as
+fixed, and then closed.
+
+If given a prefix, and given a tag to set, the tag will be
+removed instead."
+  (interactive
+   (save-excursion                 ; Point can change while prompting!
+     (list (completing-read
+            "Control message: " debbugs-control-message-keywords nil t)
+           (let* ((implicit-ids (mapcar #'prin1-to-string
+                                        (debbugs-gnus-implicit-ids)))
+                  (default-id (car implicit-ids)))
+             (string-to-number
+              (completing-read (if default-id (format "Bug #ID (default %s): " default-id)
+                                 "Bug #ID: ")
+                               implicit-ids
+                               (lambda (s) (string-match-p "\\`[0-9]+\\'" s))
+                               nil nil nil (car implicit-ids))))
+           current-prefix-arg
+           (when (derived-mode-p 'message-mode)
+             (current-buffer)))))
+  (let* ((version
+          (when (member message '("done" "fixed" "found"))
+            (save-excursion
+              (read-string
+               "Version: "
+               (pcase (nbutlast (version-to-list emacs-version)
+                                ;; Chop off build number, if needed.
+                                (if (boundp 'emacs-build-number)
+                                    0
+                                  1))
+                 (`(,major ,minor ,micro) ; Development version.
+                  (format "%d.%d" major (1+ minor)))
+                 (`(,major ,minor)      ; Release version.
+                  (format "%d.%d" major minor))
+                 ;; Newer release versions without build number are
+                 ;; already in the right format.
+                 (_ emacs-version))))))
+	 (status (debbugs-gnu-current-status))
+         (subject (format "Subject: control message for bug #%d" bugid)))
+    (unless buffer
+      (setq buffer
+            (pop-to-buffer (get-buffer-create
+                            (format "*Debbugs Control Message for #%d*" bugid)))))
+    (set-buffer buffer)
+    (when (= (buffer-size) 0)
+      (insert "To: control@debbugs.gnu.org\n"
+              "From: " (message-make-from) "\n"
+              (format "Subject: control message for bug #%d\n" bugid)
+              mail-header-separator
+              "\n"))
+    (unless (derived-mode-p 'message-mode)
+      (message-mode))
+    (save-restriction
+      (message-narrow-to-head)
+      (let* ((ctrl-addr "control@debbugs.gnu.org")
+             (ctrl-re (regexp-quote ctrl-addr))
+             (to-addr (message-fetch-field "to"))
+             (bcc-addr (message-fetch-field "bcc")))
+        (unless (or (and  to-addr (string-match-p ctrl-re to-addr))
+                    (and bcc-addr (string-match-p ctrl-re bcc-addr)))
+          (message-add-header
+           (format "%s: %s" (if to-addr "Bcc" "To") ctrl-addr)))))
+    (message-goto-body)
+    (while (looking-at-p debbugs-control-message-commands-regexp)
+      (forward-line))
+    (insert
+     (save-excursion             ; Point can change while prompting!
+       (cond
+        ((member message '("unarchive" "unmerge" "noowner"
+                           "notfixed" "notforwarded"))
+         (format "%s %d\n" message bugid))
+        ((equal message "reopen")
+         (format "reopen %d\ntag %d - fixed patch\n" bugid bugid))
+        ((member message '("merge" "forcemerge"))
+         (format "%s %d %s\n" message bugid
+                 (read-string "Merge with bug #: ")))
+        ((member message '("block" "unblock"))
+         (format
+          "%s %d by %s\n" message bugid
+          (mapconcat
+           'identity
+           (completing-read-multiple
+            (format "%s with bug(s) #: " (capitalize message))
+            (if (equal message "unblock")
+                (mapcar 'number-to-string
+                        (cdr (assq 'blockedby status))))
+            nil (and (equal message "unblock") status))
+           " ")))
+        ((equal message "owner")
+         (format "owner %d !\n" bugid))
+        ((equal message "retitle")
+         (format "retitle %d %s\n" bugid (read-string "New title: ")))
+        ((equal message "forwarded")
+         (format "forwarded %d %s\n" bugid (read-string "Forward to: ")))
+        ((equal message "reassign")
+         (format "reassign %d %s\n" bugid (read-string "Package(s): ")))
+        ((equal message "close")
+         (format "close %d\n" bugid))
+        ((equal message "done")
+         (format "tags %d fixed\nclose %d %s\n" bugid bugid version))
+        ((member message '("found" "notfound" "fixed"))
+         (format "%s %d %s\n" message bugid version))
+        ((member message '("donenotabug" "donewontfix"
+                           "doneunreproducible"))
+         (format "tags %d %s\nclose %d\n" bugid (substring message 4) bugid))
+        ((member message '("serious" "important" "normal"
+                           "minor" "wishlist"))
+         (format "severity %d %s\n" bugid message))
+        ((equal message "invalid")
+         (format "tags %d notabug wontfix\nclose %d\n"
+                 bugid bugid))
+        ((equal message "documentation")
+         (concat (unless (save-excursion
+                           (message-goto-body)
+                           (re-search-forward "^user emacs$" nil t))
+                   "user emacs\n")
+                 (format "usertag %d %s\n" bugid "documentation")))
+        ((equal message "user")
+         (format "user %s\n"
+                 (completing-read
+                  "Package name or email address: "
+                  (append
+                   debbugs-gnu-all-packages (list user-mail-address))
+                  nil nil (car debbugs-gnu-default-packages))))
+        ((equal message "usertag")
+         (format "user %s\nusertag %d %s\n"
+                 (completing-read
+                  "Package name or email address: "
+                  (append
+                   debbugs-gnu-all-packages (list user-mail-address))
+                  nil nil (car debbugs-gnu-default-packages))
+                 bugid (read-string "User tag: ")))
+        (t
+         (format "tags %d %c %s\n"
+                 bugid (if reverse ?- ?+)
+                 message)))))
+    (unless (looking-at-p debbugs-control-message-end-regexp)
+      (insert "quit\n\n"))))
+
 
 (defvar debbugs-gnu-usertags-mode-map
   (let ((map (make-sparse-keymap)))
diff --git a/packages/debbugs/debbugs-org.el b/packages/debbugs/debbugs-org.el
index a0e86b730..99696e659 100644
--- a/packages/debbugs/debbugs-org.el
+++ b/packages/debbugs/debbugs-org.el
@@ -293,6 +293,7 @@ (defconst debbugs-org-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "C-c # t") 'debbugs-gnu-toggle-tag)
     (define-key map (kbd "C-c # C") 'debbugs-gnu-send-control-message)
+    (define-key map (kbd "C-c # E") 'debbugs-gnu-make-control-message)
     (define-key map (kbd "C-c # d") 'debbugs-gnu-display-status)
     map)
   "Keymap for the `debbugs-org-mode' minor mode.")
diff --git a/packages/debbugs/debbugs-ug.texi b/packages/debbugs/debbugs-ug.texi
index 0a335129d..0da825347 100644
--- a/packages/debbugs/debbugs-ug.texi
+++ b/packages/debbugs/debbugs-ug.texi
@@ -550,6 +550,14 @@ If the command invoking the control message has been prefixed with
 The second argument in the close message, the Emacs version, is read
 interactively if the bug belongs to the @code{"emacs"} package.
 
+@item found
+@itemx notfound
+@itemx fixed
+"found|notfound|fixed 12345 25.1"
+
+The second argument, the Emacs version, is read interactively if the
+bug belongs to the @code{"emacs"} package.
+
 @item forwarded
 "forwarded 12345 @var{address}"
 
@@ -600,12 +608,25 @@ The new bug title is read interactively.
 @item unmerge
 "unmerge 12345"
 
+@item user
+"user @var{username}"
+
+The username, read interactively, is either a package name or an email
+address.
+
 @item usertag
 "user @var{username}" @*
 "usertag 12345 @var{tag}"
 
 The username, read interactively, is either a package name or an email
 address.  The tag to be set is also read interactively.
+
+@item documentation
+"user emacs" @*
+"usertag 12345 documentation"
+
+The first command, setting the user to emacs, is omitted if previous
+control messages have already set it.
 @end table
 
 @vindex debbugs-gnu-send-mail-function
-- 
2.11.0


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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-03-30  2:43   ` Noam Postavsky
@ 2019-03-31 10:21     ` Michael Albinus
  2019-03-31 21:27       ` Noam Postavsky
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Albinus @ 2019-03-31 10:21 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33225, garreau, alexandre

Noam Postavsky <npostavs@gmail.com> writes:

Hi Noam,

Thanks for the patch. In general, it works fine, so I guess you could
push it. We (I)'ll play then for some days, and if there's no serious
complaint, I'll make a new debbugs release.

But I still have some comments :-)

Please rename

debbugs-control-make-message → debbugs-gnu-make-control-message
debbugs-control-message-keywords → debbugs-gnu-control-message-keywords
debbugs-control-message-commands-regexp → debbugs-gnu-control-message-commands-regexp
debbugs-control-message-end-regexp → debbugs-gnu-control-message-end-regexp

Please add (the keybindings of) debbugs-gnu-make-control-message to the
Commentary sections of debbugs-gnu.el and debbugs-org.el and to the nodes
"Tabulated Lists" and "TODO Items" of debbugs-ug.texi.

Compiling debbugs-gnu.el results in

debbugs-gnu.el:1534:1:Warning: Unused lexical variable ‘addr’
debbugs-gnu.el:1552:1:Warning: Unused lexical variable ‘micro’
debbugs-gnu.el:1552:1:Warning: Unused lexical variable ‘subject’

Maybe you can fix it?

> Added, though it looks like the .info file is also in git?  I haven't
> regenerated it since I use texinfo 4.13, so that would trigger all sorts
> of spurious changes.

Yes, unfortunately, the info file must be there. Don't worry about, I'll
regenerate.

> +(defconst debbugs-control-message-keywords
> +  '("serious" "important" "normal" "minor" "wishlist"
> +    "done" "donenotabug" "donewontfix" "doneunreproducible"
> +    "invalid" ; done+notabug+wontfix
> +    "unarchive" "unmerge" "reopen" "close"
> +    "merge" "forcemerge"
> +    "block" "unblock"
> +    "owner" "noowner"
> +    "reassign"
> +    "retitle"
> +    "forwarded" "notforwarded"
> +    ;; 'notfixed <bugnum> <version>' works, even though it's
> +    ;; undocumented at debbugs.gnu.org.
> +    "fixed" "found" "notfound" "notfixed"
> +    "patch" "wontfix" "moreinfo" "unreproducible" "notabug"
> +    "pending" "help" "security" "confirmed" "easy"
> +    "usertag" "user"
> +    "documentation" ;; usertag:emacs.documentation
> +    ))

I suppose "user" is needed in case of debbugs-gnu-make-control-message
only. Could we separate this, and offer completion only for that
function?

> +        ((member message '("merge" "forcemerge"))
> +         (format "%s %d %s\n" message bugid
> +                 (read-string "Merge with bug #: ")))

You have removed the bug number completion via
debbugs-gnu-expand-bug-number-list. Why?

> +        ((member message '("block" "unblock"))
> +         (format
> +          "%s %d by %s\n" message bugid
> +          (mapconcat
> +           'identity
> +           (completing-read-multiple
> +            (format "%s with bug(s) #: " (capitalize message))
> +            (if (equal message "unblock")
> +                (mapcar 'number-to-string
> +                        (cdr (assq 'blockedby status))))
> +            nil (and (equal message "unblock") status))
> +           " ")))

dito

> +@item user
> +"user @var{username}"
> +
> +The username, read interactively, is either a package name or an email
> +address.

Please mention, that this is used in order to avoid giving the user name
again, for further commands.

Best regards, Michael.





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-03-31 10:21     ` Michael Albinus
@ 2019-03-31 21:27       ` Noam Postavsky
  2019-04-01  7:35         ` Michael Albinus
  0 siblings, 1 reply; 17+ messages in thread
From: Noam Postavsky @ 2019-03-31 21:27 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 33225, garreau, alexandre

[-- Attachment #1: Type: text/plain, Size: 3266 bytes --]

Michael Albinus <michael.albinus@gmx.de> writes:

> Thanks for the patch. In general, it works fine, so I guess you could
> push it. We (I)'ll play then for some days, and if there's no serious
> complaint, I'll make a new debbugs release.
>
> But I still have some comments :-)

I've updated according to your comments, I'll wait another couple of
days before pushing in case we can catch any more silly mistakes.

Regarding making a release, I have in mind next to bring in my commands
which produce control messages from git commits (both for attaching
proposed patches from an unpushed commit, and closing from a pushed
one).  Perhaps you want to wait for that before making a new release?
(or perhaps just the opposite, not sure what your release policy is)

> Please rename
>
> debbugs-control-make-message → debbugs-gnu-make-control-message
> debbugs-control-message-keywords → debbugs-gnu-control-message-keywords
> debbugs-control-message-commands-regexp → debbugs-gnu-control-message-commands-regexp
> debbugs-control-message-end-regexp → debbugs-gnu-control-message-end-regexp
>
> Please add (the keybindings of) debbugs-gnu-make-control-message to the
> Commentary sections of debbugs-gnu.el and debbugs-org.el and to the nodes
> "Tabulated Lists" and "TODO Items" of debbugs-ug.texi.

Done and done.

> Compiling debbugs-gnu.el results in
>
> debbugs-gnu.el:1534:1:Warning: Unused lexical variable ‘addr’
> debbugs-gnu.el:1552:1:Warning: Unused lexical variable ‘micro’
> debbugs-gnu.el:1552:1:Warning: Unused lexical variable ‘subject’
>
> Maybe you can fix it?

Oops, yes.

>> +(defconst debbugs-control-message-keywords

>> +    "usertag" "user"
>> +    "documentation" ;; usertag:emacs.documentation
>> +    ))
>
> I suppose "user" is needed in case of debbugs-gnu-make-control-message
> only. Could we separate this, and offer completion only for that
> function?

Actually, thinking about it, there's really no need for a "user" control
message.  I've just removed it instead (it only needs to go in
debbugs-gnu-control-message-commands-regexp).

>> +        ((member message '("merge" "forcemerge"))
>> +         (format "%s %d %s\n" message bugid
>> +                 (read-string "Merge with bug #: ")))
>
> You have removed the bug number completion via
> debbugs-gnu-expand-bug-number-list. Why?

>> +        ((member message '("block" "unblock"))

> dito

Ah, I think what happened is that I started from a very old version
debbugs-gnu-send-control-message which didn't use
debbugs-gnu-expand-bug-number-list.  Fixed now (I also added back the
version arg to "close").

>> +@item user
>> +"user @var{username}"
>> +
>> +The username, read interactively, is either a package name or an email
>> +address.
>
> Please mention, that this is used in order to avoid giving the user name
> again, for further commands.

As mentioned above, I decided to simply remove this instead.  And I also
removed the duplicate avoidance feature of "documentation".  Making the
message shorter isn't that much of a benefit, and having it adds more
possible failure modes (e.g., if there is both "user emacs" and "user
something-else", things get tricky).


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 20791 bytes --]

From 80080854cd4e9d34fcd6e397b402ce5230deb310 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@users.sourceforge.net>
Date: Thu, 1 Nov 2018 08:03:57 -0400
Subject: [PATCH v3] New command debbugs-control-make-message (Bug#33225)

Add new command debbugs-control-make-message which is like
debbugs-gnu-send-control-message, but doesn't send the message
immediately.
* packages/debbugs/debbugs-ug.texi: Document additional keybinding and
control message keywords: "found", "notfound", "notfixed", and
"documentation".
* packages/debbugs/debbugs-gnu.el (debbugs-control-message-keywords):
(debbugs-gnu-control-message-commands-regexp)
(debbugs-gnu-control-message-end-regexp): New constants.
(debbugs-gnus-implicit-ids): New function.
(debbugs-gnu-make-control-message): New command.
(debbugs-gnu-send-control-message): Move guts to new command.
(debbugs-gnu-mode-map, debbugs-read-emacs-bug-with-rmail)
(debbugs-gnu-summary-mode-map)
* packages/debbugs/debbugs-org.el (debbugs-org-mode-map): Bind
debbugs-gnu-make-control-message to "E".
---
 packages/debbugs/debbugs-gnu.el  | 333 ++++++++++++++++++++++++++-------------
 packages/debbugs/debbugs-org.el  |   2 +
 packages/debbugs/debbugs-ug.texi |  27 ++++
 3 files changed, 249 insertions(+), 113 deletions(-)

diff --git a/packages/debbugs/debbugs-gnu.el b/packages/debbugs/debbugs-gnu.el
index aa584b248..effb6acaf 100644
--- a/packages/debbugs/debbugs-gnu.el
+++ b/packages/debbugs/debbugs-gnu.el
@@ -91,6 +91,7 @@
 
 ;;   RET: Show corresponding messages in Gnus/Rmail
 ;;   "C": Send a control message
+;;   "E": Make (but don't yet send) a control message
 ;;   "t": Mark the bug locally as tagged
 ;;   "b": Show bugs this bug is blocked by
 ;;   "B": Show bugs this bug is blocking
@@ -107,7 +108,8 @@
 ;;   "w": Display all the currently selected bug reports
 
 ;; When you visit the related bug messages in Gnus or Rmail, you could
-;; also send control messages by keystroke "C".
+;; also send or make control messages by keystroke "C" or "E" in the
+;; message summary buffer.
 
 ;; In the header line of every bug list page, you can toggle sorting
 ;; per column by selecting a column with the mouse.  The sorting
@@ -917,6 +919,7 @@ (defvar debbugs-gnu-mode-map
     (define-key map "g" 'debbugs-gnu-rescan)
     (define-key map "R" 'debbugs-gnu-show-all-blocking-reports)
     (define-key map "C" 'debbugs-gnu-send-control-message)
+    (define-key map "E" 'debbugs-gnu-make-control-message)
 
     (define-key map "s" 'debbugs-gnu-toggle-sort)
     (define-key map "t" 'debbugs-gnu-toggle-tag)
@@ -1324,9 +1327,11 @@ (defun debbugs-read-emacs-bug-with-rmail (id status merged)
 	 (format "Re: bug#%d: %s" id (cdr (assq 'subject status))))
     (rmail-summary)
     (define-key rmail-summary-mode-map "C" 'debbugs-gnu-send-control-message)
+    (define-key rmail-summary-mode-map "E" 'debbugs-gnu-make-control-message)
     (set-window-text-height nil 10)
     (other-window 1)
     (define-key rmail-mode-map "C" 'debbugs-gnu-send-control-message)
+    (define-key rmail-mode-map "E" 'debbugs-gnu-make-control-message)
     (rmail-show-message 1)))
 
 (defcustom debbugs-gnu-lars-workflow nil
@@ -1375,6 +1380,7 @@ (defun debbugs-gnu-select-report ()
 (defvar debbugs-gnu-summary-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "C" 'debbugs-gnu-send-control-message)
+    (define-key map "E" 'debbugs-gnu-make-control-message)
     (define-key map [(meta m)] 'debbugs-gnu-apply-patch)
     map))
 
@@ -1472,6 +1478,37 @@ (defun debbugs-gnu-expand-bug-number-list (bug-number-list)
 	       (number-sequence (string-to-number from) (string-to-number to)))
 	      result))))))))
 
+
+(defconst debbugs-gnu-control-message-keywords
+  '("serious" "important" "normal" "minor" "wishlist"
+    "done" "donenotabug" "donewontfix" "doneunreproducible"
+    "invalid" ; done+notabug+wontfix
+    "unarchive" "unmerge" "reopen" "close"
+    "merge" "forcemerge"
+    "block" "unblock"
+    "owner" "noowner"
+    "reassign"
+    "retitle"
+    "forwarded" "notforwarded"
+    ;; 'notfixed <bugnum> <version>' works, even though it's
+    ;; undocumented at debbugs.gnu.org.
+    "fixed" "found" "notfound" "notfixed"
+    "patch" "wontfix" "moreinfo" "unreproducible" "notabug"
+    "pending" "help" "security" "confirmed" "easy"
+    "usertag"
+    "documentation" ;; usertag:emacs.documentation
+    ))
+
+(defconst debbugs-gnu-control-message-commands-regexp
+  (concat "^" (regexp-opt (cl-list* "#" "tags" "severity" "user"
+                                    debbugs-gnu-control-message-keywords))
+          " .*$"))
+
+(defconst debbugs-gnu-control-message-end-regexp
+  (concat "^" (regexp-opt '("--" "quit" "stop"
+                            "thank" "thanks" "thankyou" "thank you"))
+          "$"))
+
 (defun debbugs-gnu-send-control-message (message &optional reverse)
   "Send a control message for the current bug report.
 You can set the severity or add a tag, or close the report.  If
@@ -1482,124 +1519,194 @@ (defun debbugs-gnu-send-control-message (message &optional reverse)
 removed instead."
   (interactive
    (list (completing-read
-	  "Control message: "
-	  '("serious" "important" "normal" "minor" "wishlist"
-	    "done" "donenotabug" "donewontfix" "doneunreproducible"
-	    "unarchive" "unmerge" "reopen" "close"
-	    "merge" "forcemerge"
-	    "block" "unblock"
-	    "owner" "noowner"
-	    "forwarded" "notforwarded"
-	    "invalid"
-	    "reassign"
-	    "retitle"
-	    "patch" "wontfix" "moreinfo" "unreproducible" "fixed" "notabug"
-	    "pending" "help" "security" "confirmed" "easy"
-	    "usertag")
-	  nil t)
+          "Control message: " debbugs-gnu-control-message-keywords nil t)
 	 current-prefix-arg))
-  (let* ((id (or (debbugs-gnu-current-id t)
-		 debbugs-gnu-bug-number	; Set on group entry.
-		 (debbugs-gnu-guess-current-id)))
-	 (status (debbugs-gnu-current-status))
-	 (version
-	  (when (and
-		 (member message '("close" "done"))
-		 (member "emacs" (cdr (assq 'package status))))
-	    (read-string
-	     "Version: "
-	     (cond
-	      ;; Emacs development versions.
-	      ((if (boundp 'emacs-build-number)
-		   (string-match
-		    "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version)
-		 (string-match
-		  "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\." emacs-version))
-	       (format "%s.%d"
-		       (match-string 1 emacs-version)
-		       (1+ (string-to-number (match-string 2 emacs-version)))))
-	      ;; Emacs release versions.
-	      ((if (boundp 'emacs-build-number)
-		   (string-match
-		    "^\\([0-9]+\\)\\.\\([0-9]+\\)$" emacs-version)
-		 (string-match
-		  "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)$" emacs-version))
-	       (format "%s.%s"
-		       (match-string 1 emacs-version)
-		       (match-string 2 emacs-version)))
-	      (t emacs-version))))))
+  (let ((id (or (debbugs-gnu-current-id t)
+                debbugs-gnu-bug-number       ; Set on group entry.
+                (debbugs-gnu-guess-current-id))))
     (with-temp-buffer
-      (insert "To: control@debbugs.gnu.org\n"
-	      "From: " (message-make-from) "\n"
-	      (format "Subject: control message for bug #%d\n" id)
-	      mail-header-separator
-	      "\n"
-	      (cond
-	       ((member message '("unarchive" "unmerge" "reopen"
-				  "noowner" "notforwarded"))
-		(format "%s %d\n" message id))
-	       ((member message '("merge" "forcemerge"))
-		(format
-		 "%s %d %s\n" message id
-		 (mapconcat
-		  'identity
-		  (debbugs-gnu-expand-bug-number-list
-		   (completing-read-multiple
-		    (format "%s with bug(s) #: " (capitalize message))
-		    debbugs-gnu-completion-table))
-		  " ")))
-	       ((member message '("block" "unblock"))
-		(format
-		 "%s %d by %s\n" message id
-		 (mapconcat
-		  'identity
-		  (debbugs-gnu-expand-bug-number-list
-		   (completing-read-multiple
-		    (format "%s with bug(s) #: " (capitalize message))
-		    (if (equal message "unblock")
-			(mapcar 'number-to-string
-				(cdr (assq 'blockedby status)))
-		      debbugs-gnu-completion-table)
-		    nil (and (equal message "unblock") status)))
-		  " ")))
-	       ((equal message "owner")
-		(format "owner %d !\n" id))
-	       ((equal message "retitle")
-		(format "retitle %d %s\n" id (read-string "New title: ")))
-	       ((equal message "reassign")
-		(format "reassign %d %s\n" id (read-string "Package(s): ")))
-	       ((equal message "forwarded")
-		(format "forwarded %d %s\n" id (read-string "Forwarded to: ")))
-	       ((equal message "close")
-		(format "close %d %s\n" id (or version "")))
-	       ((equal message "done")
-		(format "tags %d fixed\nclose %d %s\n" id id (or version "")))
-	       ((member message '("donenotabug" "donewontfix"
-				  "doneunreproducible"))
-		(format "tags %d %s\nclose %d\n" id (substring message 4) id))
-	       ((member message '("serious" "important" "normal"
-				  "minor" "wishlist"))
-		(format "severity %d %s\n" id message))
-	       ((equal message "invalid")
-		(format "tags %d notabug\ntags %d wontfix\nclose %d\n"
-			id id id))
-	       ((equal message "usertag")
-		(format "user %s\nusertag %d %s\n"
-			(completing-read
-			 "Package name or email address: "
-			 (append
-			  debbugs-gnu-all-packages (list user-mail-address))
-			 nil nil (car debbugs-gnu-default-packages))
-			id (read-string "User tag: ")))
-	       (t
-		(format "tags %d%s %s\n"
-			id (if reverse " -" "")
-			message))))
+      (debbugs-gnu-make-control-message
+       message id reverse (current-buffer))
       (funcall (or debbugs-gnu-send-mail-function send-mail-function))
       (remhash id debbugs-cache-data)
       (message-goto-body)
       (message "Control message sent:\n%s"
-	       (buffer-substring-no-properties (point) (1- (point-max)))))))
+               (buffer-substring-no-properties (point) (1- (point-max)))))))
+
+(defun debbugs-gnus-implicit-ids ()
+  "Return a list of bug IDs guessed from the current buffer."
+  (delq nil (delete-dups
+             (list (debbugs-gnu-current-id t)
+                   debbugs-gnu-bug-number ; Set on group entry.
+                   (debbugs-gnu-guess-current-id)
+                   (let ((bugnum-re "\\([0-9]+\\)\\(?:-done\\)?@debbugs.gnu.org"))
+                     (when (derived-mode-p 'message-mode)
+                       (save-excursion
+                         (save-restriction
+                           (message-narrow-to-headers)
+                           (or (let ((addr (message-fetch-field "to")))
+                                 (and addr (string-match bugnum-re addr)
+                                      (string-to-number (match-string 1 addr))))
+                               (let ((addr (message-fetch-field "cc")))
+                                 (and addr (string-match bugnum-re addr)
+                                      (string-to-number (match-string 1 addr)))))))))))))
+
+(defun debbugs-gnu-make-control-message (message bugid &optional reverse buffer)
+  "Make a control message for the current bug report.
+The message is inserted into BUFFER, and mail headers are adjust
+so that it will be sent to control@debbugs.gnu.org (via Bcc if
+there is already a To address).  If BUFFER omitted, create and
+display a new buffer.
+
+When called interactively, choose the current buffer if it is in
+`message-mode', or create a new buffer otherwise.
+
+You can set the severity or add a tag, or close the report.  If
+you use the special \"done\" MESSAGE, the report will be marked as
+fixed, and then closed.
+
+If given a prefix, and given a tag to set, the tag will be
+removed instead."
+  (interactive
+   (save-excursion                 ; Point can change while prompting!
+     (list (completing-read
+            "Control message: " debbugs-gnu-control-message-keywords nil t)
+           (let* ((implicit-ids (mapcar #'prin1-to-string
+                                        (debbugs-gnus-implicit-ids)))
+                  (default-id (car implicit-ids)))
+             (string-to-number
+              (completing-read (if default-id
+                                   (format "Bug #ID (default %s): " default-id)
+                                 "Bug #ID: ")
+                               implicit-ids
+                               (lambda (s) (string-match-p "\\`[0-9]+\\'" s))
+                               nil nil nil (car implicit-ids))))
+           current-prefix-arg
+           (when (derived-mode-p 'message-mode)
+             (current-buffer)))))
+  (let* ((status (debbugs-gnu-current-status))
+         (version
+          (when (and
+                 (member message '("close" "done" "fixed" "found"))
+                 (member "emacs" (cdr (assq 'package status))))
+            (save-excursion
+              (read-string
+               "Version: "
+               (pcase (nbutlast (version-to-list emacs-version)
+                                ;; Chop off build number, if needed.
+                                (if (boundp 'emacs-build-number)
+                                    0
+                                  1))
+                 (`(,major ,minor ,_micro) ; Development version.
+                  (format "%d.%d" major (if (equal message "found")
+                                            minor
+                                          (1+ minor))))
+                 (`(,major ,minor)      ; Release version.
+                  (format "%d.%d" major minor))
+                 ;; Unexpected version format?
+                 (_ emacs-version)))))))
+    (unless buffer
+      (setq buffer
+            (pop-to-buffer
+             (get-buffer-create
+              (format "*Debbugs Control Message for #%d*" bugid)))))
+    (set-buffer buffer)
+    (when (= (buffer-size) 0)
+      (insert "To: control@debbugs.gnu.org\n"
+              "From: " (message-make-from) "\n"
+              (format "Subject: control message for bug #%d\n" bugid)
+              mail-header-separator
+              "\n"))
+    (unless (or (derived-mode-p 'message-mode)
+                ;; `message-mode' associates buffer with file, we
+                ;; don't want to do that for temp buffers.
+                (eq (aref (buffer-name) 0) ?\s))
+      (message-mode))
+    (save-restriction
+      (message-narrow-to-head)
+      (let* ((ctrl-addr "control@debbugs.gnu.org")
+             (ctrl-re (regexp-quote ctrl-addr))
+             (to-addr (message-fetch-field "to"))
+             (bcc-addr (message-fetch-field "bcc")))
+        (unless (or (and  to-addr (string-match-p ctrl-re to-addr))
+                    (and bcc-addr (string-match-p ctrl-re bcc-addr)))
+          (message-add-header
+           (format "%s: %s" (if to-addr "Bcc" "To") ctrl-addr)))))
+    (message-goto-body)
+    (while (looking-at-p debbugs-gnu-control-message-commands-regexp)
+      (forward-line))
+    (insert
+     (save-excursion             ; Point can change while prompting!
+       (cond
+        ((member message '("unarchive" "unmerge" "noowner"
+                           "notfixed" "notforwarded"))
+         (format "%s %d\n" message bugid))
+        ((equal message "reopen")
+         (format "reopen %d\ntag %d - fixed patch\n" bugid bugid))
+        ((member message '("merge" "forcemerge"))
+         (format
+          "%s %d %s\n" message bugid
+          (mapconcat
+           'identity
+           (debbugs-gnu-expand-bug-number-list
+            (completing-read-multiple
+             (format "%s with bug(s) #: " (capitalize message))
+             debbugs-gnu-completion-table))
+           " ")))
+        ((member message '("block" "unblock"))
+         (format
+          "%s %d by %s\n" message bugid
+          (mapconcat
+           'identity
+           (debbugs-gnu-expand-bug-number-list
+            (completing-read-multiple
+             (format "%s with bug(s) #: " (capitalize message))
+             (if (equal message "unblock")
+                 (mapcar 'number-to-string
+                         (cdr (assq 'blockedby status)))
+               debbugs-gnu-completion-table)
+             nil (and (equal message "unblock") status)))
+           " ")))
+        ((equal message "owner")
+         (format "owner %d !\n" bugid))
+        ((equal message "retitle")
+         (format "retitle %d %s\n" bugid (read-string "New title: ")))
+        ((equal message "forwarded")
+         (format "forwarded %d %s\n" bugid (read-string "Forward to: ")))
+        ((equal message "reassign")
+         (format "reassign %d %s\n" bugid (read-string "Package(s): ")))
+        ((equal message "close")
+         (format "close %d %s\n" bugid (or version "")))
+        ((equal message "done")
+         (format "tags %d fixed\nclose %d %s\n" bugid bugid version))
+        ((member message '("found" "notfound" "fixed"))
+         (format "%s %d %s\n" message bugid version))
+        ((member message '("donenotabug" "donewontfix"
+                           "doneunreproducible"))
+         (format "tags %d %s\nclose %d\n" bugid (substring message 4) bugid))
+        ((member message '("serious" "important" "normal"
+                           "minor" "wishlist"))
+         (format "severity %d %s\n" bugid message))
+        ((equal message "invalid")
+         (format "tags %d notabug wontfix\nclose %d\n"
+                 bugid bugid))
+        ((equal message "documentation")
+         (format "user emacs\nusertag %d %s\n" bugid "documentation"))
+        ((equal message "usertag")
+         (format "user %s\nusertag %d %s\n"
+                 (completing-read
+                  "Package name or email address: "
+                  (append
+                   debbugs-gnu-all-packages (list user-mail-address))
+                  nil nil (car debbugs-gnu-default-packages))
+                 bugid (read-string "User tag: ")))
+        (t
+         (format "tags %d %c %s\n"
+                 bugid (if reverse ?- ?+)
+                 message)))))
+    (unless (looking-at-p debbugs-gnu-control-message-end-regexp)
+      (insert "quit\n\n"))))
+
 
 (defvar debbugs-gnu-usertags-mode-map
   (let ((map (make-sparse-keymap)))
diff --git a/packages/debbugs/debbugs-org.el b/packages/debbugs/debbugs-org.el
index a0e86b730..ecdcaa731 100644
--- a/packages/debbugs/debbugs-org.el
+++ b/packages/debbugs/debbugs-org.el
@@ -82,6 +82,7 @@
 ;; keystrokes:
 
 ;;   "C-c # C": Send a debbugs control message
+;;   "C-c # E": Make (but don't yet send) a debbugs control message
 ;;   "C-c # t": Mark the bug locally as tagged
 ;;   "C-c # d": Show bug attributes
 
@@ -293,6 +294,7 @@ (defconst debbugs-org-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "C-c # t") 'debbugs-gnu-toggle-tag)
     (define-key map (kbd "C-c # C") 'debbugs-gnu-send-control-message)
+    (define-key map (kbd "C-c # E") 'debbugs-gnu-make-control-message)
     (define-key map (kbd "C-c # d") 'debbugs-gnu-display-status)
     map)
   "Keymap for the `debbugs-org-mode' minor mode.")
diff --git a/packages/debbugs/debbugs-ug.texi b/packages/debbugs/debbugs-ug.texi
index 0a335129d..d7d94ec41 100644
--- a/packages/debbugs/debbugs-ug.texi
+++ b/packages/debbugs/debbugs-ug.texi
@@ -426,6 +426,13 @@ Toggle showing of closed bugs.
 @code{debbugs-gnu-send-control-message} @*
 Send a control message for this bug, @ref{Control Messages}.
 
+@item
+@kindex @kbd{C}
+@kbd{C} @tab
+@code{debbugs-gnu-make-control-message} @*
+Make (but don't yet send) a control message for this bug, @ref{Control
+Messages}.
+
 @end multitable
 
 @vindex debbugs-gnu-suppress-closed
@@ -482,6 +489,13 @@ Toggle local tag of bugs.
 @code{debbugs-gnu-send-control-message} @*
 Send a control message for this bug, @ref{Control Messages}.
 
+@item
+@kindex @kbd{C-c # E}
+@kbd{C-c # E} @tab
+@code{debbugs-gnu-make-control-message} @*
+Make (but don't yet send) a control message for this bug, @ref{Control
+Messages}.
+
 @end multitable
 
 When the bug attributes are shown by @code{org-cycle}, there is a link
@@ -550,6 +564,14 @@ If the command invoking the control message has been prefixed with
 The second argument in the close message, the Emacs version, is read
 interactively if the bug belongs to the @code{"emacs"} package.
 
+@item found
+@itemx notfound
+@itemx fixed
+"found|notfound|fixed 12345 25.1"
+
+The second argument, the Emacs version, is read interactively if the
+bug belongs to the @code{"emacs"} package.
+
 @item forwarded
 "forwarded 12345 @var{address}"
 
@@ -606,6 +628,11 @@ The new bug title is read interactively.
 
 The username, read interactively, is either a package name or an email
 address.  The tag to be set is also read interactively.
+
+@item documentation
+"user emacs" @*
+"usertag 12345 documentation"
+
 @end table
 
 @vindex debbugs-gnu-send-mail-function
-- 
2.11.0


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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-03-31 21:27       ` Noam Postavsky
@ 2019-04-01  7:35         ` Michael Albinus
  2019-04-01 13:34           ` Noam Postavsky
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Albinus @ 2019-04-01  7:35 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33225, garreau, alexandre

Noam Postavsky <npostavs@gmail.com> writes:

Hi Noam,

> I've updated according to your comments, I'll wait another couple of
> days before pushing in case we can catch any more silly mistakes.

It looks almost good. Still some minor nits :-)

> Regarding making a release, I have in mind next to bring in my commands
> which produce control messages from git commits (both for attaching
> proposed patches from an unpushed commit, and closing from a pushed
> one).  Perhaps you want to wait for that before making a new release?
> (or perhaps just the opposite, not sure what your release policy is)

My release policy is very simple: gut feeling. I have no pending issue
to solve, so we could wait for the release.

I'd prefer if you would commit your changes so far, that we have a
common base, and further patches you'll show are shorter (to review).

> +        ((member message '("unarchive" "unmerge" "noowner"
> +                           "notfixed" "notforwarded"))
> +         (format "%s %d\n" message bugid))

You have (correctly) said, that "notfixed" isn't documented on
debbugs.gnu.org. So I have checked
<https://www.debian.org/Bugs/server-control#notfixed>. "notfixed"
requires also a version number, it should be moved to the handling of

> +        ((member message '("found" "notfound" "fixed"))
> +         (format "%s %d %s\n" message bugid version))

> +@item
> +@kindex @kbd{C}
> +@kbd{C} @tab
> +@code{debbugs-gnu-make-control-message} @*


This shall be {E}

> +@item found
> +@itemx notfound
> +@itemx fixed
> +"found|notfound|fixed 12345 25.1"

Please add notfixed.

Best regards, Michael.





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-04-01  7:35         ` Michael Albinus
@ 2019-04-01 13:34           ` Noam Postavsky
  2019-04-01 14:52             ` Michael Albinus
  0 siblings, 1 reply; 17+ messages in thread
From: Noam Postavsky @ 2019-04-01 13:34 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 33225, garreau, alexandre

[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]

Michael Albinus <michael.albinus@gmx.de> writes:
>
>> Regarding making a release, I have in mind next to bring in my commands
>> which produce control messages from git commits (both for attaching
>> proposed patches from an unpushed commit, and closing from a pushed
>> one).  Perhaps you want to wait for that before making a new release?
>> (or perhaps just the opposite, not sure what your release policy is)
>
> My release policy is very simple: gut feeling. I have no pending issue
> to solve, so we could wait for the release.
>
> I'd prefer if you would commit your changes so far, that we have a
> common base, and further patches you'll show are shorter (to review).

Yes, I would open a new bug thread for the feature I mention above,
after this is one is closed and pushed.

>> +        ((member message '("unarchive" "unmerge" "noowner"
>> +                           "notfixed" "notforwarded"))
>> +         (format "%s %d\n" message bugid))
>
> You have (correctly) said, that "notfixed" isn't documented on
> debbugs.gnu.org. So I have checked
> <https://www.debian.org/Bugs/server-control#notfixed>. "notfixed"
> requires also a version number [...]

Huh, indeed.  Not sure how I messed that up.  I even have it correct in
my .emacs.d/, so it seems something went wrong while moving it to
debbugs-gnu.el.

>> +@item
>> +@kindex @kbd{C}
>> +@kbd{C} @tab
>> +@code{debbugs-gnu-make-control-message} @*
>
>
> This shall be {E}

Right.

>> +@item found
>> +@itemx notfound
>> +@itemx fixed
>> +"found|notfound|fixed 12345 25.1"
>
> Please add notfixed.

Done.  Hmm, I just noticed that we have "@itemx fixed" in two places.
So there is a conflict between "fixed" as a tag, and "fixed" as its own
command.  I think the command should precedence (that was already the
case in the code for previous patches, now I've updated the doc as
well).

One last thing I noticed when byte-compiling from emacs -Q, is that I
needed to add a couple of autoloads for the message functions.  And then
I realized that the message-narrow-to-head call should actually be
message-narrow-to-headers, since the latter looks for
mail-header-separator, while the former just looks for a blank line (in
practice, it doesn't make much difference unless the message body
happens to have text that looks like a mail header).


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 21818 bytes --]

From 3ceceef29252c5f3eaa4e4406a154929784f86e6 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@users.sourceforge.net>
Date: Thu, 1 Nov 2018 08:03:57 -0400
Subject: [PATCH v4] New command debbugs-control-make-message (Bug#33225)

Add new command debbugs-control-make-message which is like
debbugs-gnu-send-control-message, but doesn't send the message
immediately.
* packages/debbugs/debbugs-ug.texi: Document additional keybinding and
control message keywords: "found", "notfound", "notfixed", and
"documentation".  Note that "fixed" now corresponds to "fixed <bug>
<version>" rather than "tag <bug> fixed".
* packages/debbugs/debbugs-gnu.el (debbugs-control-message-keywords):
(debbugs-gnu-control-message-commands-regexp)
(debbugs-gnu-control-message-end-regexp): New constants.
(debbugs-gnus-implicit-ids): New function.
(debbugs-gnu-make-control-message): New command.
(debbugs-gnu-send-control-message): Move guts to new command.
(debbugs-gnu-mode-map, debbugs-read-emacs-bug-with-rmail)
(debbugs-gnu-summary-mode-map)
* packages/debbugs/debbugs-org.el (debbugs-org-mode-map): Bind
debbugs-gnu-make-control-message to "E".
---
 packages/debbugs/debbugs-gnu.el  | 336 ++++++++++++++++++++++++++-------------
 packages/debbugs/debbugs-org.el  |   2 +
 packages/debbugs/debbugs-ug.texi |  31 +++-
 3 files changed, 254 insertions(+), 115 deletions(-)

diff --git a/packages/debbugs/debbugs-gnu.el b/packages/debbugs/debbugs-gnu.el
index aa584b248..192f0aeb1 100644
--- a/packages/debbugs/debbugs-gnu.el
+++ b/packages/debbugs/debbugs-gnu.el
@@ -91,6 +91,7 @@
 
 ;;   RET: Show corresponding messages in Gnus/Rmail
 ;;   "C": Send a control message
+;;   "E": Make (but don't yet send) a control message
 ;;   "t": Mark the bug locally as tagged
 ;;   "b": Show bugs this bug is blocked by
 ;;   "B": Show bugs this bug is blocking
@@ -107,7 +108,8 @@
 ;;   "w": Display all the currently selected bug reports
 
 ;; When you visit the related bug messages in Gnus or Rmail, you could
-;; also send control messages by keystroke "C".
+;; also send or make control messages by keystroke "C" or "E" in the
+;; message summary buffer.
 
 ;; In the header line of every bug list page, you can toggle sorting
 ;; per column by selecting a column with the mouse.  The sorting
@@ -170,6 +172,8 @@ (autoload 'log-edit-insert-changelog "log-edit")
 (autoload 'mail-header-subject "nnheader")
 (autoload 'message-goto-body "message")
 (autoload 'message-make-from "message")
+(autoload 'message-narrow-to-headers "message")
+(autoload 'message-add-header "message")
 (autoload 'rmail-get-new-mail "rmail")
 (autoload 'rmail-show-message "rmail")
 (autoload 'rmail-summary "rmailsum")
@@ -917,6 +921,7 @@ (defvar debbugs-gnu-mode-map
     (define-key map "g" 'debbugs-gnu-rescan)
     (define-key map "R" 'debbugs-gnu-show-all-blocking-reports)
     (define-key map "C" 'debbugs-gnu-send-control-message)
+    (define-key map "E" 'debbugs-gnu-make-control-message)
 
     (define-key map "s" 'debbugs-gnu-toggle-sort)
     (define-key map "t" 'debbugs-gnu-toggle-tag)
@@ -1324,9 +1329,11 @@ (defun debbugs-read-emacs-bug-with-rmail (id status merged)
 	 (format "Re: bug#%d: %s" id (cdr (assq 'subject status))))
     (rmail-summary)
     (define-key rmail-summary-mode-map "C" 'debbugs-gnu-send-control-message)
+    (define-key rmail-summary-mode-map "E" 'debbugs-gnu-make-control-message)
     (set-window-text-height nil 10)
     (other-window 1)
     (define-key rmail-mode-map "C" 'debbugs-gnu-send-control-message)
+    (define-key rmail-mode-map "E" 'debbugs-gnu-make-control-message)
     (rmail-show-message 1)))
 
 (defcustom debbugs-gnu-lars-workflow nil
@@ -1375,6 +1382,7 @@ (defun debbugs-gnu-select-report ()
 (defvar debbugs-gnu-summary-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "C" 'debbugs-gnu-send-control-message)
+    (define-key map "E" 'debbugs-gnu-make-control-message)
     (define-key map [(meta m)] 'debbugs-gnu-apply-patch)
     map))
 
@@ -1472,6 +1480,37 @@ (defun debbugs-gnu-expand-bug-number-list (bug-number-list)
 	       (number-sequence (string-to-number from) (string-to-number to)))
 	      result))))))))
 
+
+(defconst debbugs-gnu-control-message-keywords
+  '("serious" "important" "normal" "minor" "wishlist"
+    "done" "donenotabug" "donewontfix" "doneunreproducible"
+    "invalid" ; done+notabug+wontfix
+    "unarchive" "unmerge" "reopen" "close"
+    "merge" "forcemerge"
+    "block" "unblock"
+    "owner" "noowner"
+    "reassign"
+    "retitle"
+    "forwarded" "notforwarded"
+    ;; 'notfixed <bugnum> <version>' works, even though it's
+    ;; undocumented at debbugs.gnu.org.
+    "fixed" "found" "notfound" "notfixed"
+    "patch" "wontfix" "moreinfo" "unreproducible" "notabug"
+    "pending" "help" "security" "confirmed" "easy"
+    "usertag"
+    "documentation" ;; usertag:emacs.documentation
+    ))
+
+(defconst debbugs-gnu-control-message-commands-regexp
+  (concat "^" (regexp-opt (cl-list* "#" "tags" "severity" "user"
+                                    debbugs-gnu-control-message-keywords))
+          " .*$"))
+
+(defconst debbugs-gnu-control-message-end-regexp
+  (concat "^" (regexp-opt '("--" "quit" "stop"
+                            "thank" "thanks" "thankyou" "thank you"))
+          "$"))
+
 (defun debbugs-gnu-send-control-message (message &optional reverse)
   "Send a control message for the current bug report.
 You can set the severity or add a tag, or close the report.  If
@@ -1482,124 +1521,195 @@ (defun debbugs-gnu-send-control-message (message &optional reverse)
 removed instead."
   (interactive
    (list (completing-read
-	  "Control message: "
-	  '("serious" "important" "normal" "minor" "wishlist"
-	    "done" "donenotabug" "donewontfix" "doneunreproducible"
-	    "unarchive" "unmerge" "reopen" "close"
-	    "merge" "forcemerge"
-	    "block" "unblock"
-	    "owner" "noowner"
-	    "forwarded" "notforwarded"
-	    "invalid"
-	    "reassign"
-	    "retitle"
-	    "patch" "wontfix" "moreinfo" "unreproducible" "fixed" "notabug"
-	    "pending" "help" "security" "confirmed" "easy"
-	    "usertag")
-	  nil t)
+          "Control message: " debbugs-gnu-control-message-keywords nil t)
 	 current-prefix-arg))
-  (let* ((id (or (debbugs-gnu-current-id t)
-		 debbugs-gnu-bug-number	; Set on group entry.
-		 (debbugs-gnu-guess-current-id)))
-	 (status (debbugs-gnu-current-status))
-	 (version
-	  (when (and
-		 (member message '("close" "done"))
-		 (member "emacs" (cdr (assq 'package status))))
-	    (read-string
-	     "Version: "
-	     (cond
-	      ;; Emacs development versions.
-	      ((if (boundp 'emacs-build-number)
-		   (string-match
-		    "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version)
-		 (string-match
-		  "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\." emacs-version))
-	       (format "%s.%d"
-		       (match-string 1 emacs-version)
-		       (1+ (string-to-number (match-string 2 emacs-version)))))
-	      ;; Emacs release versions.
-	      ((if (boundp 'emacs-build-number)
-		   (string-match
-		    "^\\([0-9]+\\)\\.\\([0-9]+\\)$" emacs-version)
-		 (string-match
-		  "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)$" emacs-version))
-	       (format "%s.%s"
-		       (match-string 1 emacs-version)
-		       (match-string 2 emacs-version)))
-	      (t emacs-version))))))
+  (let ((id (or (debbugs-gnu-current-id t)
+                debbugs-gnu-bug-number       ; Set on group entry.
+                (debbugs-gnu-guess-current-id))))
     (with-temp-buffer
-      (insert "To: control@debbugs.gnu.org\n"
-	      "From: " (message-make-from) "\n"
-	      (format "Subject: control message for bug #%d\n" id)
-	      mail-header-separator
-	      "\n"
-	      (cond
-	       ((member message '("unarchive" "unmerge" "reopen"
-				  "noowner" "notforwarded"))
-		(format "%s %d\n" message id))
-	       ((member message '("merge" "forcemerge"))
-		(format
-		 "%s %d %s\n" message id
-		 (mapconcat
-		  'identity
-		  (debbugs-gnu-expand-bug-number-list
-		   (completing-read-multiple
-		    (format "%s with bug(s) #: " (capitalize message))
-		    debbugs-gnu-completion-table))
-		  " ")))
-	       ((member message '("block" "unblock"))
-		(format
-		 "%s %d by %s\n" message id
-		 (mapconcat
-		  'identity
-		  (debbugs-gnu-expand-bug-number-list
-		   (completing-read-multiple
-		    (format "%s with bug(s) #: " (capitalize message))
-		    (if (equal message "unblock")
-			(mapcar 'number-to-string
-				(cdr (assq 'blockedby status)))
-		      debbugs-gnu-completion-table)
-		    nil (and (equal message "unblock") status)))
-		  " ")))
-	       ((equal message "owner")
-		(format "owner %d !\n" id))
-	       ((equal message "retitle")
-		(format "retitle %d %s\n" id (read-string "New title: ")))
-	       ((equal message "reassign")
-		(format "reassign %d %s\n" id (read-string "Package(s): ")))
-	       ((equal message "forwarded")
-		(format "forwarded %d %s\n" id (read-string "Forwarded to: ")))
-	       ((equal message "close")
-		(format "close %d %s\n" id (or version "")))
-	       ((equal message "done")
-		(format "tags %d fixed\nclose %d %s\n" id id (or version "")))
-	       ((member message '("donenotabug" "donewontfix"
-				  "doneunreproducible"))
-		(format "tags %d %s\nclose %d\n" id (substring message 4) id))
-	       ((member message '("serious" "important" "normal"
-				  "minor" "wishlist"))
-		(format "severity %d %s\n" id message))
-	       ((equal message "invalid")
-		(format "tags %d notabug\ntags %d wontfix\nclose %d\n"
-			id id id))
-	       ((equal message "usertag")
-		(format "user %s\nusertag %d %s\n"
-			(completing-read
-			 "Package name or email address: "
-			 (append
-			  debbugs-gnu-all-packages (list user-mail-address))
-			 nil nil (car debbugs-gnu-default-packages))
-			id (read-string "User tag: ")))
-	       (t
-		(format "tags %d%s %s\n"
-			id (if reverse " -" "")
-			message))))
+      (debbugs-gnu-make-control-message
+       message id reverse (current-buffer))
       (funcall (or debbugs-gnu-send-mail-function send-mail-function))
       (remhash id debbugs-cache-data)
       (message-goto-body)
       (message "Control message sent:\n%s"
-	       (buffer-substring-no-properties (point) (1- (point-max)))))))
+               (buffer-substring-no-properties (point) (1- (point-max)))))))
+
+(defun debbugs-gnus-implicit-ids ()
+  "Return a list of bug IDs guessed from the current buffer."
+  (delq nil (delete-dups
+             (list (debbugs-gnu-current-id t)
+                   debbugs-gnu-bug-number ; Set on group entry.
+                   (debbugs-gnu-guess-current-id)
+                   (let ((bugnum-re "\\([0-9]+\\)\\(?:-done\\)?@debbugs.gnu.org"))
+                     (when (derived-mode-p 'message-mode)
+                       (save-excursion
+                         (save-restriction
+                           (message-narrow-to-headers)
+                           (or (let ((addr (message-fetch-field "to")))
+                                 (and addr (string-match bugnum-re addr)
+                                      (string-to-number (match-string 1 addr))))
+                               (let ((addr (message-fetch-field "cc")))
+                                 (and addr (string-match bugnum-re addr)
+                                      (string-to-number (match-string 1 addr)))))))))))))
+
+(defun debbugs-gnu-make-control-message (message bugid &optional reverse buffer)
+  "Make a control message for the current bug report.
+The message is inserted into BUFFER, and mail headers are adjust
+so that it will be sent to control@debbugs.gnu.org (via Bcc if
+there is already a To address).  If BUFFER omitted, create and
+display a new buffer.
+
+When called interactively, choose the current buffer if it is in
+`message-mode', or create a new buffer otherwise.
+
+You can set the severity or add a tag, or close the report.  If
+you use the special \"done\" MESSAGE, the report will be marked as
+fixed, and then closed.
+
+If given a prefix, and given a tag to set, the tag will be
+removed instead."
+  (interactive
+   (save-excursion                 ; Point can change while prompting!
+     (list (completing-read
+            "Control message: " debbugs-gnu-control-message-keywords nil t)
+           (let* ((implicit-ids (mapcar #'prin1-to-string
+                                        (debbugs-gnus-implicit-ids)))
+                  (default-id (car implicit-ids)))
+             (string-to-number
+              (completing-read (if default-id
+                                   (format "Bug #ID (default %s): " default-id)
+                                 "Bug #ID: ")
+                               implicit-ids
+                               (lambda (s) (string-match-p "\\`[0-9]+\\'" s))
+                               nil nil nil (car implicit-ids))))
+           current-prefix-arg
+           (when (derived-mode-p 'message-mode)
+             (current-buffer)))))
+  (let* ((status (debbugs-gnu-current-status))
+         (version
+          (when (and
+                 (member message '("close" "done"
+                                   "fixed" "notfixed" "found" "notfound"))
+                 (member "emacs" (cdr (assq 'package status))))
+            (save-excursion
+              (read-string
+               "Version: "
+               (pcase (nbutlast (version-to-list emacs-version)
+                                ;; Chop off build number, if needed.
+                                (if (boundp 'emacs-build-number)
+                                    0
+                                  1))
+                 (`(,major ,minor ,_micro) ; Development version.
+                  (format "%d.%d" major
+                          (if (member message '("notfixed" "found" "notfound"))
+                              minor
+                            (1+ minor))))
+                 (`(,major ,minor)      ; Release version.
+                  (format "%d.%d" major minor))
+                 ;; Unexpected version format?
+                 (_ emacs-version)))))))
+    (unless buffer
+      (setq buffer
+            (pop-to-buffer
+             (get-buffer-create
+              (format "*Debbugs Control Message for #%d*" bugid)))))
+    (set-buffer buffer)
+    (when (= (buffer-size) 0)
+      (insert "To: control@debbugs.gnu.org\n"
+              "From: " (message-make-from) "\n"
+              (format "Subject: control message for bug #%d\n" bugid)
+              mail-header-separator
+              "\n"))
+    (unless (or (derived-mode-p 'message-mode)
+                ;; `message-mode' associates buffer with file, we
+                ;; don't want to do that for temp buffers.
+                (eq (aref (buffer-name) 0) ?\s))
+      (message-mode))
+    (save-restriction
+      (message-narrow-to-headers)
+      (let* ((ctrl-addr "control@debbugs.gnu.org")
+             (ctrl-re (regexp-quote ctrl-addr))
+             (to-addr (message-fetch-field "to"))
+             (bcc-addr (message-fetch-field "bcc")))
+        (unless (or (and  to-addr (string-match-p ctrl-re to-addr))
+                    (and bcc-addr (string-match-p ctrl-re bcc-addr)))
+          (message-add-header
+           (format "%s: %s" (if to-addr "Bcc" "To") ctrl-addr)))))
+    (message-goto-body)
+    (while (looking-at-p debbugs-gnu-control-message-commands-regexp)
+      (forward-line))
+    (insert
+     (save-excursion             ; Point can change while prompting!
+       (cond
+        ((member message '("unarchive" "unmerge" "noowner" "notforwarded"))
+         (format "%s %d\n" message bugid))
+        ((equal message "reopen")
+         (format "reopen %d\ntag %d - fixed patch\n" bugid bugid))
+        ((member message '("merge" "forcemerge"))
+         (format
+          "%s %d %s\n" message bugid
+          (mapconcat
+           'identity
+           (debbugs-gnu-expand-bug-number-list
+            (completing-read-multiple
+             (format "%s with bug(s) #: " (capitalize message))
+             debbugs-gnu-completion-table))
+           " ")))
+        ((member message '("block" "unblock"))
+         (format
+          "%s %d by %s\n" message bugid
+          (mapconcat
+           'identity
+           (debbugs-gnu-expand-bug-number-list
+            (completing-read-multiple
+             (format "%s with bug(s) #: " (capitalize message))
+             (if (equal message "unblock")
+                 (mapcar 'number-to-string
+                         (cdr (assq 'blockedby status)))
+               debbugs-gnu-completion-table)
+             nil (and (equal message "unblock") status)))
+           " ")))
+        ((equal message "owner")
+         (format "owner %d !\n" bugid))
+        ((equal message "retitle")
+         (format "retitle %d %s\n" bugid (read-string "New title: ")))
+        ((equal message "forwarded")
+         (format "forwarded %d %s\n" bugid (read-string "Forward to: ")))
+        ((equal message "reassign")
+         (format "reassign %d %s\n" bugid (read-string "Package(s): ")))
+        ((equal message "close")
+         (format "close %d %s\n" bugid (or version "")))
+        ((equal message "done")
+         (format "tags %d fixed\nclose %d %s\n" bugid bugid version))
+        ((member message '("found" "notfound" "fixed" "notfixed"))
+         (format "%s %d %s\n" message bugid version))
+        ((member message '("donenotabug" "donewontfix"
+                           "doneunreproducible"))
+         (format "tags %d %s\nclose %d\n" bugid (substring message 4) bugid))
+        ((member message '("serious" "important" "normal"
+                           "minor" "wishlist"))
+         (format "severity %d %s\n" bugid message))
+        ((equal message "invalid")
+         (format "tags %d notabug wontfix\nclose %d\n"
+                 bugid bugid))
+        ((equal message "documentation")
+         (format "user emacs\nusertag %d %s\n" bugid "documentation"))
+        ((equal message "usertag")
+         (format "user %s\nusertag %d %s\n"
+                 (completing-read
+                  "Package name or email address: "
+                  (append
+                   debbugs-gnu-all-packages (list user-mail-address))
+                  nil nil (car debbugs-gnu-default-packages))
+                 bugid (read-string "User tag: ")))
+        (t
+         (format "tags %d %c %s\n"
+                 bugid (if reverse ?- ?+)
+                 message)))))
+    (unless (looking-at-p debbugs-gnu-control-message-end-regexp)
+      (insert "quit\n\n"))))
+
 
 (defvar debbugs-gnu-usertags-mode-map
   (let ((map (make-sparse-keymap)))
diff --git a/packages/debbugs/debbugs-org.el b/packages/debbugs/debbugs-org.el
index a0e86b730..ecdcaa731 100644
--- a/packages/debbugs/debbugs-org.el
+++ b/packages/debbugs/debbugs-org.el
@@ -82,6 +82,7 @@
 ;; keystrokes:
 
 ;;   "C-c # C": Send a debbugs control message
+;;   "C-c # E": Make (but don't yet send) a debbugs control message
 ;;   "C-c # t": Mark the bug locally as tagged
 ;;   "C-c # d": Show bug attributes
 
@@ -293,6 +294,7 @@ (defconst debbugs-org-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "C-c # t") 'debbugs-gnu-toggle-tag)
     (define-key map (kbd "C-c # C") 'debbugs-gnu-send-control-message)
+    (define-key map (kbd "C-c # E") 'debbugs-gnu-make-control-message)
     (define-key map (kbd "C-c # d") 'debbugs-gnu-display-status)
     map)
   "Keymap for the `debbugs-org-mode' minor mode.")
diff --git a/packages/debbugs/debbugs-ug.texi b/packages/debbugs/debbugs-ug.texi
index 0a335129d..2bb01d2c2 100644
--- a/packages/debbugs/debbugs-ug.texi
+++ b/packages/debbugs/debbugs-ug.texi
@@ -426,6 +426,13 @@ Toggle showing of closed bugs.
 @code{debbugs-gnu-send-control-message} @*
 Send a control message for this bug, @ref{Control Messages}.
 
+@item
+@kindex @kbd{E}
+@kbd{E} @tab
+@code{debbugs-gnu-make-control-message} @*
+Make (but don't yet send) a control message for this bug, @ref{Control
+Messages}.
+
 @end multitable
 
 @vindex debbugs-gnu-suppress-closed
@@ -482,6 +489,13 @@ Toggle local tag of bugs.
 @code{debbugs-gnu-send-control-message} @*
 Send a control message for this bug, @ref{Control Messages}.
 
+@item
+@kindex @kbd{C-c # E}
+@kbd{C-c # E} @tab
+@code{debbugs-gnu-make-control-message} @*
+Make (but don't yet send) a control message for this bug, @ref{Control
+Messages}.
+
 @end multitable
 
 When the bug attributes are shown by @code{org-cycle}, there is a link
@@ -522,7 +536,6 @@ bug belongs to the @code{"emacs"} package.
 
 @item confirmed
 @itemx easy
-@itemx fixed
 @itemx help
 @itemx moreinfo
 @itemx notabug
@@ -531,7 +544,7 @@ bug belongs to the @code{"emacs"} package.
 @itemx security
 @itemx unreproducible
 @itemx wontfix
-"tags 12345 confirmed|easy|fixed|help|moreinfo|notabug"
+"tags 12345 confirmed|easy|help|moreinfo|notabug"
 
 "tags 12345 patch|pending|security|unreproducible|wontfix"
 
@@ -550,6 +563,15 @@ If the command invoking the control message has been prefixed with
 The second argument in the close message, the Emacs version, is read
 interactively if the bug belongs to the @code{"emacs"} package.
 
+@item found
+@itemx notfound
+@itemx fixed
+@itemx notfixed
+"found|notfound|fixed|notfixed 12345 25.1"
+
+The second argument, the Emacs version, is read interactively if the
+bug belongs to the @code{"emacs"} package.
+
 @item forwarded
 "forwarded 12345 @var{address}"
 
@@ -606,6 +628,11 @@ The new bug title is read interactively.
 
 The username, read interactively, is either a package name or an email
 address.  The tag to be set is also read interactively.
+
+@item documentation
+"user emacs" @*
+"usertag 12345 documentation"
+
 @end table
 
 @vindex debbugs-gnu-send-mail-function
-- 
2.11.0


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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-04-01 13:34           ` Noam Postavsky
@ 2019-04-01 14:52             ` Michael Albinus
  2019-04-01 22:47               ` Noam Postavsky
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Albinus @ 2019-04-01 14:52 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33225, garreau, alexandre

Noam Postavsky <npostavs@gmail.com> writes:

Hi Noam,

>> I'd prefer if you would commit your changes so far, that we have a
>> common base, and further patches you'll show are shorter (to review).
>
> Yes, I would open a new bug thread for the feature I mention above,
> after this is one is closed and pushed.

OK.

>>> +@item found
>>> +@itemx notfound
>>> +@itemx fixed
>>> +"found|notfound|fixed 12345 25.1"
>>
>> Please add notfixed.
>
> Done.  Hmm, I just noticed that we have "@itemx fixed" in two places.
> So there is a conflict between "fixed" as a tag, and "fixed" as its own
> command.  I think the command should precedence (that was already the
> case in the code for previous patches, now I've updated the doc as
> well).

OK.

> One last thing I noticed when byte-compiling from emacs -Q, is that I
> needed to add a couple of autoloads for the message functions.  And then
> I realized that the message-narrow-to-head call should actually be
> message-narrow-to-headers, since the latter looks for
> mail-header-separator, while the former just looks for a blank line (in
> practice, it doesn't make much difference unless the message body
> happens to have text that looks like a mail header).

That was also on my todo list. I'm glad if you fix it (but, as finical
German, I prefer to insert them in alphabetical order).

There's nothing left I could nitpick, so pls commit :-)

Thanks, and best regards, Michael.





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-04-01 14:52             ` Michael Albinus
@ 2019-04-01 22:47               ` Noam Postavsky
  2019-04-01 22:59                 ` Noam Postavsky
  2019-04-02  5:52                 ` Michael Albinus
  0 siblings, 2 replies; 17+ messages in thread
From: Noam Postavsky @ 2019-04-01 22:47 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 33225, garreau, alexandre

tags 33225 fixed
close 33225
quit

Michael Albinus <michael.albinus@gmx.de> writes:

> That was also on my todo list. I'm glad if you fix it (but, as finical
> German, I prefer to insert them in alphabetical order).
>
> There's nothing left I could nitpick, so pls commit :-)

Okay, sorted and pushed.

[1: be4e402f9]: 2019-04-01 18:45:04 -0400
  New command debbugs-control-make-message (Bug#33225)
  https://git.savannah.gnu.org/cgit/emacs/elpa.git/commit/?id=be4e402f92ba3c2326f0f71afdcc5dde66546624





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-04-01 22:47               ` Noam Postavsky
@ 2019-04-01 22:59                 ` Noam Postavsky
  2019-04-02  5:52                 ` Michael Albinus
  1 sibling, 0 replies; 17+ messages in thread
From: Noam Postavsky @ 2019-04-01 22:59 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 33225, garreau, alexandre


>> There's nothing left I could nitpick, so pls commit :-)
>
> Okay, sorted and pushed.
>
> [1: be4e402f9]: 2019-04-01 18:45:04 -0400
>   New command debbugs-control-make-message (Bug#33225)
>   https://git.savannah.gnu.org/cgit/emacs/elpa.git/commit/?id=be4e402f92ba3c2326f0f71afdcc5dde66546624

Ugh, of course I discover a mistake just after pushing (in fact, while
using it to create the previous message).  I forgot to check for a nil
version in a couple of cases.

[2: 54678808c]: 2019-04-01 18:54:10 -0400
  Fix previous change for version-less commands
  https://git.savannah.gnu.org/cgit/emacs/elpa.git/commit/?id=54678808cdb18da080553e18ce5d806cd1659c82





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

* bug#33225: [debbugs.el] Don't send control message immediately
  2019-04-01 22:47               ` Noam Postavsky
  2019-04-01 22:59                 ` Noam Postavsky
@ 2019-04-02  5:52                 ` Michael Albinus
  1 sibling, 0 replies; 17+ messages in thread
From: Michael Albinus @ 2019-04-02  5:52 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33225, garreau, alexandre

Noam Postavsky <npostavs@gmail.com> writes:

> Okay, sorted and pushed.

Thanks!

Best regards, Michael.





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

end of thread, other threads:[~2019-04-02  5:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-01 12:29 bug#33225: [debbugs.el] Don't send control message immediately Noam Postavsky
2018-11-01 14:28 ` Garreau, Alexandre
2018-11-02 10:30   ` Michael Albinus
2018-11-02 10:23 ` Michael Albinus
2019-01-04 14:38   ` Michael Albinus
2019-02-27  8:45     ` Michael Albinus
2019-02-28  1:10       ` Noam Postavsky
2019-02-28  7:10         ` Michael Albinus
2019-03-30  2:43   ` Noam Postavsky
2019-03-31 10:21     ` Michael Albinus
2019-03-31 21:27       ` Noam Postavsky
2019-04-01  7:35         ` Michael Albinus
2019-04-01 13:34           ` Noam Postavsky
2019-04-01 14:52             ` Michael Albinus
2019-04-01 22:47               ` Noam Postavsky
2019-04-01 22:59                 ` Noam Postavsky
2019-04-02  5:52                 ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).