Subject: Fwd: Flyspell error traversal additions

From: Stefan Kangas <[email-masked]>
Date: Tue, 7 Sep 2021 02:22:29 +0200

X-Debbugs-CC: Roni Kallio <[email-masked]>

This was sent to emacs-devel, but never followed up.  I'm forwarding
to the bug tracker so that we don't lose track of it.

---------- Forwarded message ---------
Från: Roni Kallio <[email-masked]>
Date: tors 28 jan. 2021 kl 14:59
Subject: Flyspell error traversal additions
To: <[email-masked]>

While consolidating my spell/syntax checking setup, I noticed that
flyspell lacks a command to jump to the nearest error that is before the
point in a buffer.  There exists `flyspell-goto-next-error', which of
course loops back to beginning when the end of the buffer is reached,
but no equivalent command for going backwards.

I have attached a patch that implements backwards traversal, making sure
it acts analogous to `flyspell-goto-next-error'.  I'd like to open a
discussion on whether it would be feasible to have a key binding in
`flyspell-mode-map' for this command.  For reference, the bindings
currently are:

C-;   -- flyspell-auto-correct-previous-word
C-,   -- flyspell-goto-next-error
C-.   -- flyspell-auto-correct-word
C-c $ -- flyspell-correct-word-before-point

IMO the best course of action would be to modify
`flyspell-goto-next-error' to accept a prefix argument.  The prefix
would control the direction and number of jumps performed; negative
arguments would jump backwards -ARG errors (by calling
flyspell-goto-previous-error), while positive arguments would jump
forwards ARG errors.  This would be similar to how commands like
`forward-word' handle prefix arguments.  This would allow us to leave
the mode-map unchanged, but still distribute the improvement to all
users.

--
Roni Kallio