Re: bug#74518: 29.4; ERC 5.6: `undo' regression on Erc 5.6

"J.P." <[email protected]> Sun, 24 Nov 2024 15:43:41 -0800
Newsgroups gmane.emacs.erc.general
Message-ID <[email protected]>
--=-=-=
Content-Type: text/plain

Alcor via General discussion about ERC <[email protected]> writes:

> 1. Start from a clean Emacs installation (-Q or default config).
> 2. Install the latest stable version of Erc via C-u M-x package-install
> erc RET (At the time of writing, this is Erc 5.6).
> 3. Connect to Libera.Chat under any nick.
> 4. Once connected, type /QUERY fsbot and hit RET.
> 5. Interact with the bot in any way that forces a reply (e.g. type
> ,greet RET).
> 6. Wait for the bot to reply.
> 7. Trigger the undo function via M-x undo or C-x u.
> 8. Observe as the undo affects the reply text inserted by the bot.
>
> This is a regression from Erc 5.5, where `undo' only affected the text
> typed by the user within the input prompt.

Thanks for reporting this.

Hoping this patch will address the issue.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Clear-buffer-undo-list-after-sending-input-in-ERC.patch

From 45180df71fc636d086ff87d70d377263688a133f Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <[email protected]>
Date: Sun, 24 Nov 2024 15:30:02 -0800
Subject: [PATCH] Clear buffer-undo-list after sending input in ERC

* lisp/erc/erc.el (erc-send-current-line): Set `buffer-undo-list' to nil
because it should only record editing changes in the prompt area, which
has just been cleared.  ERC did this via `erc-display-prompt' prior to
5.6, but it now leaves the prompt alone by default.  (Bug#74518)
---
 lisp/erc/erc.el | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 7028d0a68cc..c6978728dd6 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -8200,10 +8200,9 @@ erc-send-current-line
                   ;; Fix the buffer if the command didn't kill it
                   (when (buffer-live-p old-buf)
                     (with-current-buffer old-buf
-                      (save-restriction
-                        (widen)
-                        (let ((buffer-modified (buffer-modified-p)))
-                          (set-buffer-modified-p buffer-modified))))))
+                      (setq buffer-undo-list nil)
+                      ;; `set-buffer-modified-p' used to do this here.
+                      (force-mode-line-update))))
 
                 ;; Only when last hook has been run...
                 (run-hook-with-args 'erc-send-completed-hook str)))
-- 
2.47.0


--=-=-=--