1
1
;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2
3
;; Copyright (C) 1994-1995, 1997-2014 Free Software Foundation, Inc.
3
;; Copyright (C) 1994-1995, 1997-2015 Free Software Foundation, Inc.
5
5
;; Author: Ken Stevens <k.stevens@ieee.org>
6
6
;; Maintainer: Ken Stevens <k.stevens@ieee.org>
1058
1058
"For aspell dictionary DICT-NAME, return a list of parameters if an
1059
1059
associated data file is found or nil otherwise. List format is that
1060
1060
of `ispell-dictionary-base-alist' elements."
1062
;; Make sure `ispell-aspell-dict-dir' is defined
1063
(or ispell-aspell-dict-dir
1064
(setq ispell-aspell-dict-dir
1065
(ispell-get-aspell-config-value "dict-dir")))
1061
1067
;; Make sure `ispell-aspell-data-dir' is defined
1062
1068
(or ispell-aspell-data-dir
1063
1069
(setq ispell-aspell-data-dir
1064
1070
(ispell-get-aspell-config-value "data-dir")))
1065
;; Try finding associated datafile
1067
(concat ispell-aspell-data-dir "/"
1068
;; Strip out variant, country code, etc.
1069
(and (string-match "^[[:alpha:]]+" dict-name)
1070
(match-string 0 dict-name)) ".dat"))
1072
(concat ispell-aspell-data-dir "/"
1073
;; Strip out anything but xx_YY.
1074
(and (string-match "^[[:alpha:]_]+" dict-name)
1075
(match-string 0 dict-name)) ".dat"))
1077
(if (file-readable-p datafile1)
1079
(if (file-readable-p datafile2)
1072
;; Try finding associated datafile. aspell will look for master .dat
1073
;; file in `dict-dir' and `data-dir'. Associated .dat files must be
1074
;; in the same directory as master file.
1077
(dolist ( tmp-path (list ispell-aspell-dict-dir
1078
ispell-aspell-data-dir ))
1079
;; Try xx.dat first, strip out variant, country code, etc,
1080
;; then try xx_YY.dat (without stripping country code).
1081
(dolist (tmp-regexp (list "^[[:alpha:]]+"
1084
(concat tmp-path "/"
1085
(and (string-match tmp-regexp dict-name)
1086
(match-string 0 dict-name)) ".dat")))
1087
(if (file-readable-p fullpath)
1088
(throw 'datafile fullpath)))))))
1084
1092
(with-temp-buffer
1130
1138
(realdict (assoc realname alist)))
1131
1139
(when (and realdict (not already-exists-p))
1132
1140
(push (cons aliasname (cdr realdict)) alist))))))
1141
;; Add entries for standard dict-names with found locale-matching entry
1142
(dolist (dict-map-entry ispell-dicts-name2locale-equivs-alist)
1143
(let ((name (car dict-map-entry))
1144
(locale (cadr dict-map-entry)))
1145
(unless (assoc name alist) ;; skip if already present
1146
(if (assoc locale alist)
1147
(push (cons name (cdr (assoc locale alist))) alist)))))
1135
1150
;; Make ispell.el work better with hunspell.
1153
1168
(if (cadr (assoc dict ispell-dictionary-alist))
1154
1169
(message "ispell-hfde: Non void entry for %s. Skipping.\n" dict)
1155
1170
(let ((dict-alias
1156
(cadr (assoc dict ispell-hunspell-dictionary-equivs-alist)))
1171
(cadr (assoc dict ispell-dicts-name2locale-equivs-alist)))
1157
1172
(use-for-dicts (list dict))
1158
1173
(dict-args-cdr (cdr (ispell-parse-hunspell-affix-file dict)))
1160
1175
;; Get a list of uninitialized dicts using the same affix file.
1161
(dolist (dict-equiv-alist-entry ispell-hunspell-dictionary-equivs-alist)
1176
(dolist (dict-equiv-alist-entry ispell-dicts-name2locale-equivs-alist)
1162
1177
(let ((dict-equiv-key (car dict-equiv-alist-entry))
1163
1178
(dict-equiv-value (cadr dict-equiv-alist-entry)))
1164
1179
(if (or (member dict dict-equiv-alist-entry)
1223
1238
"Look for installed hunspell dictionaries.
1224
1239
Will initialize `ispell-hunspell-dictionary-alist' and
1225
1240
`ispell-hunspell-dictionary-alist' after values found
1226
and remove `ispell-hunspell-dictionary-equivs-alist'
1241
and remove `ispell-dicts-name2locale-equivs-alist'
1227
1242
entries if a specific dict was found."
1228
1243
(let ((hunspell-found-dicts
1262
1277
"-- ispell-fhd: Skipping entry: %s\n" dict)))))
1263
1278
;; Remove entry from aliases alist if explicit dict was found.
1265
(dolist (dict ispell-hunspell-dictionary-equivs-alist)
1280
(dolist (dict ispell-dicts-name2locale-equivs-alist)
1266
1281
(if (assoc (car dict) ispell-hunspell-dict-paths-alist)
1267
1282
(ispell-print-if-debug
1268
1283
"-- ispell-fhd: Excluding %s alias. Standalone dict found.\n"
1270
1285
(add-to-list 'newlist dict)))
1271
(setq ispell-hunspell-dictionary-equivs-alist newlist))
1286
(setq ispell-dicts-name2locale-equivs-alist newlist))
1272
1287
;; Add known hunspell aliases
1273
(dolist (dict-equiv ispell-hunspell-dictionary-equivs-alist)
1288
(dolist (dict-equiv ispell-dicts-name2locale-equivs-alist)
1274
1289
(let ((dict-equiv-key (car dict-equiv))
1275
1290
(dict-equiv-value (cadr dict-equiv))
1276
1291
(exclude-aliases (list ;; Exclude TeX aliases
1367
1382
(let* ((dict-name (nth 0 adict))
1369
1384
(cadr (assoc dict-name
1370
ispell-hunspell-dictionary-equivs-alist)))
1385
ispell-dicts-name2locale-equivs-alist)))
1371
1386
(ispell-args (nth 5 adict))
1372
1387
(ispell-args-has-d (member "-d" ispell-args))