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

From: "J.P." <[email-masked]>
Date: Sun, 24 Nov 2024 15:43:41 -0800

Alcor via General discussion about ERC <[email-masked]> 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.

>From 45180df71fc636d086ff87d70d377263688a133f Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <[email-masked]>
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