Initial support for hunspell dictionaries auto-detection (Bug#13639)
authorAgustín Martín <agustin.martin@hispalinux.es>
Thu, 28 Feb 2013 19:01:34 +0000 (20:01 +0100)
committerAgustín Martín <agustin.martin@hispalinux.es>
Thu, 28 Feb 2013 19:01:34 +0000 (20:01 +0100)
commitef3761e3f4407fdd4d7329d296a00f51c66b52ec
tree891c152bab7b8c905bbae6685df3bb4ff8233e0f
parent930de676ac040f3e459bbd1ddfec0aa36131297d
Initial support for hunspell dictionaries auto-detection (Bug#13639)

* textmodes/ispell.el (ispell-find-hunspell-dictionaries):
Ask hunspell about available and default dictionaries.
(ispell-parse-hunspell-affix-file): Extract relevant info from
hunspell affix file.
(ispell-hunspell-fill-dictionary-entry): Fill non-initialized
`ispell-dictionary-alist' entry for given dictionary after info
provided by `ispell-parse-hunspell-affix-file'.
(ispell-hunspell-dict-paths-alist): New defvar to contain an alist
of parsed hunspell dicts and associated affix files.
(ispell-hunspell-dictionary-alist): New defvar to contain an alist
of parsed hunspell dicts and associated parameters.
(ispell-set-spellchecker-params):
Call `ispell-find-hunspell-dictionaries' if hunspell and not
previously done.
(ispell-start-process):
Call `ispell-hunspell-fill-dictionary-entry' for current
dictionary if it is not initialized.

Some additional details about the implementation:

(ispell-hunspell-dict-paths-alist): Alist that contains a list of
  parsed hunspell dicts and associated affix files.

(ispell-hunspell-dictionary-alist): Alist of parsed hunspell dicts and
  associated parameters. It is initially just a list of found
  dictionaries except for the default dictionary where is filled with
  proper parameters.

When spellchecker is initialized by (ispell-set-spellchecker-params)
if the conditions: is hunspell, communication can be set to UTF-8 and
Emacs flavor supports [:alpha:] are matched installed hunspell
dictionaries are parsed and info passed to
`ispell-hunspell-dictionary-alist', either full for default dictionary
or just name for other dictionaries. These entries are used for
`ispell-dictionary-alist' if not overriden.

Before starting hunspell process in (ispell-start-process), if
`ispell-dictionary-alist' entry is not yet initialized
(ispell-hunspell-fill-dictionary-entry) is called to fill that entry
(and all pending entries using the same affix file) after info
extracted by (ispell-parse-hunspell-affix-file) from the associated
affix file.

hunspell process will then be started as usual. This delayed procedure
is used to avoid that in systems containing many hunspell dictionaries
all affix files are parsed (if there are many, time may be noticeable)
for just one used dictionary.
lisp/ChangeLog
lisp/textmodes/ispell.el