unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting with erc-spelling module and flyspell
@ 2025-01-03 22:10 Trevor Arjeski
  2025-01-04  5:51 ` Trevor Arjeski
  0 siblings, 1 reply; 4+ messages in thread
From: Trevor Arjeski @ 2025-01-03 22:10 UTC (permalink / raw)
  To: 75327


When using the erc-spelling module, pressing M-TAB to autocorrect a word
does not trigger autocorrection, but using C-. or C-; does, even when
`flyspell-use-meta-tab' is enabled.

Minimal config:

(use-package erc
  :config
  (setopt erc-modules '(spelling))
  (erc-spelling-mode))

1. Open an erc buffer
2. Type 'thier' and hit M-TAB
3. Notice it passes through to ispell - perhaps due to the command
passthrough in `flyspell-auto-correct-word'.

Setting `flyspell-generic-check-word-predicate' to nil in the erc buffer
resolves the issue, but we lose verification that is done in
`erc-spelling-flyspell-verify'.


In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.2) of 2024-12-31 built on trevarch
Repository revision: 2f1052d9b0de551dc3a463ed54e21c63517497ab
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101015
System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-modules --without-m17n-flt --without-gconf
 --with-native-compilation=yes --with-xinput2 --with-x-toolkit=gtk3
 --without-xaw3d --with-sound=no --with-tree-sitter --without-gpm
 --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer
 -mno-omit-leaf-frame-pointer -Wno-implicit-function-declaration -g
 -ffile-prefix-map=/home/trev/Workspace/emacs-git/src=/usr/src/debug/emacs-git
 -flto=auto' 'LDFLAGS=-Wl,-O1 -Wl,--sort-common -Wl,--as-needed
 -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_CTYPE: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ERC

Minor modes in effect:
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-spelling-mode: t
  flyspell-mode: t
  erc-ring-mode: t
  erc-nicks-mode: t
  erc-netsplit-mode: t
  erc-menu-mode: t
  erc-match-mode: t
  erc-list-mode: t
  erc-irccontrols-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  erc-scrolltobottom-mode: t
  erc-imenu-mode: t
  erc-pcomplete-mode: t
  erc-button--phantom-users-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-autojoin-mode: t
  erc-networks-mode: t
  envrc-global-mode: t
  envrc-mode: t
  diff-hl-flydiff-mode: t
  global-diff-hl-mode: t
  ws-butler-global-mode: t
  ws-butler-mode: t
  global-treesit-auto-mode: t
  corfu-popupinfo-mode: t
  global-corfu-mode: t
  marginalia-mode: t
  savehist-mode: t
  vertico-mode: t
  auto-insert-mode: t
  undo-fu-session-global-mode: t
  undo-fu-session-mode: t
  which-key-mode: t
  electric-pair-mode: t
  global-auto-revert-mode: t
  desktop-save-mode: t
  recentf-mode: t
  save-place-mode: t
  override-global-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  window-divider-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
~/.emacs.d//lisp/aoc hides /home/trev/.emacs.d/elpa/aoc-1.0.0/aoc
~/.emacs.d//lisp/launch-program hides /home/trev/.emacs.d/elpa/launch-program-1.0.0/launch-program
~/.emacs.d//lisp/my-secrets hides /home/trev/.emacs.d/elpa/my-secrets-1.0.0/my-secrets
/home/trev/.emacs.d/elpa/transient-20241201.1616/transient hides /usr/share/emacs/31.0.50/lisp/transient

Features:
(shadow sort mail-extr emacsbug cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine misearch multi-isearch pulse
bug-reference eglot external-completion jsonrpc flymake ert pcase
c++-ts-mode c-ts-mode c-ts-common xref undo-fu shortdoc project consult
bookmark ace-window avy jka-compr comp comp-cstr warnings comp-run
comp-common thingatpt helpful cc-langs cc-vars cc-defs trace cl-print
edebug debug backtrace info-look find-func f help-fns radix-tree
elisp-refs s orderless cape-char cape network-stream nsm erc-track
erc-spelling flyspell ispell erc-ring erc-nicks erc-netsplit erc-menu
erc-match erc-list erc-goodies erc-imenu imenu erc-pcomplete pcomplete
erc-button erc-fill erc-stamp erc-join my-secrets cus-start epa-file erc
format-spec erc-backend erc-networks erc-common erc-compat erc-loaddefs
mule-util rainbow-mode envrc diff-hl-flydiff diff diff-hl log-view
log-edit message sendmail yank-media puny dired dired-loaddefs rfc822
mml mml-sec epa derived epg rfc6068 epg-config mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
gmm-utils mailheader add-log pcvs-util vc-dir ewoc vc vc-git diff-mode
track-changes files-x vc-dispatcher paredit display-line-numbers rx
ligature rainbow-delimiters format-all language-id inheritenv init gnus
nnheader gnus-util time-date mail-utils range mm-util mail-prsvr
cus-edit pp ws-butler treesit-auto treesit corfu-popupinfo corfu
marginalia savehist vertico compat autoinsert grep compile
text-property-search comint ansi-osc ansi-color ring cus-load finder-inf
undo-fu-session which-key diminish edmacro kmacro elec-pair autorevert
filenotify desktop frameset recentf tree-widget wid-edit saveplace
nord-theme autothemer color lisp-mnt dash use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode package browse-url xdg url url-proxy url-privacy url-expand
url-methods url-history url-cookie generate-lisp-file url-domsuf
url-util mailcap url-handlers url-parse auth-source eieio eieio-core
icons password-cache json subr-x map byte-opt url-vars cl-macs gv
cl-extra help-mode cl-seq use-package-core cl-loaddefs cl-lib bytecomp
byte-compile info 2048-game-autoloads ace-window-autoloads aoc-autoloads
autothemer-autoloads avy-autoloads cape-autoloads consult-autoloads
corfu-autoloads debbugs-autoloads diff-hl-autoloads diminish-autoloads
elfeed-autoloads envrc-autoloads format-all-autoloads
geiser-guile-autoloads geiser-autoloads git-modes-autoloads
heap-autoloads helpful-autoloads elisp-refs-autoloads f-autoloads
ht-autoloads inheritenv-autoloads language-id-autoloads
launch-program-autoloads leetcode-autoloads aio-autoloads
ligature-autoloads log4e-autoloads magit-autoloads
magit-section-autoloads dash-autoloads marginalia-autoloads
markdown-mode-autoloads memoize-autoloads my-secrets-autoloads
nerd-icons-dired-autoloads nerd-icons-autoloads orderless-autoloads
paredit-autoloads rainbow-delimiters-autoloads rainbow-mode-autoloads
request-autoloads rust-mode-autoloads s-autoloads sly-autoloads
transient-autoloads treesit-auto-autoloads undo-fu-autoloads
undo-fu-session-autoloads vertico-autoloads vterm-autoloads
with-editor-autoloads ws-butler-autoloads early-init rmc iso-transl
tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
touch-screen tool-bar dnd fontset image regexp-opt fringe tabulated-list
replace newcomment text-mode lisp-mode prog-mode register page tab-bar
menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse
jit-lock font-lock syntax font-core term/tty-colors frame minibuffer
nadvice seq simple cl-generic indonesian philippine cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop
case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process tty-child-frames native-compile emacs)

Memory information:
((conses 16 712889 485226) (symbols 48 29999 54) (strings 32 127367 16380)
 (string-bytes 1 4530868) (vectors 16 60916) (vector-slots 8 1489370 389695)
 (floats 8 497 1213) (intervals 56 25972 6388) (buffers 992 41))






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting with erc-spelling module and flyspell
  2025-01-03 22:10 bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting with erc-spelling module and flyspell Trevor Arjeski
@ 2025-01-04  5:51 ` Trevor Arjeski
  2025-01-05 19:33   ` J.P.
       [not found]   ` <874j2drr6m.fsf@neverwas.me>
  0 siblings, 2 replies; 4+ messages in thread
From: Trevor Arjeski @ 2025-01-04  5:51 UTC (permalink / raw)
  To: 75327

[-- Attachment #1: Type: text/plain, Size: 86 bytes --]

Trevor Arjeski <tmarjeski@gmail.com> writes:

Here is a patch to resolve this issue:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch file --]
[-- Type: text/x-patch, Size: 1962 bytes --]

From 3d32aea96cc6ec020e35901d35f1d02994912215 Mon Sep 17 00:00:00 2001
From: Trevor Arjeski <tmarjeski@gmail.com>
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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting with erc-spelling module and flyspell
  2025-01-04  5:51 ` Trevor Arjeski
@ 2025-01-05 19:33   ` J.P.
       [not found]   ` <874j2drr6m.fsf@neverwas.me>
  1 sibling, 0 replies; 4+ messages in thread
From: J.P. @ 2025-01-05 19:33 UTC (permalink / raw)
  To: Trevor Arjeski; +Cc: 75327, emacs-erc

[-- Attachment #1: Type: text/plain, Size: 4152 bytes --]

Trevor Arjeski <tmarjeski@gmail.com> writes:

> When using the erc-spelling module, pressing M-TAB to autocorrect a word
> does not trigger autocorrection, but using C-. or C-; does, even when
> `flyspell-use-meta-tab' is enabled.
>
> Minimal config:
>
> (use-package erc
>   :config
>   (setopt erc-modules '(spelling))
>   (erc-spelling-mode))
>
> 1. Open an erc buffer
> 2. Type 'thier' and hit M-TAB
> 3. Notice it passes through to ispell - perhaps due to the command
> passthrough in `flyspell-auto-correct-word'.

Regarding this "passthrough" behavior with "M-TAB" vs "C-.", I think
what's happening is that when you type "C-.", the call to

  (let (flyspell-mode) (key-binding (kbd "C-.")))

in `flyspell-auto-correct-word' returns nil because there's no global or
`erc-mode' binding for that key, so `flyspell-word' ultimately runs
further down in the function body. And so too does the predicate in
question, `erc-spelling-flyspell-verify', with `flyspell-word' bound as
a dynamic variable. By contrast,

  (let (flyspell-mode) (key-binding (kbd "C-M-i"))) ; or "M-TAB"

yields a non-nil result, namely `ispell-complete-word', because that's
the binding in `erc-mode-map'. And if you were to remove that with
`local-unset-key', you'd observe `flyspell-auto-correct-word' deferring
to `complete-symbol', which appeals to CAPF and `pcomplete'-related
machinery in ERC buffers.

> Setting `flyspell-generic-check-word-predicate' to nil in the erc buffer
> resolves the issue, but we lose verification that is done in
> `erc-spelling-flyspell-verify'.

Right, that basically nullifies the integration.

> Here is a patch to resolve this issue:
>
> From 3d32aea96cc6ec020e35901d35f1d02994912215 Mon Sep 17 00:00:00 2001
> From: Trevor Arjeski <tmarjeski@gmail.com>
> 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'.

In the future, please use the GNU ChangeLog style for commit messages,
as described in CONTRIBUTE.

> ---
>  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."
[...]
> +  (when-let* (((>= (point) erc-input-marker))
> +              (word-data (flyspell-get-word)))

While calling `flyspell-get-word' definitely seems to work and is
probably harmless, I'm not sure Flyspell's authors intended these
predicates to know about the current candidate, much less modify
existing overlays based on that info (both preexisting transgressions
and obviously not your doing).

There's also the small matter of `flyspell-get-word' running twice in
quick succession during the course of a normal `flyspell-word' call.
Again, probably harmless, but if there's a more idiomatic way to get at
this, we should probably abide (see attached), just in case future
flyspell.el hackers decide to assume all "consumers" of its API are well
behaved citizens.

> +    (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

Please see the attached iteration, which has a few more changes than
your v1 patch. If we go with something similar, that would, by my
uninformed figuring, put you right at the copyright-exempt limit of
12-ish nontrivial lines (though we may be pushing the envelope a tad).

Thanks.

P.S. Have you already (or will you) put in for a copyright assignment?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0000-v1-v2.diff --]
[-- Type: text/x-patch, Size: 11791 bytes --]

From ce275256955f20b2932ae50b9019394c8758b970 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Sun, 5 Jan 2025 09:39:31 -0800
Subject: [PATCH 0/2] *** NOT A PATCH ***

*** BLURB HERE ***

F. Jason Park (1):
  [5.6.1] Declare unused functions in erc-spelling obsolete

Trevor Arjeski (1):
  [5.6.1] Improve use of flyspell's API in erc-spelling

 etc/ERC-NEWS                                  |  5 +
 lisp/erc/erc-spelling.el                      | 24 ++++-
 test/lisp/erc/erc-scenarios-spelling.el       | 95 +++++++++++++++++++
 .../erc/resources/spelling/auto-correct.eld   | 35 +++++++
 4 files changed, 157 insertions(+), 2 deletions(-)
 create mode 100644 test/lisp/erc/erc-scenarios-spelling.el
 create mode 100644 test/lisp/erc/resources/spelling/auto-correct.eld

Interdiff:
diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index f79d45b94b6..d491c3e5132 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -96,6 +96,11 @@ Although this has always been the case, string values are now more
 likely to be seen because ERC no longer coerces service names to port
 numbers.
 
+*** The 'spelling' module makes better use of Flyspell's API.
+As a consequence, the library functions 'erc-spelling-flyspell-verify'
+and 'erc-spelling-unhighlight-word' are now unused and have been marked
+obsolete.
+
 \f
 * Changes in ERC 5.6
 
diff --git a/lisp/erc/erc-spelling.el b/lisp/erc/erc-spelling.el
index 0bfb20fce2e..f0a45683f4d 100644
--- a/lisp/erc/erc-spelling.el
+++ b/lisp/erc/erc-spelling.el
@@ -48,6 +48,7 @@ spelling
        (erc-spelling-init (current-buffer)))))
   ((remove-hook 'erc-connect-pre-hook #'erc-spelling-init)
    (dolist (buffer (erc-buffer-list))
+     (remove-hook 'flyspell-incorrect-hook #'erc-spelling--flyspell-check t)
      (with-current-buffer buffer (flyspell-mode 0)))))
 
 (defcustom erc-spelling-dictionaries nil
@@ -78,7 +79,7 @@ erc-spelling-init
               (if dicts
                   (cadr (car dicts))
                 (erc-with-server-buffer ispell-local-dictionary)))))
-    (setq flyspell-generic-check-word-predicate #'erc-spelling-flyspell-verify)
+    (add-hook 'flyspell-incorrect-hook #'erc-spelling--flyspell-check 20 t)
     (flyspell-mode 1)))
 
 (defun erc-spelling-unhighlight-word (word)
@@ -92,23 +93,45 @@ erc-spelling-unhighlight-word
 
 (defun erc-spelling-flyspell-verify ()
   "Flyspell only the input line, nothing else."
-  (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))))
+  (declare (obsolete erc-spelling--flyspell-input-p "31.1"))
+  ;; 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)))))
+
+;; Do this down here to avoid adding `with-suppressed-warnings'.
+(make-obsolete 'erc-spelling-unhighlight-word
+               "value from `flyspell-get-word' now unused" "31.1")
+
+(defun erc-spelling--flyspell-check (beg end _)
+  "Return non-nil and remove overlay if text between BEG and END is correct."
+  (or (and erc-channel-users
+           (erc-get-channel-user (buffer-substring-no-properties beg end))
+           (always (flyspell-unhighlight-at beg)))
+      (and erc-input-marker (> beg erc-input-marker) (eq (char-before beg) ?/)
+           (or (= beg (1+ erc-input-marker)) ; allow /unknown if initial
+               (erc-command-symbol (buffer-substring-no-properties beg end)))
+           (always (flyspell-unhighlight-at beg)))))
+
+(defun erc-spelling--flyspell-input-p ()
+  "Return non-nil if flyspell should check the prompt input at point."
+  (>= (point) erc-input-marker))
 
 (put 'erc-mode
      'flyspell-mode-predicate
-     #'erc-spelling-flyspell-verify)
+     #'erc-spelling--flyspell-input-p)
 
 (provide 'erc-spelling)
 
diff --git a/test/lisp/erc/erc-scenarios-spelling.el b/test/lisp/erc/erc-scenarios-spelling.el
new file mode 100644
index 00000000000..907fbd78de3
--- /dev/null
+++ b/test/lisp/erc/erc-scenarios-spelling.el
@@ -0,0 +1,95 @@
+;;; erc-scenarios-spelling.el --- Basic spelling scenarios -*- lexical-binding: t -*-
+
+;; Copyright (C) 2025 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert-x)
+(eval-and-compile
+  (let ((load-path (cons (ert-resource-directory) load-path)))
+    (require 'erc-scenarios-common)))
+
+(require 'erc-spelling)
+
+(ert-deftest erc-scenarios-spelling--auto-correct ()
+  :tags '(:expensive-test
+          ;; FIXME make contingent upon a feature test for an English
+          ;; ispell setup in the current environment.
+          :unstable
+          ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
+
+  (ert-with-temp-directory erc-scenarios-spelling
+
+    (erc-scenarios-common-with-noninteractive-in-term
+        ((erc-scenarios-common-dialog "spelling")
+         (process-environment (cons
+                               (format "HOME=%s" erc-scenarios-spelling)
+                               process-environment))
+         (dumb-server (erc-d-run "localhost" t 'auto-correct))
+         (port (process-contact dumb-server :service))
+         (expect (erc-d-t-make-expecter))
+         (erc-autojoin-channels-alist '((foonet "#chan")))
+         (erc-modules (cons 'spelling erc-modules))
+         (erc-server-flood-penalty 0.1))
+
+      (ert-info ("Connect to foonet")
+        (with-current-buffer (erc :server "127.0.0.1"
+                                  :port port
+                                  :nick "tester"
+                                  :full-name "tester")
+          (funcall expect 10 "no longer marked as being")
+          (should erc-spelling-mode)
+          (should flyspell-mode)))
+
+      (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan"))
+        (should erc-spelling-mode)
+        (should flyspell-mode)
+        (funcall expect 10 "<alice> tester, welcome!")
+
+        ;; Insert a command with one misspelled word.
+        (set-window-buffer nil (current-buffer))
+        (execute-kbd-macro "\M->/AMSG an/dor /gmsg one fsbot two frob my shoe")
+        (funcall expect 10 "shoe")
+
+        (let* ((ovs (overlays-in erc-input-marker (point)))
+               (ov1 (pop ovs))
+               (ov2 (pop ovs)))
+          ;; At this point, flyspell should have done its thing.  There
+          ;; should be two overlays: one on "dor" and the other on
+          ;; "frob".  The spelling module's modifications should have
+          ;; prevented the two valid slash commands as well as "fsbot"
+          ;; from being highlighted.
+          (should-not ovs)
+          (should (flyspell-overlay-p ov1))
+          (should (equal "dor" (buffer-substring (overlay-start ov1)
+                                                 (overlay-end ov1))))
+          (should (flyspell-overlay-p ov2))
+          (should (equal "frob" (buffer-substring (overlay-start ov2)
+                                                  (overlay-end ov2))))
+          (goto-char (overlay-start ov2))
+
+          ;; Depending on the machine, this should become something
+          ;; like: "/AMSG an/dor /gmsg one fsbot two Rob my shoe".
+          (execute-kbd-macro (key-parse "M-TAB"))
+          (should (equal (overlays-in erc-input-marker (point-max))
+                         (list ov1)))))
+
+      (when noninteractive
+        (erc-spelling-mode -1)))))
+
+;;; erc-scenarios-spelling.el ends here
diff --git a/test/lisp/erc/resources/spelling/auto-correct.eld b/test/lisp/erc/resources/spelling/auto-correct.eld
new file mode 100644
index 00000000000..0f00ee4825c
--- /dev/null
+++ b/test/lisp/erc/resources/spelling/auto-correct.eld
@@ -0,0 +1,35 @@
+;; -*- mode: lisp-data; -*-
+((nick 1 "NICK tester"))
+((user 1 "USER user 0 * :tester")
+ (0 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester")
+ (0 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version oragono-2.6.0-7481bf0385b95b16")
+ (0 ":irc.foonet.org 003 tester :This server was created Wed, 05 May 2021 09:05:34 UTC")
+ (0 ":irc.foonet.org 004 tester irc.foonet.org oragono-2.6.0-7481bf0385b95b16 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv")
+ (0 ":irc.foonet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server")
+ (0 ":irc.foonet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=foonet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server")
+ (0 ":irc.foonet.org 005 tester draft/CHATHISTORY=100 :are supported by this server")
+ (0 ":irc.foonet.org 251 tester :There are 0 users and 3 invisible on 1 server(s)")
+ (0 ":irc.foonet.org 252 tester 0 :IRC Operators online")
+ (0 ":irc.foonet.org 254 tester 1 :channels formed")
+ (0 ":irc.foonet.org 255 tester :I have 3 clients and 0 servers")
+ (0 ":irc.foonet.org 265 tester 3 3 :Current local users 3, max 3")
+ (0 ":irc.foonet.org 266 tester 3 3 :Current global users 3, max 3")
+ (0 ":irc.foonet.org 422 tester :MOTD File is missing"))
+
+((mode-user 10 "MODE tester +i")
+ (0 ":irc.foonet.org 221 tester +i")
+ (0 ":irc.foonet.org NOTICE tester :This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect.")
+ (0 ":irc.foonet.org 305 tester :You are no longer marked as being away"))
+
+((join 10 "JOIN #chan")
+ (0 ":tester!~u@247eaxkrufj44.irc JOIN #chan")
+ (0 ":irc.foonet.org 353 tester = #chan :alice fsbot @bob tester")
+ (0 ":irc.foonet.org 366 tester #chan :End of /NAMES list."))
+
+((mode-chan 10 "MODE #chan")
+ (0 ":irc.foonet.org 324 tester #chan +nt")
+ (0 ":irc.foonet.org 329 tester #chan 1620205534")
+ (0 ":alice!~u@yppdd5tt4admc.irc PRIVMSG #chan :tester, welcome!")
+ (0 ":bob!~u@yppdd5tt4admc.irc PRIVMSG #chan :tester, welcome!")
+ (0 ":bob!~u@yppdd5tt4admc.irc PRIVMSG #chan :alice: Nor I no strength to climb without thy help.")
+ (0 ":alice!~u@yppdd5tt4admc.irc PRIVMSG #chan :bob: Nothing, but let him have thanks."))
-- 
2.47.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-5.6.1-Improve-use-of-flyspell-s-API-in-erc-spelling.patch --]
[-- Type: text/x-patch, Size: 3081 bytes --]

From 1329e0e05754bee70a8236d84d34d01ca42acea7 Mon Sep 17 00:00:00 2001
From: Trevor Arjeski <tmarjeski@gmail.com>
Date: Sat, 4 Jan 2025 08:45:29 +0300
Subject: [PATCH 1/2] [5.6.1] Improve use of flyspell's API in erc-spelling

* lisp/erc/erc-spelling.el: Change top-level assignment of `erc-mode'
symbol-property `flyspell-mode-predicate' from
`erc-spelling-flyspell-verify' to `erc-spelling--flyspell-input-p'.
(erc-spelling-mode, erc-spelling-disable): Remove local member from
`flyspell-incorrect-hook'.
(erc-spelling-init): Add `erc-spelling--flyspell-check' to
`flyspell-incorrect-hook' locally.  Don't bother explicitly setting
`flyspell-generic-check-word-predicate' because Flyspell already does
that for clients using the `flyspell-mode-predicte' interface.
(erc-spelling--flyspell-check, erc-spelling--flyspell-input-p): New
functions, essentially the two halves of a reworked and bifurcated
`erc-spelling-flyspell-verify'.  Though used as a predicate, the first
is not named as such because it performs side effects.  (Bug#75327)

Copyright-paperwork-exempt: yes
---
 lisp/erc/erc-spelling.el | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/lisp/erc/erc-spelling.el b/lisp/erc/erc-spelling.el
index 01e587af368..d6099d4991c 100644
--- a/lisp/erc/erc-spelling.el
+++ b/lisp/erc/erc-spelling.el
@@ -48,6 +48,7 @@ spelling
        (erc-spelling-init (current-buffer)))))
   ((remove-hook 'erc-connect-pre-hook #'erc-spelling-init)
    (dolist (buffer (erc-buffer-list))
+     (remove-hook 'flyspell-incorrect-hook #'erc-spelling--flyspell-check t)
      (with-current-buffer buffer (flyspell-mode 0)))))
 
 (defcustom erc-spelling-dictionaries nil
@@ -78,7 +79,7 @@ erc-spelling-init
               (if dicts
                   (cadr (car dicts))
                 (erc-with-server-buffer ispell-local-dictionary)))))
-    (setq flyspell-generic-check-word-predicate #'erc-spelling-flyspell-verify)
+    (add-hook 'flyspell-incorrect-hook #'erc-spelling--flyspell-check 20 t)
     (flyspell-mode 1)))
 
 (defun erc-spelling-unhighlight-word (word)
@@ -109,9 +110,23 @@ erc-spelling-flyspell-verify
              nil)
             (t t)))))
 
+(defun erc-spelling--flyspell-check (beg end _)
+  "Return non-nil and remove overlay if text between BEG and END is correct."
+  (or (and erc-channel-users
+           (erc-get-channel-user (buffer-substring-no-properties beg end))
+           (always (flyspell-unhighlight-at beg)))
+      (and erc-input-marker (> beg erc-input-marker) (eq (char-before beg) ?/)
+           (or (= beg (1+ erc-input-marker)) ; allow /unknown if initial
+               (erc-command-symbol (buffer-substring-no-properties beg end)))
+           (always (flyspell-unhighlight-at beg)))))
+
+(defun erc-spelling--flyspell-input-p ()
+  "Return non-nil if flyspell should check the prompt input at point."
+  (>= (point) erc-input-marker))
+
 (put 'erc-mode
      'flyspell-mode-predicate
-     #'erc-spelling-flyspell-verify)
+     #'erc-spelling--flyspell-input-p)
 
 (provide 'erc-spelling)
 
-- 
2.47.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0002-5.6.1-Declare-unused-functions-in-erc-spelling-obsol.patch --]
[-- Type: text/x-patch, Size: 10042 bytes --]

From ce275256955f20b2932ae50b9019394c8758b970 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Sat, 4 Jan 2025 11:40:01 -0800
Subject: [PATCH 2/2] [5.6.1] Declare unused functions in erc-spelling obsolete

* etc/ERC-NEWS: Announce deprecation of `erc-spelling-flyspell-verify'
and `erc-spelling-unhighlight-word'.  A slight behavioral change not
worth mentioning is that previously, ERC arranged for Flyspell to ignore
any word immediately following a forward slash anywhere in the input,
even those for which the slash served as mere punctuation (a "stroke"),
as in "something/misspelt."  Now, Flyspell only unconditionally exempts
an initial slash-prepended word, like "tableflip" in "ERC> /tableflip",
and checks all others that follow against known slash commands.
* lisp/erc/erc-spelling.el (erc-spelling-flyspell-verify)
(erc-spelling-unhighlight-word): Mark obsolete.
* test/lisp/erc/erc-scenarios-spelling.el: New file.
* test/lisp/erc/resources/spelling/auto-correct.eld: New file.
(Bug#75327)
---
 etc/ERC-NEWS                                  |  5 +
 lisp/erc/erc-spelling.el                      |  5 +
 test/lisp/erc/erc-scenarios-spelling.el       | 95 +++++++++++++++++++
 .../erc/resources/spelling/auto-correct.eld   | 35 +++++++
 4 files changed, 140 insertions(+)
 create mode 100644 test/lisp/erc/erc-scenarios-spelling.el
 create mode 100644 test/lisp/erc/resources/spelling/auto-correct.eld

diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index f79d45b94b6..d491c3e5132 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -96,6 +96,11 @@ Although this has always been the case, string values are now more
 likely to be seen because ERC no longer coerces service names to port
 numbers.
 
+*** The 'spelling' module makes better use of Flyspell's API.
+As a consequence, the library functions 'erc-spelling-flyspell-verify'
+and 'erc-spelling-unhighlight-word' are now unused and have been marked
+obsolete.
+
 \f
 * Changes in ERC 5.6
 
diff --git a/lisp/erc/erc-spelling.el b/lisp/erc/erc-spelling.el
index d6099d4991c..f0a45683f4d 100644
--- a/lisp/erc/erc-spelling.el
+++ b/lisp/erc/erc-spelling.el
@@ -93,6 +93,7 @@ erc-spelling-unhighlight-word
 
 (defun erc-spelling-flyspell-verify ()
   "Flyspell only the input line, nothing else."
+  (declare (obsolete erc-spelling--flyspell-input-p "31.1"))
   ;; FIXME: Don't use `flyspell-word'!
   (let ((word-data (and (boundp 'flyspell-word)
                         flyspell-word)))
@@ -110,6 +111,10 @@ erc-spelling-flyspell-verify
              nil)
             (t t)))))
 
+;; Do this down here to avoid adding `with-suppressed-warnings'.
+(make-obsolete 'erc-spelling-unhighlight-word
+               "value from `flyspell-get-word' now unused" "31.1")
+
 (defun erc-spelling--flyspell-check (beg end _)
   "Return non-nil and remove overlay if text between BEG and END is correct."
   (or (and erc-channel-users
diff --git a/test/lisp/erc/erc-scenarios-spelling.el b/test/lisp/erc/erc-scenarios-spelling.el
new file mode 100644
index 00000000000..907fbd78de3
--- /dev/null
+++ b/test/lisp/erc/erc-scenarios-spelling.el
@@ -0,0 +1,95 @@
+;;; erc-scenarios-spelling.el --- Basic spelling scenarios -*- lexical-binding: t -*-
+
+;; Copyright (C) 2025 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert-x)
+(eval-and-compile
+  (let ((load-path (cons (ert-resource-directory) load-path)))
+    (require 'erc-scenarios-common)))
+
+(require 'erc-spelling)
+
+(ert-deftest erc-scenarios-spelling--auto-correct ()
+  :tags '(:expensive-test
+          ;; FIXME make contingent upon a feature test for an English
+          ;; ispell setup in the current environment.
+          :unstable
+          ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
+
+  (ert-with-temp-directory erc-scenarios-spelling
+
+    (erc-scenarios-common-with-noninteractive-in-term
+        ((erc-scenarios-common-dialog "spelling")
+         (process-environment (cons
+                               (format "HOME=%s" erc-scenarios-spelling)
+                               process-environment))
+         (dumb-server (erc-d-run "localhost" t 'auto-correct))
+         (port (process-contact dumb-server :service))
+         (expect (erc-d-t-make-expecter))
+         (erc-autojoin-channels-alist '((foonet "#chan")))
+         (erc-modules (cons 'spelling erc-modules))
+         (erc-server-flood-penalty 0.1))
+
+      (ert-info ("Connect to foonet")
+        (with-current-buffer (erc :server "127.0.0.1"
+                                  :port port
+                                  :nick "tester"
+                                  :full-name "tester")
+          (funcall expect 10 "no longer marked as being")
+          (should erc-spelling-mode)
+          (should flyspell-mode)))
+
+      (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan"))
+        (should erc-spelling-mode)
+        (should flyspell-mode)
+        (funcall expect 10 "<alice> tester, welcome!")
+
+        ;; Insert a command with one misspelled word.
+        (set-window-buffer nil (current-buffer))
+        (execute-kbd-macro "\M->/AMSG an/dor /gmsg one fsbot two frob my shoe")
+        (funcall expect 10 "shoe")
+
+        (let* ((ovs (overlays-in erc-input-marker (point)))
+               (ov1 (pop ovs))
+               (ov2 (pop ovs)))
+          ;; At this point, flyspell should have done its thing.  There
+          ;; should be two overlays: one on "dor" and the other on
+          ;; "frob".  The spelling module's modifications should have
+          ;; prevented the two valid slash commands as well as "fsbot"
+          ;; from being highlighted.
+          (should-not ovs)
+          (should (flyspell-overlay-p ov1))
+          (should (equal "dor" (buffer-substring (overlay-start ov1)
+                                                 (overlay-end ov1))))
+          (should (flyspell-overlay-p ov2))
+          (should (equal "frob" (buffer-substring (overlay-start ov2)
+                                                  (overlay-end ov2))))
+          (goto-char (overlay-start ov2))
+
+          ;; Depending on the machine, this should become something
+          ;; like: "/AMSG an/dor /gmsg one fsbot two Rob my shoe".
+          (execute-kbd-macro (key-parse "M-TAB"))
+          (should (equal (overlays-in erc-input-marker (point-max))
+                         (list ov1)))))
+
+      (when noninteractive
+        (erc-spelling-mode -1)))))
+
+;;; erc-scenarios-spelling.el ends here
diff --git a/test/lisp/erc/resources/spelling/auto-correct.eld b/test/lisp/erc/resources/spelling/auto-correct.eld
new file mode 100644
index 00000000000..0f00ee4825c
--- /dev/null
+++ b/test/lisp/erc/resources/spelling/auto-correct.eld
@@ -0,0 +1,35 @@
+;; -*- mode: lisp-data; -*-
+((nick 1 "NICK tester"))
+((user 1 "USER user 0 * :tester")
+ (0 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester")
+ (0 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version oragono-2.6.0-7481bf0385b95b16")
+ (0 ":irc.foonet.org 003 tester :This server was created Wed, 05 May 2021 09:05:34 UTC")
+ (0 ":irc.foonet.org 004 tester irc.foonet.org oragono-2.6.0-7481bf0385b95b16 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv")
+ (0 ":irc.foonet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server")
+ (0 ":irc.foonet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=foonet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server")
+ (0 ":irc.foonet.org 005 tester draft/CHATHISTORY=100 :are supported by this server")
+ (0 ":irc.foonet.org 251 tester :There are 0 users and 3 invisible on 1 server(s)")
+ (0 ":irc.foonet.org 252 tester 0 :IRC Operators online")
+ (0 ":irc.foonet.org 254 tester 1 :channels formed")
+ (0 ":irc.foonet.org 255 tester :I have 3 clients and 0 servers")
+ (0 ":irc.foonet.org 265 tester 3 3 :Current local users 3, max 3")
+ (0 ":irc.foonet.org 266 tester 3 3 :Current global users 3, max 3")
+ (0 ":irc.foonet.org 422 tester :MOTD File is missing"))
+
+((mode-user 10 "MODE tester +i")
+ (0 ":irc.foonet.org 221 tester +i")
+ (0 ":irc.foonet.org NOTICE tester :This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect.")
+ (0 ":irc.foonet.org 305 tester :You are no longer marked as being away"))
+
+((join 10 "JOIN #chan")
+ (0 ":tester!~u@247eaxkrufj44.irc JOIN #chan")
+ (0 ":irc.foonet.org 353 tester = #chan :alice fsbot @bob tester")
+ (0 ":irc.foonet.org 366 tester #chan :End of /NAMES list."))
+
+((mode-chan 10 "MODE #chan")
+ (0 ":irc.foonet.org 324 tester #chan +nt")
+ (0 ":irc.foonet.org 329 tester #chan 1620205534")
+ (0 ":alice!~u@yppdd5tt4admc.irc PRIVMSG #chan :tester, welcome!")
+ (0 ":bob!~u@yppdd5tt4admc.irc PRIVMSG #chan :tester, welcome!")
+ (0 ":bob!~u@yppdd5tt4admc.irc PRIVMSG #chan :alice: Nor I no strength to climb without thy help.")
+ (0 ":alice!~u@yppdd5tt4admc.irc PRIVMSG #chan :bob: Nothing, but let him have thanks."))
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting with erc-spelling module and flyspell
       [not found]   ` <874j2drr6m.fsf@neverwas.me>
@ 2025-01-05 20:34     ` Trevor Arjeski
  0 siblings, 0 replies; 4+ messages in thread
From: Trevor Arjeski @ 2025-01-05 20:34 UTC (permalink / raw)
  To: J.P.; +Cc: 75327, emacs-erc

"J.P." <jp@neverwas.me> writes:

Thanks for the bug explanation!

> In the future, please use the GNU ChangeLog style for commit messages,
> as described in CONTRIBUTE.

Noted.

>> ---
>>  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."
> [...]
>> +  (when-let* (((>= (point) erc-input-marker))
>> +              (word-data (flyspell-get-word)))
>
> While calling `flyspell-get-word' definitely seems to work and is
> probably harmless, I'm not sure Flyspell's authors intended these
> predicates to know about the current candidate, much less modify
> existing overlays based on that info (both preexisting transgressions
> and obviously not your doing).
>
> There's also the small matter of `flyspell-get-word' running twice in
> quick succession during the course of a normal `flyspell-word' call.
> Again, probably harmless, but if there's a more idiomatic way to get at
> this, we should probably abide (see attached), just in case future
> flyspell.el hackers decide to assume all "consumers" of its API are well
> behaved citizens.
>
>> +    (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
>
> Please see the attached iteration, which has a few more changes than
> your v1 patch. If we go with something similar, that would, by my
> uninformed figuring, put you right at the copyright-exempt limit of
> 12-ish nontrivial lines (though we may be pushing the envelope a tad).
>
> Thanks.

Looks good to me, as long as it fixes the issue I will be glad.  You
could just remove my name from the commit, since the changes in the
patches don't really resemble my crude fix.

> P.S. Have you already (or will you) put in for a copyright assignment?

I have not. Not sure if I will do it. I am content with my patches just
being guides to help a maintainer, since I am not really familiar with
the true inner workings of emacs or erc.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-05 20:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-03 22:10 bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting with erc-spelling module and flyspell Trevor Arjeski
2025-01-04  5:51 ` Trevor Arjeski
2025-01-05 19:33   ` J.P.
     [not found]   ` <874j2drr6m.fsf@neverwas.me>
2025-01-05 20:34     ` Trevor Arjeski

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).