From 6788d7b01528ebe2d6d6c4b93f24db175b5ab1e7 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 29 Sep 2021 18:44:41 +0200 Subject: [PATCH] Make `M-q' in message-mode work better * lisp/gnus/message.el (message-newline-and-reformat): Fix bug#43299 differently. (message-newline-and-reformat): Revert change for bug#43299. This fixes bug#50842. --- lisp/gnus/message.el | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 4a754b98569..f51f5c0dd0d 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -3572,8 +3572,18 @@ Prefix arg means justify as well." (when (looking-at message-cite-prefix-regexp) (setq quoted (match-string 0)) (goto-char (match-end 0)) - (looking-at "[ \t]*") - (setq leading-space (match-string 0))) + (let ((after (point))) + ;; This is a line with no text after the cite prefix. In that + ;; case, the trailing space is commonly not present, so look + ;; around for other lines that have some data. + (when (looking-at-p "\n") + (let ((regexp (concat "^" message-cite-prefix-regexp "."))) + (when (or (re-search-backward regexp nil t) + (re-search-forward regexp nil t)) + (goto-char (1- (match-end 0)))))) + (looking-at "[ \t]*") + (setq leading-space (match-string 0)) + (goto-char after))) (if (and quoted (not not-break) (not bolp) @@ -3590,7 +3600,7 @@ Prefix arg means justify as well." (equal quoted (match-string 0))) (goto-char (match-end 0)) (looking-at "[ \t]*") - (when (< (length leading-space) (length (match-string 0))) + (when (> (length leading-space) (length (match-string 0))) (setq leading-space (match-string 0))) (forward-line 1)) (setq end (point)) -- 2.39.5