• flyspell woe

    From Jim@zsd@jdvb.ca to gnu.emacs.help on Sat Mar 8 11:59:44 2025
    From Newsgroup: gnu.emacs.help

    Just in case anyone still checks this group...

    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 in my init.el and started typing away, only to discover that
    it doesn't do exactly what I want. To reproduce the problem,

    (1) Replace your entire init.el with this one line:
    (add-hook 'flyspell-incorrect-hook 'flyspell-maybe-correct-transposition)


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

    ABC

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

    (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
    I get "CAB", whereas I expect "ACB".

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

    With my old setup in emacs 28.2, the transposition correction function was
    only triggered when I typed a space (or maybe some other word-ending character), so 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 don't immediately see any way to get the previous behaviour I liked.
    Can anyone suggest a way to do this?

    (And if you are wondering... I rarely want to have "ACB", but I was typing
    a message with some other three-letter acronym which kept getting changed
    by flyspell, and getting the actual TLA that I wanted was a nuisance.)

    Thanks.

    Jim
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Alan Mackenzie@acm@muc.de to gnu.emacs.help on Sat Mar 8 19:23:34 2025
    From Newsgroup: gnu.emacs.help

    Jim <zsd@jdvb.ca> wrote:
    Just in case anyone still checks this group...

    :-)

    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 in my init.el and started typing away, only to discover that
    it doesn't do exactly what I want. To reproduce the problem,

    (1) Replace your entire init.el with this one line:
    (add-hook 'flyspell-incorrect-hook 'flyspell-maybe-correct-transposition)


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

    ABC

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

    (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
    I get "CAB", whereas I expect "ACB".

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

    With my old setup in emacs 28.2, the transposition correction function was only triggered when I typed a space (or maybe some other word-ending character), so 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 don't immediately see any way to get the previous behaviour I liked.
    Can anyone suggest a way to do this?

    What you have typed in this post is very close to a perfect bug report.
    As an ex Emacs developer, I would suggest you submit a bug report for
    this. It feels like somebody decided to make flyspell "nicer" without
    thinking things through thoroughly.

    To submit a bug, either (preferred) M-x report-emacs-bug followed by
    doing the obvious (if you use Emacs for email), or just send an email to bug-gnu-emacs@gnu.org. Either should get you an immediate
    acknowledgement, followed by a proper reply as soon as somebody actually
    looks at it. This time is usually less than the previous sentence makes
    it sound.

    (And if you are wondering... I rarely want to have "ACB", but I was typing
    a message with some other three-letter acronym which kept getting changed
    by flyspell, and getting the actual TLA that I wanted was a nuisance.)

    A bug indeed!

    Thanks.

    Jim
    --
    Alan Mackenzie (Nuremberg, Germany).

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Jim Diamond@zsd@jdvb.ca to gnu.emacs.help on Sun Mar 9 18:09:54 2025
    From Newsgroup: gnu.emacs.help

    On 2025-03-08 at 15:23 AST, Alan Mackenzie <acm@muc.de> wrote:
    Jim <zsd@jdvb.ca> wrote:
    Just in case anyone still checks this group...

    :-)

    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 in my init.el and started typing away, only to discover that >> it doesn't do exactly what I want. To reproduce the problem,

    (1) Replace your entire init.el with this one line:
    (add-hook 'flyspell-incorrect-hook 'flyspell-maybe-correct-transposition)


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

    ABC

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

    (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
    I get "CAB", whereas I expect "ACB".

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

    With my old setup in emacs 28.2, the transposition correction function was >> only triggered when I typed a space (or maybe some other word-ending
    character), so 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 don't immediately see any way to get the previous behaviour I liked.
    Can anyone suggest a way to do this?

    What you have typed in this post is very close to a perfect bug report.
    As an ex Emacs developer, I would suggest you submit a bug report for
    this. It feels like somebody decided to make flyspell "nicer" without thinking things through thoroughly.

    To submit a bug, either (preferred) M-x report-emacs-bug followed by
    doing the obvious (if you use Emacs for email), or just send an email to bug-gnu-emacs@gnu.org. Either should get you an immediate
    acknowledgement, followed by a proper reply as soon as somebody actually looks at it. This time is usually less than the previous sentence makes
    it sound.

    (And if you are wondering... I rarely want to have "ACB", but I was typing >> a message with some other three-letter acronym which kept getting changed
    by flyspell, and getting the actual TLA that I wanted was a nuisance.)

    A bug indeed!

    Thanks for the suggestion. I reported a bug, but was firmly informed that
    it isn't a bug. So I will try to see what the problem with the old code
    is. Time to knock some of the rust off my elisp skills.

    Cheers.
    Jim
    --- Synchronet 3.21d-Linux NewsLink 1.2