diff options
| author | Agustín Martín | 2010-07-07 12:30:57 +0200 |
|---|---|---|
| committer | Agustín Martín | 2010-07-07 12:30:57 +0200 |
| commit | fd5539c6de4df242b517a73ced2fc1ff1f661227 (patch) | |
| tree | 3d6bc36b4b0d96283572ca0389ef76145c61172b /lisp/textmodes | |
| parent | ed3751c8245cbf523caf4975f654d459f070ea9a (diff) | |
| download | emacs-fd5539c6de4df242b517a73ced2fc1ff1f661227.tar.gz emacs-fd5539c6de4df242b517a73ced2fc1ff1f661227.zip | |
Improve ispell.el word completion handling.
* ispell.el (ispell-alternate-dictionary): Use file-readable-p.
Return nil if no word-list is found at default locations.
(ispell-complete-word-dict): Default to nil.
(ispell-command-loop): Use 'word-list' when using lookup-words.
(lookup-words): Use ispell-complete-word-dict or
ispell-alternate-dictionary. Check for word-list availability
and handle errors if needed with better messages (Bug#6539).
(ispell-complete-word): Use ispell-complete-word-dict or
ispell-alternate-dictionary.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/ispell.el | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index a9915fcfb17..ad591eb0e7f 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -357,21 +357,21 @@ Must be greater than 1." | |||
| 357 | :group 'ispell) | 357 | :group 'ispell) |
| 358 | 358 | ||
| 359 | (defcustom ispell-alternate-dictionary | 359 | (defcustom ispell-alternate-dictionary |
| 360 | (cond ((file-exists-p "/usr/dict/web2") "/usr/dict/web2") | 360 | (cond ((file-readable-p "/usr/dict/web2") "/usr/dict/web2") |
| 361 | ((file-exists-p "/usr/share/dict/web2") "/usr/share/dict/web2") | 361 | ((file-readable-p "/usr/share/dict/web2") "/usr/share/dict/web2") |
| 362 | ((file-exists-p "/usr/dict/words") "/usr/dict/words") | 362 | ((file-readable-p "/usr/dict/words") "/usr/dict/words") |
| 363 | ((file-exists-p "/usr/lib/dict/words") "/usr/lib/dict/words") | 363 | ((file-readable-p "/usr/lib/dict/words") "/usr/lib/dict/words") |
| 364 | ((file-exists-p "/usr/share/dict/words") "/usr/share/dict/words") | 364 | ((file-readable-p "/usr/share/dict/words") "/usr/share/dict/words") |
| 365 | ((file-exists-p "/usr/share/lib/dict/words") | 365 | ((file-readable-p "/usr/share/lib/dict/words") |
| 366 | "/usr/share/lib/dict/words") | 366 | "/usr/share/lib/dict/words") |
| 367 | ((file-exists-p "/sys/dict") "/sys/dict") | 367 | ((file-readable-p "/sys/dict") "/sys/dict")) |
| 368 | (t "/usr/dict/words")) | 368 | "*Alternate plain word-list dictionary for spelling help." |
| 369 | "*Alternate dictionary for spelling help." | ||
| 370 | :type '(choice file (const :tag "None" nil)) | 369 | :type '(choice file (const :tag "None" nil)) |
| 371 | :group 'ispell) | 370 | :group 'ispell) |
| 372 | 371 | ||
| 373 | (defcustom ispell-complete-word-dict ispell-alternate-dictionary | 372 | (defcustom ispell-complete-word-dict nil |
| 374 | "*Dictionary used for word completion." | 373 | "*Plain word-list dictionary used for word completion if |
| 374 | different from `ispell-alternate-dictionary'." | ||
| 375 | :type '(choice file (const :tag "None" nil)) | 375 | :type '(choice file (const :tag "None" nil)) |
| 376 | :group 'ispell) | 376 | :group 'ispell) |
| 377 | 377 | ||
| @@ -2049,10 +2049,11 @@ Global `ispell-quit' set to start location to continue spell session." | |||
| 2049 | (erase-buffer) | 2049 | (erase-buffer) |
| 2050 | (setq count ?0 | 2050 | (setq count ?0 |
| 2051 | skipped 0 | 2051 | skipped 0 |
| 2052 | mode-line-format | 2052 | mode-line-format ;; setup the *Choices* buffer with valid data. |
| 2053 | (concat "-- %b -- word: " new-word | 2053 | (concat "-- %b -- word: " new-word |
| 2054 | " -- dict: " | 2054 | " -- word-list: " |
| 2055 | ispell-alternate-dictionary) | 2055 | (or ispell-complete-word-dict |
| 2056 | ispell-alternate-dictionary)) | ||
| 2056 | miss (lookup-words new-word) | 2057 | miss (lookup-words new-word) |
| 2057 | choices miss | 2058 | choices miss |
| 2058 | line ispell-choices-win-default-height) | 2059 | line ispell-choices-win-default-height) |
| @@ -2267,11 +2268,20 @@ Otherwise the variable `ispell-grep-command' contains the command used to | |||
| 2267 | search for the words (usually egrep). | 2268 | search for the words (usually egrep). |
| 2268 | 2269 | ||
| 2269 | Optional second argument contains the dictionary to use; the default is | 2270 | Optional second argument contains the dictionary to use; the default is |
| 2270 | `ispell-alternate-dictionary'." | 2271 | `ispell-alternate-dictionary', overriden by `ispell-complete-word-dict' |
| 2272 | if defined." | ||
| 2271 | ;; We don't use the filter for this function, rather the result is written | 2273 | ;; We don't use the filter for this function, rather the result is written |
| 2272 | ;; into a buffer. Hence there is no need to save the filter values. | 2274 | ;; into a buffer. Hence there is no need to save the filter values. |
| 2273 | (if (null lookup-dict) | 2275 | (if (null lookup-dict) |
| 2274 | (setq lookup-dict ispell-alternate-dictionary)) | 2276 | (setq lookup-dict (or ispell-complete-word-dict |
| 2277 | ispell-alternate-dictionary))) | ||
| 2278 | |||
| 2279 | (if lookup-dict | ||
| 2280 | (unless (file-readable-p lookup-dict) | ||
| 2281 | (error "lookup-words error: Unreadable or missing plain word-list %s." | ||
| 2282 | lookup-dict)) | ||
| 2283 | (error (concat "lookup-words error: No plain word-list found at system default " | ||
| 2284 | "locations. Customize `ispell-alternate-dictionary' to set yours."))) | ||
| 2275 | 2285 | ||
| 2276 | (let* ((process-connection-type ispell-use-ptys-p) | 2286 | (let* ((process-connection-type ispell-use-ptys-p) |
| 2277 | (wild-p (string-match "\\*" word)) | 2287 | (wild-p (string-match "\\*" word)) |
| @@ -3342,7 +3352,8 @@ Standard ispell choices are then available." | |||
| 3342 | (lookup-words (concat (and interior-frag "*") word | 3352 | (lookup-words (concat (and interior-frag "*") word |
| 3343 | (if (or interior-frag (null ispell-look-p)) | 3353 | (if (or interior-frag (null ispell-look-p)) |
| 3344 | "*")) | 3354 | "*")) |
| 3345 | ispell-complete-word-dict))) | 3355 | (or ispell-complete-word-dict |
| 3356 | ispell-alternate-dictionary)))) | ||
| 3346 | (cond ((eq possibilities t) | 3357 | (cond ((eq possibilities t) |
| 3347 | (message "No word to complete")) | 3358 | (message "No word to complete")) |
| 3348 | ((null possibilities) | 3359 | ((null possibilities) |