diff options
| author | Eli Zaretskii | 2017-03-25 19:12:07 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-03-25 19:12:07 +0300 |
| commit | 501d07981ed1840ae72fe7dd599ab0b9f85b4a7f (patch) | |
| tree | c94b20174b2be584c8279e094119abcecd33fd6a | |
| parent | 541e950bdb495ea63420dcf80727cd0075d62e04 (diff) | |
| download | emacs-501d07981ed1840ae72fe7dd599ab0b9f85b4a7f.tar.gz emacs-501d07981ed1840ae72fe7dd599ab0b9f85b4a7f.zip | |
Support in ispell.el multiple dictionaries loaded by Hunspell
* lisp/textmodes/ispell.el (ispell-find-hunspell-dictionaries):
Support Hunspell configurations that load more than one dictionary
by default. Doc fix. (Bug#25830)
| -rw-r--r-- | lisp/textmodes/ispell.el | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 9747bd6cc12..db733fe661b 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -1094,10 +1094,10 @@ in the list must have an affix file where Hunspell affix files are kept." | |||
| 1094 | 1094 | ||
| 1095 | (defun ispell-find-hunspell-dictionaries () | 1095 | (defun ispell-find-hunspell-dictionaries () |
| 1096 | "Look for installed Hunspell dictionaries. | 1096 | "Look for installed Hunspell dictionaries. |
| 1097 | Will initialize `ispell-hunspell-dictionary-alist' and | 1097 | Will initialize `ispell-hunspell-dictionary-alist' according |
| 1098 | `ispell-hunspell-dictionary-alist' after values found | 1098 | to dictionaries found, and will remove aliases from the list |
| 1099 | and remove `ispell-dicts-name2locale-equivs-alist' | 1099 | in `ispell-dicts-name2locale-equivs-alist' if an explicit |
| 1100 | entries if a specific dictionary was found." | 1100 | dictionary from that list was found." |
| 1101 | (let ((hunspell-found-dicts | 1101 | (let ((hunspell-found-dicts |
| 1102 | (split-string | 1102 | (split-string |
| 1103 | (with-temp-buffer | 1103 | (with-temp-buffer |
| @@ -1110,18 +1110,27 @@ entries if a specific dictionary was found." | |||
| 1110 | "[\n\r]+" | 1110 | "[\n\r]+" |
| 1111 | t)) | 1111 | t)) |
| 1112 | hunspell-default-dict | 1112 | hunspell-default-dict |
| 1113 | hunspell-default-dict-entry) | 1113 | hunspell-default-dict-entry |
| 1114 | hunspell-multi-dict) | ||
| 1114 | (dolist (dict hunspell-found-dicts) | 1115 | (dolist (dict hunspell-found-dicts) |
| 1115 | (let* ((full-name (file-name-nondirectory dict)) | 1116 | (let* ((full-name (file-name-nondirectory dict)) |
| 1116 | (basename (file-name-sans-extension full-name)) | 1117 | (basename (file-name-sans-extension full-name)) |
| 1117 | (affix-file (concat dict ".aff"))) | 1118 | (affix-file (concat dict ".aff"))) |
| 1118 | (if (string-match "\\.aff$" dict) | 1119 | (if (string-match "\\.aff$" dict) |
| 1119 | ;; Found default dictionary | 1120 | ;; Found default dictionary |
| 1120 | (if hunspell-default-dict | 1121 | (progn |
| 1121 | (error "ispell-fhd: Default dict already defined as %s. Not using %s.\n" | 1122 | (if hunspell-default-dict |
| 1122 | hunspell-default-dict dict) | 1123 | (setq hunspell-multi-dict |
| 1123 | (setq affix-file dict) | 1124 | (concat (or hunspell-multi-dict |
| 1124 | (setq hunspell-default-dict (list basename affix-file))) | 1125 | (car hunspell-default-dict)) |
| 1126 | "," basename)) | ||
| 1127 | (setq affix-file dict) | ||
| 1128 | ;; FIXME: The cdr of the list we cons below is never | ||
| 1129 | ;; used. Why do we need a list? | ||
| 1130 | (setq hunspell-default-dict (list basename affix-file))) | ||
| 1131 | (ispell-print-if-debug | ||
| 1132 | "++ ispell-fhd: default dict-entry:%s name:%s basename:%s\n" | ||
| 1133 | dict full-name basename)) | ||
| 1125 | (if (and (not (assoc basename ispell-hunspell-dict-paths-alist)) | 1134 | (if (and (not (assoc basename ispell-hunspell-dict-paths-alist)) |
| 1126 | (file-exists-p affix-file)) | 1135 | (file-exists-p affix-file)) |
| 1127 | ;; Entry has an associated .aff file and no previous value. | 1136 | ;; Entry has an associated .aff file and no previous value. |
| @@ -1161,7 +1170,8 @@ entries if a specific dictionary was found." | |||
| 1161 | (cl-pushnew (list dict-equiv-key affix-file) | 1170 | (cl-pushnew (list dict-equiv-key affix-file) |
| 1162 | ispell-hunspell-dict-paths-alist :test #'equal))))) | 1171 | ispell-hunspell-dict-paths-alist :test #'equal))))) |
| 1163 | ;; Parse and set values for default dictionary. | 1172 | ;; Parse and set values for default dictionary. |
| 1164 | (setq hunspell-default-dict (car hunspell-default-dict)) | 1173 | (setq hunspell-default-dict (or hunspell-multi-dict |
| 1174 | (car hunspell-default-dict))) | ||
| 1165 | (setq hunspell-default-dict-entry | 1175 | (setq hunspell-default-dict-entry |
| 1166 | (ispell-parse-hunspell-affix-file hunspell-default-dict)) | 1176 | (ispell-parse-hunspell-affix-file hunspell-default-dict)) |
| 1167 | ;; Create an alist of found dicts with only names, except for default dict. | 1177 | ;; Create an alist of found dicts with only names, except for default dict. |