Subject: bug#32280: 26.1; FLYSPELL-BUFFER sometimes misbehaves for some input in a large enough buffer

From: Artem Boldarev <[email-masked]>
Date: Sat, 28 Jul 2018 03:00:20 +0300

Hello Eli,
> Can you post the text where this happens?
The text where I encountered the problem is a personal e-mail, so I can 
not share it as it is. I will try to craft a sample text and describe 
the steps for bug reproduction using emacs -Q.
> AFAICT, you have removed a single line:
>
> 			     (< found-length misspell-length)

I am also replaced:
;; Size matches, we really found it.
(= found-length misspell-length)

with

;; Size and content matches, we really found it.
  (and (= found-length misspell-length)
           (string= found word))

I believe, in this case there is no need in  (< found-length 
misspell-length) anymore.
> Can you take me through your reasoning why this line is incorrect, and
> what assumptions it made that are correct for English, but not for
> Russian?
As about my reasoning behind the changes: I felt that it is not right to 
mark the word as misspelt without actually checking the content. 
Moreover, look at the original comment right behind the (< found-length 
misspell-length) line:
                  ;; Misspelling has higher length than
                  ;; what flyspell considers the word.
                              ;; Caused by boundary-chars mismatch.
                              ;; Validating seems safe.
I am not sure that comparing length of found word and misspelt word is 
enough to make an assumption that validating is safe (even considering 
the preceding checks). The keyword here, I think, is 'seems'. For some 
reason, it really works most of the time.

I believe that the bug should be possible to reproduce for texts in 
English too. For some reason, I have not encountered this problem while 
spell checking English. I should note that flyspell-buffer works fine 
for *most* of the texts in Russian and Ukrainian which I have checked 
and the discussed issue is rarely encountered. I did not know that It 
exists until  I started using flyspell-buffer regularly.

Kind regards,
Artem