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

From: Artem Boldarev <[email-masked]>
Date: Sun, 29 Jul 2018 17:09:54 +0300

Hello,

I have crafted some sample data as well as wrote instruction how to 
reproduce the bug.

The sample file can be found by following this link:

https://chaoticlab.io/pub/flyspell-bug/flyspell-sample.txt

The instruction alongside with the required code can be downloaded from 
here:

https://chaoticlab.io/pub/flyspell-bug/flyspell-bug-reproduction.el

I made some screenshots which demonstrate the bug:

https://chaoticlab.io/pub/flyspell-bug/flyspell-bug-linux.png
https://chaoticlab.io/pub/flyspell-bug/flyspell-bug-windows.png

I haven't been able to demonstrate the case when a misspelt word is not 
highlighted though. I will send an update should I craft the required data.

I hope this is helpful.

Regards,
Artem

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