emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111576: ispell.el: Make sure hunspel


From: Agustin Martin
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111576: ispell.el: Make sure hunspell specific dict names are used for standard dicts when using hunspell.
Date: Mon, 21 Jan 2013 17:05:30 +0100
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111576
fixes bug: http://debbugs.gnu.org/13460
committer: Agustin Martin <address@hidden>
branch nick: trunk
timestamp: Mon 2013-01-21 17:05:30 +0100
message:
  ispell.el: Make sure hunspell specific dict names are used for standard dicts 
when using hunspell.
  
  (ispell-hunspell-dictionary-equivs-alist):
    New variable to map standard dict names to hunspell ones.
  
  (ispell-set-spellchecker-params):
    Make sure specific dict names are used for standard dicts with hunspell.
  
    If a mapping is missing, skip that dictionary.
modified:
  lisp/ChangeLog
  lisp/textmodes/ispell.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-01-21 12:14:56 +0000
+++ b/lisp/ChangeLog    2013-01-21 16:05:30 +0000
@@ -1,3 +1,10 @@
+2013-01-21  Agustín Martín Domingo  <address@hidden>
+
+       * textmodes/ispell.el (ispell-hunspell-dictionary-equivs-alist):
+       New variable to map standard dict names to hunspell ones.
+       (ispell-set-spellchecker-params): Make sure specific dict names
+       are used for standard dicts with hunspell.
+
 2013-01-21  Tassilo Horn  <address@hidden>
 
        * textmodes/reftex-cite.el (reftex-format-citation): Add format

=== modified file 'lisp/textmodes/ispell.el'
--- a/lisp/textmodes/ispell.el  2013-01-11 23:08:55 +0000
+++ b/lisp/textmodes/ispell.el  2013-01-21 16:05:30 +0000
@@ -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_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-emacs-alpha-regexp
   (if (string-match "^[[:alpha:]]+$" "abcde")
       "[[:alpha:]]"
@@ -1134,9 +1169,57 @@
                    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))
+                    (dict-equiv
+                     (cadr (assoc dict-name
+                                  ispell-hunspell-dictionary-equivs-alist)))
+                    (ispell-args (nth 5 adict))
+                    (ispell-args-has-d (member "-d" ispell-args))
+                    skip-dict)
+               ;; 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
+                   (if dict-equiv
+                       (nconc ispell-args (list "-d" dict-equiv))
+                     (message
+                      "ispell-set-spellchecker-params: Missing hunspell equiv 
for \"%s\". Skipping."
+                      dict-name)
+                     (setq skip-dict t)))
+
+               (unless skip-dict
+                 (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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]