Subject: bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting with erc-spelling module and flyspell

From: Trevor Arjeski <[email-masked]>
Date: Sat, 04 Jan 2025 08:51:31 +0300

Trevor Arjeski <[email-masked]> writes:

Here is a patch to resolve this issue:

>From 3d32aea96cc6ec020e35901d35f1d02994912215 Mon Sep 17 00:00:00 2001
From: Trevor Arjeski <[email-masked]>
Date: Sat, 4 Jan 2025 08:45:29 +0300
Subject: [PATCH] erc: bug#75327 fix flyspell verify

Slightly refactored `erc-spelling-flyspell-verify' to use
`flyspell-get-word', which in turn, allows M-TAB to call
`flyspell-auto-correct-word'.
---
 lisp/erc/erc-spelling.el | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/lisp/erc/erc-spelling.el b/lisp/erc/erc-spelling.el
index 01e587af368..0bfb20fce2e 100644
--- a/lisp/erc/erc-spelling.el
+++ b/lisp/erc/erc-spelling.el
@@ -92,22 +92,19 @@ erc-spelling-unhighlight-word
 
 (defun erc-spelling-flyspell-verify ()
   "Flyspell only the input line, nothing else."
-  ;; FIXME: Don't use `flyspell-word'!
-  (let ((word-data (and (boundp 'flyspell-word)
-                        flyspell-word)))
-    (when word-data
-      (cond ((< (point) erc-input-marker)
-             nil)
-            ;; don't spell-check names of users
-            ((and erc-channel-users
-                  (erc-get-channel-user (car word-data)))
-             (erc-spelling-unhighlight-word word-data)
-             nil)
-            ;; if '/' occurs before the word, don't spell-check it
-            ((eq (char-before (nth 1 word-data)) ?/)
-             (erc-spelling-unhighlight-word word-data)
-             nil)
-            (t t)))))
+  (when-let* (((>= (point) erc-input-marker))
+              (word-data (flyspell-get-word)))
+    (cond
+     ;; don't spell-check names of users
+     ((and erc-channel-users
+           (erc-get-channel-user (car word-data)))
+      (erc-spelling-unhighlight-word word-data)
+      nil)
+     ;; if '/' occurs before the word, don't spell-check it
+     ((eq (char-before (nth 1 word-data)) ?/)
+      (erc-spelling-unhighlight-word word-data)
+      nil)
+     (t t))))
 
 (put 'erc-mode
      'flyspell-mode-predicate
-- 
2.47.1