From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Changing dictionary while flyspell-buffer is running Date: Thu, 21 Feb 2019 16:59:17 +0200 Message-ID: <83y369fare.fsf@gnu.org> References: <874l8ztmgk.fsf@posteo.de> <83zhqqgzlk.fsf@gnu.org> <87y36as44p.fsf@posteo.de> <83o976gvd2.fsf@gnu.org> <87h8cxsed3.fsf@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="160961"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Titus von der Malsburg Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 21 16:00:26 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gwppp-000fg1-Lp for ged-emacs-devel@m.gmane.org; Thu, 21 Feb 2019 16:00:25 +0100 Original-Received: from localhost ([127.0.0.1]:33403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwppo-0005XA-IP for ged-emacs-devel@m.gmane.org; Thu, 21 Feb 2019 10:00:24 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwpoz-0005Vg-Q6 for emacs-devel@gnu.org; Thu, 21 Feb 2019 09:59:34 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:53631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwpoq-0001Ld-Vy; Thu, 21 Feb 2019 09:59:27 -0500 Original-Received: from [176.228.60.248] (port=3035 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gwpok-0000su-Kv; Thu, 21 Feb 2019 09:59:24 -0500 In-reply-to: <87h8cxsed3.fsf@posteo.de> (message from Titus von der Malsburg on Thu, 21 Feb 2019 10:03:04 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:233520 Archived-At: > From: Titus von der Malsburg > 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 > >> 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.)