From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Agustin Martin Newsgroups: gmane.emacs.bugs Subject: bug#13460: Issue to change dictionary when using hunspell on emacs Date: Fri, 18 Jan 2013 18:05:01 +0100 Message-ID: <20130118170501.GA9786@agmartin.aq.upm.es> References: <20130116122509.GA2209@omega.in.herr-schmitt.de> <83hamh80ry.fsf@gnu.org> <20130117131733.GA20519@omega.in.herr-schmitt.de> <20728.16566.19238.480349@gnu.org> <20130117193029.GB4933@agmartin.aq.upm.es> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" X-Trace: ger.gmane.org 1358528719 22900 80.91.229.3 (18 Jan 2013 17:05:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Jan 2013 17:05:19 +0000 (UTC) Cc: Jochen Schmitt To: 13460@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 18 18:05:37 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TwFNo-000177-Dl for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 Jan 2013 18:05:36 +0100 Original-Received: from localhost ([::1]:42782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwFNW-00032F-Vd for geb-bug-gnu-emacs@m.gmane.org; Fri, 18 Jan 2013 12:05:18 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37952) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwFNU-00031w-IO for bug-gnu-emacs@gnu.org; Fri, 18 Jan 2013 12:05:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TwFNT-0006QK-0x for bug-gnu-emacs@gnu.org; Fri, 18 Jan 2013 12:05:16 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwFNS-0006QD-Ud for bug-gnu-emacs@gnu.org; Fri, 18 Jan 2013 12:05:14 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TwFOD-00085r-Si for bug-gnu-emacs@gnu.org; Fri, 18 Jan 2013 12:06:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Agustin Martin Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Jan 2013 17:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13460 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13460-submit@debbugs.gnu.org id=B13460.135852875331094 (code B ref 13460); Fri, 18 Jan 2013 17:06:01 +0000 Original-Received: (at 13460) by debbugs.gnu.org; 18 Jan 2013 17:05:53 +0000 Original-Received: from localhost ([127.0.0.1]:38976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TwFO4-00085R-Su for submit@debbugs.gnu.org; Fri, 18 Jan 2013 12:05:53 -0500 Original-Received: from fibonacci.ccupm.upm.es ([138.100.198.70]:45326 helo=smtp.upm.es) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TwFO2-00085I-Hg for 13460@debbugs.gnu.org; Fri, 18 Jan 2013 12:05:52 -0500 Original-Received: from agmartin.aq.upm.es (Agmartin.aq.upm.es [138.100.41.131]) by smtp.upm.es (8.14.3/8.14.3/fibonacci-001) with ESMTP id r0IH51B8024377; Fri, 18 Jan 2013 18:05:01 +0100 Original-Received: by agmartin.aq.upm.es (Postfix, from userid 1000) id 5B8AC381; Fri, 18 Jan 2013 18:05:01 +0100 (CET) Content-Disposition: inline In-Reply-To: <20130117193029.GB4933@agmartin.aq.upm.es> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:69984 Archived-At: --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jan 17, 2013 at 08:30:29PM +0100, Agustin Martin wrote: > From: Jochen Schmitt > > > > I have try to create a suggestion for a general solution for > > this issue in the next release of emacs. > > > > I have attached a patch on this mail which introduced a alist to > > translate the dictionary names like 'english' in the form which will > > be accepted by hunspell. > > > > I have done a first short test to check out, that this is a > > working solution. > > > > Of course the ispell-hunspell-dictionary-alist need extension because > > I have put only two entries to be able to check out my solution. > > Hi Jochen. Thanks a lot for your feedback (and to Glenn for forwarding it), > you can send your followups to the bug address. > > I remember to have done some initial work with an alias file for hunspell, > but I do not find that now. > > I'd keep the name `ispell-hunspell-dictionary-alist' for the alist of > actually found dicts, once implemented in one way or another. I vaguely > remember using something like `ispell-hunspell-dictionary-equivs-alist' for > the purpose of having a list of equivalences. I'd also not hardcode nil to > "en_GB". > > For the rest I think it can be useful as a temporary workaround, but I'd > prefer to see these changes in a sanitized dictionary alist for hunspell, > something similar to what is done in `ispell-set-spellchecker-params' to use > [:alpha:] when possible, but for this purpose and limited to the original > base alist. Otherwise will only work for entries not using explicit "-d" > and may hide personal choices in ~/.emacs pointing to non-standard locations > (e.g., "american" using "~/personal/en_US". (Looked quickly, may be I missed > something) > > Let me try to find where I have my previous work and what is harder, try to > find the time. This should not be that time consuming, so I expect to look > at this shortly. I have been playing with this. Please see attached patch for current status. There are a couple of minor things I would like to think about first. Current changes explicitly set "english" to one of the two main choices ("en_GB"). This is not something I like very much and I am aware that people is sensitive about this. I'd prefer to associate it with plain "en", but hunspell has some pending issues regarding fallback values. Since there should be mapppings for all (but nil) default dict definitions, and this is only done for those dicts I am also considering to show an error if an expected mappping is not found, but this is a really minor internal issue just to help finding missing mappings early. I will test these changes a bit more and if no problems appear will commit early next week. Feedback is welcome. Thanks again for your suggestions. -- Agustin --dDRMvlgZJXvWKvBx Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ispell.el_hunspell-default-dict-names-mapping.diff" --- ispell.el.orig 2013-01-18 15:35:17.804804007 +0100 +++ ispell.el 2013-01-18 18:03:01.017847901 +0100 @@ -773,6 +773,41 @@ (make-obsolete-variable 'ispell-aspell-supports-utf8 'ispell-encoding8-command "23.1") +(defvar ispell-hunspell-dictionary-equivs-alist + '(("american" "en_US") + ("brasileiro" "pt_BR") + ("british" "en_GB") + ("castellano" "es_ES") + ("castellano8" "es_ES") + ("czech" "cs_CZ") + ("dansk" "da_DK") + ("deutsch" "de_DE") + ("deutsch8" "de_DE") + ("english" "en_GB") + ("esperanto" "eo") + ("esperanto-tex" "eo") + ("finnish" "fi_FI") + ("francais7" "fr_FR") + ("francais" "fr_FR") + ("francais-tex" "fr_FR") + ("german" "de_DE") + ("german8" "de_DE") + ("italiano" "it_IT") + ("nederlands" "nl_NL") + ("nederlands8" "nl_NL") + ("norsk" "nn_NO") + ("norsk7-tex" "nn_NO") + ("polish" "pl_PL") + ("portugues" "pt_PT") + ("russian" "ru_RU") + ("russianw" "ru_RU") + ("slovak" "sk_SK") + ("slovenian" "sl_SI") + ("svenska" "sv_SE") + ("hebrew" "he_IL")) + "Alist with matching hunspell dict names for standard dict names in + `ispell-dictionary-base-alist'.") + (defvar ispell-emacs-alpha-regexp (if (string-match "^[[:alpha:]]+$" "abcde") "[[:alpha:]]" @@ -1134,9 +1169,52 @@ ispell-encoding8-command) ispell-aspell-dictionary-alist nil)) + (ispell-dictionary-base-alist ispell-dictionary-base-alist) ispell-base-dicts-override-alist ; Override only base-dicts-alist all-dicts-alist) + ;; While ispell and aspell (through aliases) use the traditional + ;; dict naming originally expected by ispell.el, hunspell + ;; uses locale based names with no alias. We need to map + ;; standard names to locale based names to make default dict + ;; definitions available for hunspell. + (if ispell-really-hunspell + (let (tmp-dicts-alist) + (dolist (adict ispell-dictionary-base-alist) + (let* ((dict-name (nth 0 adict)) + (ispell-args (nth 5 adict)) + (ispell-args-has-d (member "-d" ispell-args))) + ;; Remove "-d" option from `ispell-args' if present + (if ispell-args-has-d + (let ((ispell-args-after-d + (cdr (cdr ispell-args-has-d))) + (ispell-args-before-d + (butlast ispell-args (length ispell-args-has-d)))) + (setq ispell-args + (nconc ispell-args-before-d + ispell-args-after-d)))) + ;; Unless default dict, re-add "-d" option with the mapped value + (if dict-name + (nconc ispell-args + (list "-d" + (or (cadr (assoc + dict-name + ispell-hunspell-dictionary-equivs-alist)) + dict-name)))) + + (add-to-list 'tmp-dicts-alist + (list + dict-name ; dict name + (nth 1 adict) ; casechars + (nth 2 adict) ; not-casechars + (nth 3 adict) ; otherchars + (nth 4 adict) ; many-otherchars-p + ispell-args ; ispell-args + (nth 6 adict) ; extended-character-mode + (nth 7 adict) ; dict encoding + ))) + (setq ispell-dictionary-base-alist tmp-dicts-alist)))) + (run-hooks 'ispell-initialize-spellchecker-hook) ;; Add dicts to ``ispell-dictionary-alist'' unless already present. --dDRMvlgZJXvWKvBx--