Subject: Re: bug#76884: 30.1 problem with flyspell-maybe-correct-transposition

From: Jim Diamond <[email-masked]>
Date: Sun, 9 Mar 2025 17:59:15 -0300

On Sun, Mar  9, 2025 at 21:08 (+0200), Eli Zaretskii wrote:

>> Date: Sun, 9 Mar 2025 13:46:23 -0300
>> From: Jim Diamond <[email-masked]>
>> Cc: [email-masked]

>>>> Result: I get "CAB", whereas I expect "ACB".  This is not merely
>>>> unexpected, but an actual problem.

>>> What causes that problem is that add-hook you did.  If you want C-t to
>>> transpose characters, and Flyspell to not react on C-t, then why did
>>> you add to that hook?

>> I added to that hook because, when the above-mentioned "automatically fix
>> transposition errors" stopped working (with my upgrade to 30.1), I went
>> looking for a newer version of the software.  The original author told me
>> that flyspell has had the ability to automatically fix transposition errors
>> for some time, and thus he has stopped updating his code.  And he suggested
>> I add that function to that hook.  So I did.

>> Given that he (presumably!) understands perfectly what his original
>> software did, I assumed that adding to that hook would do the same thing.
>> It doesn't, at least the way I am using it.

> So let me see if I understand what you are describing.

> You had a bunch of function in auto-correct.el which would
> automatically fix transposed characters as side effect of expanding
> abbrevs, which happens when you type a non-word character such as SPC
> after a sequence of word-constituent characters.  This code stopped
> working in Emacs 30.1 (any idea why, btw?).

No, the error message I got was opaque to me, and so that was when I went
looking for a newer version of auto-correct.el

> So you were looking for a replacement, and someone told you that setting
> flyspell-incorrect-hook to call flyspell-maybe-correct-transposition
> would do the job.

Correct.

> But it doesn't do the job as you'd like it, because it attempts to fix
> mis-spellings too early, immediately when you type C-t instead of when
> you type SPC after C-t.

Correct.

> So your bug report is that using flyspell-maybe-correct-transposition
> this way doesn't work as you'd like, and you consider that a bug.  Did I
> understand you correctly?

No.  As I already said (twice?) I thought there might be some setting to
make it work as I would like, and I posted to the gnu emacs newsgroup,
where an experienced emacs and elisp person opined that it was a bug and I
should report it.

>> I realize that the flyspell mechanism doesn't rely on abbrev mode, and so
>> my original question to the gnu emacs newsgroup was a hope that someone
>> with more elisp knowledge than me could help me out.  But, as I mentioned,
>> someone with far more elisp knowledge than me claimed it was a bug, and I
>> believed him.  So here we are.

> If I understood you correctly, there's no bug in what
> flyspell-maybe-correct-transposition does,

I'd say that is arguable, but let's carry on.

> and invoking it from flyspell-incorrect-hook is indeed supposed to work
> as you see, which is not what you want.  flyspell-incorrect-hook is
> called when Flyspell decides the word before point is mis-spelled and
> underlines it with that red wavy underline, and that happens as soon as
> you type C-t.

Indeed it does.

> I think you should figure out why the functions you used before no
> longer work and adapt them to Emacs 30, so you could keep using them
> as you did before.

It would appear that is my way forward.

> Because Flyspell and its hook will not allow you to have the same
> functionality if the ability to type C-t without having Flyspell
> intervene right away is not part of what
> flyspell-maybe-correct-transposition can offer.

OK.  I will interpret that as a definitive "no" answer to my original
question of "is there anything I can configure in flyspell to get what I
want.

> If you explain why auto-correct no longer works and show the details,
> maybe we can even find the solution as part of this discussion,
> although it will no longer be about a bug in Flyspell.

I will reset things back to how they were and wait for the problem to
repeat itself.  (Unfortunately, the error and subsequent backtrace are not
as easily reproducible as would be convenient.)

                                Jim