Subject: Re: 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: Sun, 05 Jan 2025 23:34:29 +0300

"J.P." <[email-masked]> 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.