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

Previous Next

Package: emacs;

Reported by: Trevor Arjeski <tmarjeski <at> gmail.com>

Date: Fri, 3 Jan 2025 22:12:01 UTC

Severity: normal

Found in version 31.0.50

Done: "J.P." <jp <at> neverwas.me>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75327 in the body.
You can then email your comments to 75327 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#75327; Package emacs. (Fri, 03 Jan 2025 22:12:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Trevor Arjeski <tmarjeski <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 03 Jan 2025 22:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Trevor Arjeski <tmarjeski <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting with erc-spelling
 module and flyspell
Date: Sat, 04 Jan 2025 01:10:48 +0300
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))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75327; Package emacs. (Sat, 04 Jan 2025 05:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 75327 <at> debbugs.gnu.org (full text, mbox):

From: Trevor Arjeski <tmarjeski <at> gmail.com>
To: 75327 <at> debbugs.gnu.org
Subject: Re: bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting
 with erc-spelling module and flyspell
Date: Sat, 04 Jan 2025 08:51:31 +0300
[Message part 1 (text/plain, inline)]
Trevor Arjeski <tmarjeski <at> gmail.com> writes:

Here is a patch to resolve this issue:

[0001-erc-bug-75327-fix-flyspell-verify.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75327; Package emacs. (Sun, 05 Jan 2025 19:35:01 GMT) Full text and rfc822 format available.

Message #11 received at 75327 <at> debbugs.gnu.org (full text, mbox):

From: "J.P." <jp <at> neverwas.me>
To: Trevor Arjeski <tmarjeski <at> gmail.com>
Cc: 75327 <at> debbugs.gnu.org, emacs-erc <at> gnu.org
Subject: Re: bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting
 with erc-spelling module and flyspell
Date: Sun, 05 Jan 2025 11:33:53 -0800
[Message part 1 (text/plain, inline)]
Trevor Arjeski <tmarjeski <at> 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 <at> 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?

[0000-v1-v2.diff (text/x-patch, attachment)]
[0001-5.6.1-Improve-use-of-flyspell-s-API-in-erc-spelling.patch (text/x-patch, attachment)]
[0002-5.6.1-Declare-unused-functions-in-erc-spelling-obsol.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75327; Package emacs. (Sun, 05 Jan 2025 20:35:02 GMT) Full text and rfc822 format available.

Message #14 received at 75327 <at> debbugs.gnu.org (full text, mbox):

From: Trevor Arjeski <tmarjeski <at> gmail.com>
To: "J.P." <jp <at> neverwas.me>
Cc: 75327 <at> debbugs.gnu.org, emacs-erc <at> gnu.org
Subject: Re: bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting
 with erc-spelling module and flyspell
Date: Sun, 05 Jan 2025 23:34:29 +0300
"J.P." <jp <at> 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.




Reply sent to "J.P." <jp <at> neverwas.me>:
You have taken responsibility. (Fri, 10 Jan 2025 03:34:02 GMT) Full text and rfc822 format available.

Notification sent to Trevor Arjeski <tmarjeski <at> gmail.com>:
bug acknowledged by developer. (Fri, 10 Jan 2025 03:34:02 GMT) Full text and rfc822 format available.

Message #19 received at 75327-done <at> debbugs.gnu.org (full text, mbox):

From: "J.P." <jp <at> neverwas.me>
To: Trevor Arjeski <tmarjeski <at> gmail.com>
Cc: 75327-done <at> debbugs.gnu.org, emacs-erc <at> gnu.org
Subject: Re: bug#75327: 31.0.50; ERC 5.6.1-git: M-TAB not autocorrecting
 with erc-spelling module and flyspell
Date: Thu, 09 Jan 2025 19:33:36 -0800
Trevor Arjeski <tmarjeski <at> gmail.com> writes:

> 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.

Installed on master as:

  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=f9ecde75

Closing for now (but will reopen if problems remain).

>> 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.

Patches of this type are helpful indeed. Thanks!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 07 Feb 2025 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 129 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.