diff options
| author | Agustín Martín | 2010-10-18 18:01:43 +0200 |
|---|---|---|
| committer | Agustín Martín | 2010-10-18 18:01:43 +0200 |
| commit | df987d70a30d886cf9a54b94b4ddcc88c965ce07 (patch) | |
| tree | d04c02ef825cc5f7a253590f3e29f361a089349b /lisp/textmodes | |
| parent | b41c2f6580dd2b02e7f062bcc5d9707f86a13586 (diff) | |
| download | emacs-df987d70a30d886cf9a54b94b4ddcc88c965ce07.tar.gz emacs-df987d70a30d886cf9a54b94b4ddcc88c965ce07.zip | |
ispell.el (ispell-aspell-find-dictionary): Fix aspell data file search (bug#7230).
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/ispell.el | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index c773aadd3d8..d1dd5b05723 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -983,19 +983,32 @@ Assumes that value contains no whitespace." | |||
| 983 | (car (split-string (buffer-string))))) | 983 | (car (split-string (buffer-string))))) |
| 984 | 984 | ||
| 985 | (defun ispell-aspell-find-dictionary (dict-name) | 985 | (defun ispell-aspell-find-dictionary (dict-name) |
| 986 | ;; This returns nil if the data file does not exist. | 986 | "For aspell dictionary DICT-NAME, return a list of parameters if an |
| 987 | ;; Can someone please explain the return value format when the | 987 | associated data file is found or nil otherwise. List format is |
| 988 | ;; file does exist -- rms? | 988 | that of `ispell-dictionary-base-alist' elements." |
| 989 | (let* ((lang ;; Strip out variant, etc. | 989 | ;; Make sure `ispell-aspell-data-dir' is defined |
| 990 | (and (string-match "^[[:alpha:]_]+" dict-name) | 990 | (or ispell-aspell-data-dir |
| 991 | (match-string 0 dict-name))) | 991 | (setq ispell-aspell-data-dir |
| 992 | (ispell-get-aspell-config-value "data-dir"))) | ||
| 993 | ;; Try finding associated datafile | ||
| 994 | (let* ((datafile1 | ||
| 995 | (concat ispell-aspell-data-dir "/" | ||
| 996 | ;; Strip out variant, country code, etc. | ||
| 997 | (and (string-match "^[[:alpha:]]+" dict-name) | ||
| 998 | (match-string 0 dict-name)) ".dat")) | ||
| 999 | (datafile2 | ||
| 1000 | (concat ispell-aspell-data-dir "/" | ||
| 1001 | ;; Strip out anything but xx_YY. | ||
| 1002 | (and (string-match "^[[:alpha:]_]+" dict-name) | ||
| 1003 | (match-string 0 dict-name)) ".dat")) | ||
| 992 | (data-file | 1004 | (data-file |
| 993 | (concat (or ispell-aspell-data-dir | 1005 | (if (file-readable-p datafile1) |
| 994 | (setq ispell-aspell-data-dir | 1006 | datafile1 |
| 995 | (ispell-get-aspell-config-value "data-dir"))) | 1007 | (if (file-readable-p datafile2) |
| 996 | "/" lang ".dat")) | 1008 | datafile2))) |
| 997 | otherchars) | 1009 | otherchars) |
| 998 | (condition-case () | 1010 | |
| 1011 | (if data-file | ||
| 999 | (with-temp-buffer | 1012 | (with-temp-buffer |
| 1000 | (insert-file-contents data-file) | 1013 | (insert-file-contents data-file) |
| 1001 | ;; There is zero or one line with special characters declarations. | 1014 | ;; There is zero or one line with special characters declarations. |
| @@ -1023,9 +1036,7 @@ Assumes that value contains no whitespace." | |||
| 1023 | ;; Here we specify the encoding to use while communicating with | 1036 | ;; Here we specify the encoding to use while communicating with |
| 1024 | ;; aspell. This doesn't apply to command line arguments, so | 1037 | ;; aspell. This doesn't apply to command line arguments, so |
| 1025 | ;; just don't pass words to spellcheck as arguments... | 1038 | ;; just don't pass words to spellcheck as arguments... |
| 1026 | 'utf-8)) | 1039 | 'utf-8))))) |
| 1027 | (file-error | ||
| 1028 | nil)))) | ||
| 1029 | 1040 | ||
| 1030 | (defun ispell-aspell-add-aliases (alist) | 1041 | (defun ispell-aspell-add-aliases (alist) |
| 1031 | "Find aspell's dictionary aliases and add them to dictionary ALIST. | 1042 | "Find aspell's dictionary aliases and add them to dictionary ALIST. |