GNU bug report logs - #76884
30.1 problem with flyspell-maybe-correct-transposition

Previous Next

Package: emacs;

Reported by: Jim Diamond <jim <at> jdvb.ca>

Date: Sun, 9 Mar 2025 10:21:02 UTC

Severity: normal

Found in version 30.1

Full log


View this message in rfc822 format

From: Jim Diamond <jim <at> jdvb.ca>
To: 76884 <at> debbugs.gnu.org
Subject: bug#76884: 30.1 problem with flyspell-maybe-correct-transposition
Date: Sat, 8 Mar 2025 20:50:26 -0400
I recently upgraded to emacs 30.1.  For many years I had been using a
function which automatically corrected transposition errors, but it no
longer works in 30.1.  The author of that function kindly pointed me to the
fact that such functionality has been part of flyspell for a long time, and
that I should add
    (add-hook 'flyspell-incorrect-hook 'flyspell-maybe-correct-transposition)
to my init.el.

So I put that line in my init.el and started editing away, only to discover
that it doesn't do exactly what I want.  To reproduce the problem,


(1) Create a file ABC like this
----------------- cut here --------------------

ABC

----------------- cut here --------------------

(2) Replace your entire init.el with this one line:
(add-hook 'flyspell-incorrect-hook 'flyspell-maybe-correct-transposition)
(Or start with "emacs -Q" and make the "obvious" changes to the procedure
below.)

(3) Fire up a fresh emacs as follows:
emacs ABC

(4) Turn on flyspell
M-x flyspell-mode

(5) Navigate to the end of the 'abc' line

(6) Type Ctrl-T

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

Now, I know that "cab" is an English word, and that "acb" is not, and
I presume flyspell is looking at "ACB" immediately after I do the Ctrl-T
and "fixes" the resulting spelling error.

(Finance wonks may recognize ACB as the abbreviation for "adjusted cost
base", so it is something I might actually want to type.  Yes, I could add
ACB to my dictionary, but that doesn't solve the problem in general,
because there are lots of acronyms which are just one transposition away
from a "normal" word.)

With my old setup in emacs 28 and before, the transposition correction
function was triggered when emacs was about to see if there was an
abbreviation to expand, so if I was anticipating a problem I could
transpose two letters and then move away from the "word" using something
other than a space (e.g., arrow keys), and the text would stay how I wanted
it.

I posted this on gnu.emacs.help looking for a work-around, but a person
with far more emacs expertise than me said it was a bug and I should submit
a bug report.  Here it is.

Thanks.
                                Jim




This bug report was last modified 155 days ago.

Previous Next


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