Honestly, I don't know if this is a good way to solve this issue, but it works (though fragile) and it shows a method that is applicable in other case.
Test case (since the Young Grandfather (tYG) forgot to post one):
(setq ispell-program-name "hunspell")
You see what tYG talks about by evaluating and clicking
(Leave out the
hunspell part if that's better for you).
ispell-command-loop is very complicated, it's not easy to mess with its internals. But we can use a fragile advice around it, see
(info "(elisp) Advising Functions"). Note that we are using Stefan Monnier's new, hip and super-nice
(defun rasmus/ispell-loop-get-rid-of-misspeled-word (orig-fun &rest args)
"Around-advice to avoid the misspeled word when typing r in ispell."
(cl-letf* (((symbol-function #'read-string*) (symbol-function #'read-string))
(lambda (prompt &optional initial-input history default-value
(if (equal prompt "Replacement for: ")
(read-string* prompt initial-input history default-value
(apply orig-fun args)))
(advice-add 'ispell-command-loop :around
Run the test again. The misspelled word should be gone.
C-j. It should contain a line like
:around advice: `rasmus/ispell-loop-get-rid-of-misspeled-word'.