Subject: [PATCH] Make `message-fill-yanked-message' ignore debbugs commands

From: Stefan Kangas <[email-masked]>
Date: Wed, 19 Oct 2022 11:32:09 +0000

Severity: wishlish

I often use `message-fill-yanked-message', but it incorrectly reflows
debbugs control commands in the beginning of the mail.

So this

    close 111
    thanks

becomes

    close 111 thanks

which means I have to manually edit them again to be on separate lines.

I think it would be more convenient if they were ignored, at least when
`debbugs' is installed.  See the attached patch.
From ec9c3d0a96f6aad20d05d23489baead14fc1222b Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Wed, 19 Oct 2022 13:19:48 +0200
Subject: [PATCH] Make message-fill-yanked-message ignore debbugs commands

* lisp/gnus/message.el (message-fill-yanked-message): Ignore debbugs
control commands when the `debbugs' package is installed.
---
 lisp/gnus/message.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index a714e31876..9f4cddd078 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -3918,6 +3918,12 @@ message-fill-yanked-message
   (save-excursion
     (goto-char (point-min))
     (search-forward (concat "\n" mail-header-separator "\n") nil t)
+    ;; Skip debbugs control commands.
+    (when (and (boundp 'debbugs-gnu-control-message-keywords)
+               (boundp 'debbugs-gnu-control-message-end-regexp))
+     (while (looking-at (rx (or (regexp debbugs-gnu-control-message-commands-regexp)
+                                (regexp debbugs-gnu-control-message-end-regexp))))
+       (forward-line 1)))
     (let ((fill-prefix message-yank-prefix))
       (fill-individual-paragraphs (point) (point-max) justifyp))))
 
-- 
2.35.1