Function: ispell-aspell-find-dictionary
ispell-aspell-find-dictionary is a byte-compiled function defined in
ispell.el.gz.
Signature
(ispell-aspell-find-dictionary DICT-NAME)
Documentation
Return the list of parameters for an Aspell dictionary DICT-NAME.
List format is that of ispell-dictionary-base-alist elements. Return
nil if no associated data file is found for the dictionary.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/ispell.el.gz
(defun ispell-aspell-find-dictionary (dict-name)
"Return the list of parameters for an Aspell dictionary DICT-NAME.
List format is that of `ispell-dictionary-base-alist' elements. Return
nil if no associated data file is found for the dictionary."
;; Make sure `ispell-aspell-dict-dir' is defined
(or ispell-aspell-dict-dir
(setq ispell-aspell-dict-dir
(ispell-get-aspell-config-value "dict-dir")))
;; Make sure `ispell-aspell-data-dir' is defined
(or ispell-aspell-data-dir
(setq ispell-aspell-data-dir
(ispell-get-aspell-config-value "data-dir")))
;; Try finding associated datafile. aspell will look for master .dat
;; file in `dict-dir' and `data-dir'. Associated .dat files must be
;; in the same directory as master file.
(let ((data-file
(catch 'datafile
(dolist ( tmp-path (list ispell-aspell-dict-dir
ispell-aspell-data-dir ))
;; Try xx.dat first, strip out variant, country code, etc,
;; then try xx_YY.dat (without stripping country code),
;; then try xx-alt.dat, for de-alt etc.
(dolist (tmp-regexp (list "^[[:alpha:]]+"
"^[[:alpha:]_]+"
"^[[:alpha:]]+-\\(alt\\|old\\)"))
(let ((fullpath
(concat tmp-path "/"
(and (string-match tmp-regexp dict-name)
(match-string 0 dict-name)) ".dat")))
(if (file-readable-p fullpath)
(throw 'datafile fullpath)))))))
otherchars)
(if data-file
(with-temp-buffer
(insert-file-contents data-file)
;; There is zero or one line with special characters declarations.
(when (search-forward-regexp "^special" nil t)
(let ((specials (split-string
(buffer-substring (point)
(progn (end-of-line) (point))))))
;; The line looks like: special ' -** - -** . -** : -*-
;; -** means that this character
;; - doesn't appear at word start
;; * may appear in the middle of a word
;; * may appear at word end
;; `otherchars' is about the middle case.
(while specials
(when (eq (aref (cadr specials) 1) ?*)
(push (car specials) otherchars))
(setq specials (cddr specials)))))
(list dict-name
"[[:alpha:]]"
"[^[:alpha:]]"
(regexp-opt otherchars)
t ; We can't tell, so set this to t
(list "-d" dict-name)
nil ; aspell doesn't support this
;; Here we specify the encoding to use while communicating with
;; aspell. This doesn't apply to command line arguments, so
;; just don't pass words to spellcheck as arguments...
'utf-8)))))