all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jochen Schmitt <Jochen@herr-schmitt.de>
To: 13460@debbugs.gnu.org
Subject: bug#13460: Issue to change dictionary when using hunspell on emacs
Date: Mon, 21 Jan 2013 10:43:40 +0100	[thread overview]
Message-ID: <20130121094338.GC1809@omega.in.herr-schmitt.de> (raw)
In-Reply-To: <20130118170501.GA9786@agmartin.aq.upm.es>

[-- Attachment #1: Type: text/plain, Size: 1209 bytes --]

On Fri, Jan 18, 2013 at 06:05:01PM +0100, Agustin Martin wrote:

> 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.

I have add a monor change to your suggested patch to generate
an error message, if a language doesn't exist in ispell-hunspell-equivs-alist.

My tests show, that this parch works as expected.

I have attached the modified version of the patch on this mail.

Best Regards:

Jochen Schmitt

[-- Attachment #2: emacs-24.2-hunspell.patch --]
[-- Type: text/plain, Size: 4375 bytes --]

diff -up emacs-24.2/lisp/textmodes/ispell.el.hunspell emacs-24.2/lisp/textmodes/ispell.el
--- emacs-24.2/lisp/textmodes/ispell.el.hunspell	2013-01-19 12:38:21.365802034 +0100
+++ emacs-24.2/lisp/textmodes/ispell.el	2013-01-19 14:32:10.527026717 +0100
@@ -572,6 +572,40 @@ re-start Emacs."
 		       (coding-system :tag "Coding System")))
   :group 'ispell)
 
+(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,en_US")
+    ("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-dictionary-base-alist
   '((nil
@@ -1077,9 +1111,15 @@ time, before `ispell-dictionary-alist' i
 sysadmins to override entries in `ispell-dictionary-base-alist'
 by putting those overrides in `ispell-base-dicts-override-alist', which is
 a dynamically scoped var with same format as `ispell-dictionary-alist'.
-This alist will not override the auto-detected values (e.g. if a recent
+This alist will no<<<<<<<<<<<<<t override the auto-detected values (e.g. if a recent
 aspell is used along with Emacs).")
 
+(defun ispell-hunspell-dictionary-option (dict)
+  (let ((ret (cadr (assoc dict ispell-hunspell-dictionary-equivs-alist))))
+       (list "-d" (if (null ret) 
+		      (error "Hunspell doesn't sopport dictionary '%s'" dict)
+		      ret))))
+
 (defun ispell-set-spellchecker-params ()
   "Initialize some spellchecker parameters when changed or first used."
   (unless (eq ispell-last-program-name ispell-program-name)
@@ -1106,9 +1146,47 @@ aspell is used along with Emacs).")
 		    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
+			   (ispell-hunspell-dictionary-option 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.

  parent reply	other threads:[~2013-01-21  9:43 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16 12:25 bug#13460: Issue to change dictionary when using hunspell on emacs Jochen Schmitt
2013-01-16 18:01 ` Eli Zaretskii
2013-01-16 23:23   ` Glenn Morris
2013-01-17  3:51     ` Eli Zaretskii
2013-01-17  6:37       ` Glenn Morris
2013-01-17 12:26         ` Agustin Martin
2013-01-17 15:24           ` Agustin Martin
2013-01-17 16:31             ` Stefan Monnier
2013-01-17 18:15               ` Agustin Martin
2013-01-17 16:41             ` Eli Zaretskii
2013-01-17 18:12               ` Agustin Martin
2013-01-17 18:42                 ` Eli Zaretskii
     [not found]                 ` <11624660.12538.1358448223517.JavaMail.root@mx1-new.spamfiltro.es>
2013-01-17 19:06                   ` Agustin Martin
2013-01-17 19:36                     ` Eli Zaretskii
2013-01-17 18:08             ` Glenn Morris
     [not found]             ` <7076415.12428.1358446115519.JavaMail.root@mx1-new.spamfiltro.es>
2013-01-17 18:44               ` Agustin Martin
2013-01-17 16:10           ` Eli Zaretskii
     [not found]     ` <20130117131733.GA20519@omega.in.herr-schmitt.de>
2013-01-17 18:19       ` Glenn Morris
2013-01-17 19:30         ` Agustin Martin
2013-01-18 17:05           ` Agustin Martin
2013-01-18 18:03             ` Jochen Schmitt
2013-01-18 19:03               ` Eli Zaretskii
2013-01-18 19:23                 ` Agustin Martin
2013-01-18 19:05               ` Agustin Martin
2013-01-21 16:52                 ` Agustin Martin
2013-01-21  9:43             ` Jochen Schmitt [this message]
2013-02-20 17:50 ` bug#13639: [emacs] ispell.el: hunspell dicts autodetection under Emacs Agustin Martin
2013-02-20 19:00   ` Eli Zaretskii
2013-02-28 19:23     ` Agustin Martin
2013-02-28 20:26       ` Eli Zaretskii
2013-04-15 10:18       ` Agustin Martin
2013-04-04 14:41 ` bug#13639: " Jacek Chrząszcz
2013-04-05 15:57   ` Agustin Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130121094338.GC1809@omega.in.herr-schmitt.de \
    --to=jochen@herr-schmitt.de \
    --cc=13460@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.