Function: ispell-set-spellchecker-params
ispell-set-spellchecker-params is a byte-compiled function defined in
ispell.el.gz.
Signature
(ispell-set-spellchecker-params)
Documentation
Initialize some spellchecker parameters when changed or first used.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/ispell.el.gz
(defun ispell-set-spellchecker-params ()
"Initialize some spellchecker parameters when changed or first used."
(unless (equal ispell-last-program-name ispell-program-name)
(ispell-kill-ispell t)
(if (and (condition-case ()
(progn
(setq ispell-library-directory (ispell-check-version))
t)
(error nil))
(or ispell-encoding8-command ispell-really-enchant))
;; auto-detection will only be used if spellchecker is not
;; ispell and supports a way to set communication to UTF-8.
(if ispell-really-aspell
(or ispell-aspell-dictionary-alist
(ispell-find-aspell-dictionaries))
(if ispell-really-hunspell
(or ispell-hunspell-dictionary-alist
(ispell-find-hunspell-dictionaries))
(if ispell-really-enchant
(or ispell-enchant-dictionary-alist
(ispell-find-enchant-dictionaries))))))
;; Substitute ispell-dictionary-alist with the list of
;; dictionaries corresponding to the given spellchecker.
;; With programs that support it, use the list of really
;; installed dictionaries and add to it elements of the original
;; list that are not present there. Allow distro info.
(let ((found-dicts-alist
(if ispell-encoding8-command
(if ispell-really-aspell
ispell-aspell-dictionary-alist
(if ispell-really-hunspell
ispell-hunspell-dictionary-alist))
(if ispell-really-enchant
ispell-enchant-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 & Enchant
;; use locale-based names with no alias. We need to map
;; standard names to locale based names to make default dict
;; definitions available to these programs.
(if (or ispell-really-hunspell ispell-really-enchant)
(let (tmp-dicts-alist)
(dolist (adict ispell-dictionary-base-alist)
(let* ((dict-name (nth 0 adict))
(dict-equiv
(cadr (assoc dict-name
ispell-dicts-name2locale-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
(setq ispell-args
(nconc ispell-args (list "-d" dict-equiv)))
(message
"ispell-set-spellchecker-params: Missing equivalent for \"%s\". Skipping."
dict-name)
(setq skip-dict t)))
(unless skip-dict
(cl-pushnew (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
)
tmp-dicts-alist :test #'equal)))
(setq ispell-dictionary-base-alist tmp-dicts-alist))))
(run-hooks 'ispell-initialize-spellchecker-hook)
;; Add dicts to `ispell-dictionary-alist' unless already present.
(dolist (dict (append found-dicts-alist
ispell-base-dicts-override-alist
ispell-dictionary-base-alist))
(unless (assoc (car dict) all-dicts-alist)
(push dict all-dicts-alist)))
(setq ispell-dictionary-alist all-dicts-alist))
;; If spellchecker supports UTF-8 via command-line option, use it
;; in communication. This does not affect definitions in your
;; init file.
(let (tmp-dicts-alist)
(dolist (adict ispell-dictionary-alist)
(cl-pushnew (if (cadr adict) ;; Do not touch hunspell uninitialized entries
(list
(nth 0 adict) ; dict name
(nth 1 adict) ; casechars
(nth 2 adict) ; not-casechars
(nth 3 adict) ; otherchars
(nth 4 adict) ; many-otherchars-p
(nth 5 adict) ; ispell-args
(nth 6 adict) ; extended-character-mode
(if (or ispell-encoding8-command ispell-really-enchant)
'utf-8
(nth 7 adict)))
adict)
tmp-dicts-alist :test #'equal))
(setq ispell-dictionary-alist tmp-dicts-alist)))
(setq ispell-last-program-name ispell-program-name))