From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 29 09:19:03 2025 Received: (at submit) by debbugs.gnu.org; 29 Mar 2025 13:19:03 +0000 Received: from localhost ([127.0.0.1]:57509 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tyW5W-0000Nb-NT for submit@debbugs.gnu.org; Sat, 29 Mar 2025 09:19:03 -0400 Received: from lists.gnu.org ([2001:470:142::17]:33918) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tyW5Q-0000Mz-Tv for submit@debbugs.gnu.org; Sat, 29 Mar 2025 09:18:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tyW5K-0001Gv-PO for bug-gnu-emacs@gnu.org; Sat, 29 Mar 2025 09:18:50 -0400 Received: from ledu-giraud.fr ([51.159.28.247]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tyW5I-0008M2-4C for bug-gnu-emacs@gnu.org; Sat, 29 Mar 2025 09:18:50 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=M59mbk1f BjVnCewpDja2BkOFq1ZxEMfUwrMC4FwXBm4=; h=date:subject:to:from; d=ledu-giraud.fr; b=zoOeJ4MsAxaAplvY/fsvR88RjfgYxIQdZDjmlYJlA2uwi7euqD 15DMR58x8n9gozRl7NQqK/cAeFHwmQhDSgDQ== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=M59mbk1fBjVnCewp Dja2BkOFq1ZxEMfUwrMC4FwXBm4=; h=date:subject:to:from; d=ledu-giraud.fr; b=Z1fkBtw7K8sJ3q4Og9Bdg31gsgk48GpgFTMFgBcM7J6gmLGGwi AKFfBUjcuTrq5GNQ90pc7bUAt5E0CZwqmCRb0TDC/ChKpNu/JtdA6gTDd9N/sKFb0CQB8E LTTz0aiMGLDXiVamdLAQNFFi4RpSOCt+yInpzPBA9cNtSgtcDedGetxwEcvMCEEB8WBQEb RSBuDUUgIjjDMSu3Ur0U+pVM1cWs6KEudr6+wYgEiiLtrT3rW0gXFyGAO/UP0ZBilZ7Azj dCjQlh7DLKy0rXmCQ2ylmo7EeAoGoHAqBJWHGzwDTtLTJMhRESesfqIg3m/5zwolDKvYpw Z7Q9wTbxPxEQ== Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 38b3e2ac (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Sat, 29 Mar 2025 14:18:45 +0100 (CET) From: Manuel Giraud To: bug-gnu-emacs@gnu.org Subject: [PATCH] Remove bogus citation quote X-Debbugs-Cc: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= , Lars Magne Ingebrigtsen Date: Sat, 29 Mar 2025 14:18:43 +0100 Message-ID: <877c48rn4c.fsf@ledu-giraud.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=51.159.28.247; envelope-from=manuel@ledu-giraud.fr; helo=ledu-giraud.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch Hi, When in message-mode, hitting 'M-RET' in quoted citation and at the end of line will add a bogus new quote on the following line like this (* is the point position): >>> Test* Hit 'M-RET' will result in: >>> Test * >>> This patch removes this quote. I also add some tests to validate `message-newline-and-reformat'. In GNU Emacs 31.0.50 (build 3, x86_64-unknown-openbsd7.7, X toolkit) of 2025-03-29 built on computer Repository revision: eafafb4981c2616fafeedc981e209cff51b564aa Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101016 System Description: OpenBSD computer 7.7 GENERIC.MP#603 amd64 Configured using: 'configure CC=egcc CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib MAKEINFO=gmakeinfo --prefix=/home/manuel/emacs --bindir=/home/manuel/bin --with-x-toolkit=lucid --with-toolkit-scroll-bars=no --without-cairo --without-compress-install' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Remove-bogus-citation-quote.patch >From 506cc507b2541c6f6808affdcaf88d904b5132b3 Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Sat, 29 Mar 2025 12:47:22 +0100 Subject: [PATCH] Remove bogus citation quote * lisp/gnus/message.el (message-newline-and-reformat): Do not add an extra citation quote when formatting at the end of line. * test/lisp/gnus/message-tests.el (message-newline-and-reformat): New formatting test. --- lisp/gnus/message.el | 10 +++++++--- test/lisp/gnus/message-tests.el | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index a7f27fe1021..98f34285063 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -3603,8 +3603,10 @@ message-newline-and-reformat (interactive (list (if current-prefix-arg 'full)) message-mode) (unless (message-in-body-p) (error "This command only works in the body of the message")) - (let (quoted point beg end leading-space bolp fill-paragraph-function) + (let (quoted point beg end leading-space bolp eolp fill-paragraph-function) (setq point (point)) + (end-of-line) + (setq eolp (= (point) point)) (beginning-of-line) (setq beg (point)) (setq bolp (= beg point)) @@ -3658,6 +3660,8 @@ message-newline-and-reformat (setq beg (point)) (goto-char (match-end 0)) (looking-at "[ \t]*") + ;; Avoid a potential infinite loop. + (goto-char beg) (if (> (length leading-space) (length (match-string 0))) (setq leading-space (match-string 0))))) (while (and (not (eobp)) @@ -3683,9 +3687,9 @@ message-newline-and-reformat ;; (newline 2) doesn't mark both newline's as hard, so call ;; newline twice. -jas (newline) - (newline) + (unless eolp (newline)) (delete-region (point) (re-search-forward "[ \t]*")) - (when (and quoted (not bolp)) + (when (and quoted (not bolp) (not eolp)) (insert quoted leading-space))) (undo-boundary) (if quoted diff --git a/test/lisp/gnus/message-tests.el b/test/lisp/gnus/message-tests.el index 7c290486f26..6e517b9a7d0 100644 --- a/test/lisp/gnus/message-tests.el +++ b/test/lisp/gnus/message-tests.el @@ -204,6 +204,31 @@ message-default-buffer-type (kill-buffer buf) (ert-kill-all-test-buffers)))) +(ert-deftest message-newline-and-reformat () + (with-temp-buffer + (unwind-protect + (let (message-auto-save-directory) + (message-mode) + (insert "> Being cited is\n" + "> not so bad\n" + ">> Above won't\n" + ">>> merge") + (re-search-backward "cited") + (forward-word) + (message-newline-and-reformat) + (re-search-forward message-cite-prefix-regexp) + (should (string= " is not so bad" + (buffer-substring-no-properties (point) (pos-eol)))) + (re-search-forward "Above") + (message-newline-and-reformat) + (re-search-forward message-cite-prefix-regexp) + (should (string= " won't" + (buffer-substring-no-properties (point) (pos-eol)))) + (re-search-forward "merge") + (message-newline-and-reformat) + (should-error (re-search-forward message-cite-prefix-regexp))) + (set-buffer-modified-p nil)))) + (provide 'message-mode-tests) ;;; message-tests.el ends here -- 2.49.0 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--