textmodes/ispell.el: Look for aspell .dat files also under dict-dir, as aspell does.

Originally reported as http://bugs.debian.org/765349.
Noticed when aspell has different data-dir and dict-dir.

* textmodes/ispell.el (ispell-aspell-find-dictionary): Make sure
.dat files for aspell dicts are also searched for in location
described by `ispell-aspell-dict-dir', matching aspell's dict-dir
variable.
This commit is contained in:
Agustin Martin Domingo 2015-03-03 13:12:38 +01:00
parent e28ec9a430
commit c4ade119cc
2 changed files with 32 additions and 17 deletions

View file

@ -1,3 +1,10 @@
2015-03-03 Agustín Martín Domingo <agustin6martin@gmail.com>
* textmodes/ispell.el (ispell-aspell-find-dictionary): Make sure
.dat files for aspell dicts are also searched for in location
described by `ispell-aspell-dict-dir', matching aspell's dict-dir
variable.
2015-03-03 Agustín Martín Domingo <agustin6martin@gmail.com> 2015-03-03 Agustín Martín Domingo <agustin6martin@gmail.com>
* textmodes/ispell.el (ispell-dicts-name2locale-equivs-alist) * textmodes/ispell.el (ispell-dicts-name2locale-equivs-alist)

View file

@ -1058,27 +1058,35 @@ Assumes that value contains no whitespace."
"For aspell dictionary DICT-NAME, return a list of parameters if an "For aspell dictionary DICT-NAME, return a list of parameters if an
associated data file is found or nil otherwise. List format is that associated data file is found or nil otherwise. List format is that
of `ispell-dictionary-base-alist' elements." of `ispell-dictionary-base-alist' elements."
;; 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 ;; Make sure `ispell-aspell-data-dir' is defined
(or ispell-aspell-data-dir (or ispell-aspell-data-dir
(setq ispell-aspell-data-dir (setq ispell-aspell-data-dir
(ispell-get-aspell-config-value "data-dir"))) (ispell-get-aspell-config-value "data-dir")))
;; Try finding associated datafile
(let* ((datafile1 ;; Try finding associated datafile. aspell will look for master .dat
(concat ispell-aspell-data-dir "/" ;; file in `dict-dir' and `data-dir'. Associated .dat files must be
;; Strip out variant, country code, etc. ;; in the same directory as master file.
(and (string-match "^[[:alpha:]]+" dict-name) (let ((data-file
(match-string 0 dict-name)) ".dat")) (catch 'datafile
(datafile2 (dolist ( tmp-path (list ispell-aspell-dict-dir
(concat ispell-aspell-data-dir "/" ispell-aspell-data-dir ))
;; Strip out anything but xx_YY. ;; Try xx.dat first, strip out variant, country code, etc,
(and (string-match "^[[:alpha:]_]+" dict-name) ;; then try xx_YY.dat (without stripping country code).
(match-string 0 dict-name)) ".dat")) (dolist (tmp-regexp (list "^[[:alpha:]]+"
(data-file "^[[:alpha:]_]+"))
(if (file-readable-p datafile1) (let ((fullpath
datafile1 (concat tmp-path "/"
(if (file-readable-p datafile2) (and (string-match tmp-regexp dict-name)
datafile2))) (match-string 0 dict-name)) ".dat")))
otherchars) (if (file-readable-p fullpath)
(throw 'datafile fullpath)))))))
otherchars)
(if data-file (if data-file
(with-temp-buffer (with-temp-buffer