From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Titus von der Malsburg Newsgroups: gmane.emacs.devel Subject: Changing dictionary while flyspell-buffer is running Date: Tue, 19 Feb 2019 23:58:19 +0100 Message-ID: <874l8ztmgk.fsf@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="137896"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.1.0; emacs 26.1.91 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 19 23:59:17 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 1gwEM6-000ZjN-BS for ged-emacs-devel@m.gmane.org; Tue, 19 Feb 2019 23:59:14 +0100 Original-Received: from localhost ([127.0.0.1]:56180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwEM5-0000AX-2Q for ged-emacs-devel@m.gmane.org; Tue, 19 Feb 2019 17:59:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwELN-00008h-Nu for emacs-devel@gnu.org; Tue, 19 Feb 2019 17:58:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwELK-0007mT-Hq for emacs-devel@gnu.org; Tue, 19 Feb 2019 17:58:28 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:48799) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwELI-0007kr-5i for emacs-devel@gnu.org; Tue, 19 Feb 2019 17:58:24 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 7942316005D for ; Tue, 19 Feb 2019 23:58:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1550617100; bh=dRugcBrhuFaeaViDdKloqaeARlfGXAlBxPp+KIr8vV8=; h=From:To:Subject:Date:From; b=lnJPQ6E/aSjcNFt59qDm6FSza1ZG+4dxtCFMjJYIz6IxMoOOB/KoMNV6NQRD55o4Q ygoaVm2TZB826EIMVHpOwICyEcxifIyeMYdrloEs8Zjvw4kZolELKHShG96YUKic/6 ot2A5zNe7n6WEvrbaBVfXcrAvt7mnQ48jZpmvjM/gThNUQc3pbIipTO3Ail20vBNb5 Ae6OwIRv6zL0JG4SPcQN2iwFfg9SQdV9MWOpP6X1oiivnU0ISRwVJizFBY9nmu2BqU M0ltDHu/expVq/eOzr1TfPzVm2+s6SC+1jkR3cHP0/hyaZhGP5HTsx8KxwaNvXr3xF ebeG/WQgMR6cg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 443x3b5DsVz6tm5 for ; Tue, 19 Feb 2019 23:58:19 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 185.67.36.65 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:233476 Archived-At: Hi, I wrote a package called guess-language that automatically detects the language of what is being typed and then switches dictionaries for spell-checking as needed. The code relies on fylspell-incorrect-hook. Whenever this hook is triggered (i.e. when an unknown word is detected) the language of the current paragraph is checked and if it=E2=80=99s different from the currently configured languag= e, the dictionary is changed and the paragraph is rechecked. This works really nicely, especially with documents that contain paragraphs in multiple languages. Link to package: https://github.com/tmalsburg/guess-language.el/ My question relates to flyspell-buffer. When flyspell-buffer detects an incorrect word, language guessing is activated via fylspell-incorrect-hook but it=E2=80=99s not clear to me how to proceed nex= t. I think I=E2=80=99d have to kill the running ispell/aspell/hunspell process a= nd restart with the new dictionary from where we left off. Is there any infrastructure in Flyspell that makes this relatively easy and safe? I had a look at the code and it seems that there is quite a bit of state in various places, so it=E2=80=99s probably not just a matter of killing a process, and doing things cleanly might require better understanding of the internals than I have. Any advice one how to approach this would be appreciated. Best wishes, Titus -- Dr. Titus von der Malsburg Department of Linguistics University of Potsdam, Germany https://tmalsburg.github.io