From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#25830: 25.2; ispell doesn't parse hunspell dictionaries properly Date: Mon, 27 Feb 2017 17:54:44 +0200 Message-ID: <83poi3pr23.fsf@gnu.org> References: <20170221091857.GA4096@wheatley> <83k28jo3ur.fsf@gnu.org> <20170221202454.GA30086@wheatley> <83fuj7tgto.fsf@gnu.org> <20170222104025.GA3557@wheatley> <83d1eatcxo.fsf@gnu.org> <20170222164310.GA3470@wheatley> <83efymsmnt.fsf@gnu.org> <20170225121523.GA9164@wheatley> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1488211137 25718 195.159.176.226 (27 Feb 2017 15:58:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 27 Feb 2017 15:58:57 +0000 (UTC) Cc: 25830@debbugs.gnu.org To: Martin Kletzander Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 27 16:58:51 2017 Return-path: Envelope-to: geb-bug-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 1ciNh9-000597-Kp for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Feb 2017 16:58:39 +0100 Original-Received: from localhost ([::1]:53880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciNhF-0002gh-Li for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Feb 2017 10:58:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciNdf-0007nH-7S for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2017 10:55:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciNde-0001yO-6y for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2017 10:55:03 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60266) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ciNde-0001yG-3J for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2017 10:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ciNdd-000865-TJ for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2017 10:55:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Feb 2017 15:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25830 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25830-submit@debbugs.gnu.org id=B25830.148821089931114 (code B ref 25830); Mon, 27 Feb 2017 15:55:01 +0000 Original-Received: (at 25830) by debbugs.gnu.org; 27 Feb 2017 15:54:59 +0000 Original-Received: from localhost ([127.0.0.1]:58464 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ciNdb-00085m-A0 for submit@debbugs.gnu.org; Mon, 27 Feb 2017 10:54:59 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ciNdZ-00085Y-2L for 25830@debbugs.gnu.org; Mon, 27 Feb 2017 10:54:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciNdQ-0001vo-35 for 25830@debbugs.gnu.org; Mon, 27 Feb 2017 10:54:52 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59915) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciNdP-0001vk-VS; Mon, 27 Feb 2017 10:54:48 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2756 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ciNdP-00086v-A5; Mon, 27 Feb 2017 10:54:47 -0500 In-reply-to: <20170225121523.GA9164@wheatley> (message from Martin Kletzander on Sat, 25 Feb 2017 13:15:23 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129884 Archived-At: > Date: Sat, 25 Feb 2017 13:15:23 +0100 > From: Martin Kletzander > Cc: 25830@debbugs.gnu.org > > >Thanks. I'll look into invoking ispell-hunspell-add-multi-dic > >automatically when we find more than one dictionary loaded by > >Hunspell, as it reports when invoked with the -D option. > > Thank you. Feel free too Cc me on any patch for that, I'll gladly test > it out (and learn more about the underlying code). Please try the patch below. (If it doesn't apply to your version of ispell.el, tell me which version of Emacs you have, and I will try to produce a compatible patch.) TIA --- lisp/textmodes/ispell.el~0 2017-01-08 06:23:52.000000000 +0200 +++ lisp/textmodes/ispell.el 2017-02-27 17:42:50.340586100 +0200 @@ -829,6 +829,15 @@ (fboundp 'accept-process-output)) "Non-nil means that the OS supports asynchronous processes.") +(defvar ispell-current-dictionary nil + "The name of the current dictionary, or nil for the default. +This is passed to the Ispell process using the `-d' switch and is +used as key in `ispell-local-dictionary-alist' and `ispell-dictionary-alist'.") + +(defvar ispell-current-personal-dictionary nil + "The name of the current personal dictionary, or nil for the default. +This is passed to the Ispell process using the `-p' switch.") + ;; Make ispell.el work better with aspell. (defvar ispell-aspell-dictionary-alist nil @@ -1087,6 +1096,7 @@ (ispell-find-hunspell-dictionaries) (setq ispell-dictionary-alist ispell-hunspell-dictionary-alist)) (or (assoc first-dict ispell-local-dictionary-alist) + (assoc first-dict ispell-hunspell-dictionary-alist) (assoc first-dict ispell-dictionary-alist) (error "Unknown dictionary: %s" first-dict))) (cl-pushnew (list dict '()) ispell-dictionary-alist :test #'equal) @@ -1110,18 +1120,25 @@ "[\n\r]+" t)) hunspell-default-dict - hunspell-default-dict-entry) + hunspell-default-dict-entry + hunspell-multi-dict) (dolist (dict hunspell-found-dicts) (let* ((full-name (file-name-nondirectory dict)) (basename (file-name-sans-extension full-name)) (affix-file (concat dict ".aff"))) (if (string-match "\\.aff$" dict) ;; Found default dictionary - (if hunspell-default-dict - (error "ispell-fhd: Default dict already defined as %s. Not using %s.\n" - hunspell-default-dict dict) - (setq affix-file dict) - (setq hunspell-default-dict (list basename affix-file))) + (progn + (if hunspell-default-dict + (setq hunspell-multi-dict + (concat (or hunspell-multi-dict + (car hunspell-default-dict)) + "," basename)) + (setq affix-file dict) + (setq hunspell-default-dict (list basename affix-file))) + (ispell-print-if-debug + "++ ispell-fhd: default dict-entry:%s name:%s basename:%s\n" + dict full-name basename)) (if (and (not (assoc basename ispell-hunspell-dict-paths-alist)) (file-exists-p affix-file)) ;; Entry has an associated .aff file and no previous value. @@ -1171,7 +1188,12 @@ (cl-pushnew (if (string= dict hunspell-default-dict) hunspell-default-dict-entry (list dict)) - ispell-hunspell-dictionary-alist :test #'equal)))) + ispell-hunspell-dictionary-alist :test #'equal)) + ;; If we found more than one loaded dictionary, set up for using + ;; multiple dictionaries. + (when hunspell-multi-dict + (ispell-hunspell-add-multi-dic hunspell-multi-dict) + (setq ispell-current-dictionary hunspell-multi-dict)))) ;; Set params according to the selected spellchecker @@ -1416,15 +1438,6 @@ ;;; ********************************************************************** -(defvar ispell-current-dictionary nil - "The name of the current dictionary, or nil for the default. -This is passed to the Ispell process using the `-d' switch and is -used as key in `ispell-local-dictionary-alist' and `ispell-dictionary-alist'.") - -(defvar ispell-current-personal-dictionary nil - "The name of the current personal dictionary, or nil for the default. -This is passed to the Ispell process using the `-p' switch.") - (defun ispell-decode-string (str) "Decodes multibyte character strings." (decode-coding-string str (ispell-get-coding-system)))