From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Hunspell for Japanese Date: Sun, 18 Feb 2018 17:59:59 +0200 Message-ID: <83d112b85c.fsf@gnu.org> References: <2D3482A4-0F9A-4D09-86C2-958AB03FA388@misasa.okayama-u.ac.jp> <20180218.143156.2077820890057474242.tkk@misasa.okayama-u.ac.jp> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1518969530 16867 195.159.176.226 (18 Feb 2018 15:58:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 18 Feb 2018 15:58:50 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 18 16:58:46 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1enRMG-0003Iz-5N for geh-help-gnu-emacs@m.gmane.org; Sun, 18 Feb 2018 16:58:32 +0100 Original-Received: from localhost ([::1]:40715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1enROI-0000b0-Bw for geh-help-gnu-emacs@m.gmane.org; Sun, 18 Feb 2018 11:00:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1enRNe-0000Zu-8W for help-gnu-emacs@gnu.org; Sun, 18 Feb 2018 10:59:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1enRNb-0000Ha-2p for help-gnu-emacs@gnu.org; Sun, 18 Feb 2018 10:59:58 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:42096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1enRNa-0000HU-UQ for help-gnu-emacs@gnu.org; Sun, 18 Feb 2018 10:59:55 -0500 Original-Received: from [176.228.60.248] (port=1185 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1enRNa-0000UV-8C for help-gnu-emacs@gnu.org; Sun, 18 Feb 2018 10:59:54 -0500 In-reply-to: <20180218.143156.2077820890057474242.tkk@misasa.okayama-u.ac.jp> (message from Tak Kunihiro on Sun, 18 Feb 2018 14:31:56 +0900 (JST)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:116034 Archived-At: > Date: Sun, 18 Feb 2018 14:31:56 +0900 (JST) > Cc: tkk@misasa.okayama-u.ac.jp > From: Tak Kunihiro > > (defvar ispell-regexp-non-ascii "[^\000-\377]+" > "Regular expression to match a non-ascii word.") > (add-to-list 'ispell-skip-region-alist (list ispell-regexp-non-ascii)) > > Once I accept this solution for M-x spell-buffer, I would accept a > solution for flyspell-mode as shown below. > > (defun flyspell-skip-non-ascii (beg end info) > "Tell flyspell to skip a non-ascii word. > Call this on `flyspell-incorrect-hook'." > (string-match ispell-regexp-non-ascii (buffer-substring beg end))) > (add-hook 'flyspell-incorrect-hook 'flyspell-skip-non-ascii) > > It took me a while to figure this out. I think that what M-x > ispell-buffer and flyspell-mode provide is fundamental functionalities > and it is good to be documented in somewhere in Emacs such for (info > "(emacs) Spelling"). Can you give suggestion? On the Wiki? You see, the solution you propose has one significant disadvantage: it will skip words used in English prose which are written using non-ASCII characters. It's true that there aren't many of those, but they do exist. You could try instead use 2 dictionaries at the same time, one for English, the other for Japanese. This will only work with Hunspell, and only in Emacs 26 or later. Caveat: I never tried it with these two languages, so I don't know whether this combination has some subtle problems with that feature.