[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing dictionary while flyspell-buffer is running

From: Eli Zaretskii
Subject: Re: Changing dictionary while flyspell-buffer is running
Date: Thu, 21 Feb 2019 16:59:17 +0200

> From: Titus von der Malsburg <address@hidden>
> Date: Thu, 21 Feb 2019 10:03:04 +0100
> [Note: The last to message in this branch were off list.  My fault.]
> On 2019-02-21 Thu 04:36, Eli Zaretskii wrote:
> > [Why personal email?]
> >
> >> From: Titus von der Malsburg <address@hidden>
> >> Date: Wed, 20 Feb 2019 21:14:14 +0100
> >> 
> >> > Then why do you use flyspell-buffer and not flyspell-region, each time
> >> > starting the region from the word where you decided to switch to
> >> > another language?
> >> 
> >> That’s actually what happens when people just type: my package detects a
> >> new language and then just rechecks that paragraph.  However, some users
> >> of my package are used to doing flyspell-buffer on complete files, and
> >> when they do that, they don’t get the result they expect (which is that
> >> each paragraph is checked in its own language).  Checking a whole
> >> document with multiple languages does sound like a reasonable use case
> >> to me.
> >
> > Sorry, I still don't understand.  When the user runs flyspell-buffer,
> > and you find that the language was changed, invoke
> > ispell-change-dictionary and after that invoke flyspell-region to
> > continue spell-checking from that place to the end of the document.
> > Repeat as needed.  Wouldn't this algorithm work for your use case?
> This algorithm does do the job, but when the language changes a lot in a
> document it would be inefficient.  Lets say you have 10 paragraphs, each
> in a different language, then you’d check the last paragraphs 10 times
> and only in the last pass with the correct language.  Guess-language was
> written primarily to facilitate work with such multilingual documents.
> (I’m a linguist.)  So that’s not a satisfying solution.

You don't have to end the region at the end of the document, you can
end it when your language guess changes.

> I can come up with a more efficient algorithm, no problem.  It’s just
> that it would be the easiest and most efficient solution, if I could
> just abort and restart spell-checking when a change in language is
> detected.  If flyspell doesn’t support this (aborting), tough luck.

Doesn't calling ispell-change-dictionary "abort" spell-checking
anyway?  If it doesn't, can you show a recipe to see this in action?

(I never use flyspell-buffer, so changing the dictionary is trivial,
and restarts the speller as side effect.)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]