diff options
| author | Stefan Monnier | 2016-04-18 12:27:58 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2016-04-18 12:27:58 -0400 |
| commit | 03887a1932e30da3f77f4ba80f67affb330ec56c (patch) | |
| tree | 42c60014f0f22217a71060794ec3c8512f75c3d6 | |
| parent | 531c9a43ad91aa979f02651b135f9e7c3446996f (diff) | |
| download | emacs-03887a1932e30da3f77f4ba80f67affb330ec56c.tar.gz emacs-03887a1932e30da3f77f4ba80f67affb330ec56c.zip | |
* lisp/textmodes/ispell.el: Compile with lexical-binding
(declare-function): Don't define any more.
(ispell-check-minver, ispell-looking-back): Tweak definition so that
the compiler can obviously know that it's always defined.
(ispell-debug-buffer): Declare var.
(ispell-hunspell-fill-dictionary-entry)
(ispell-parse-hunspell-affix-file, ispell-hunspell-add-multi-dic)
(ispell-find-hunspell-dictionaries, ispell-set-spellchecker-params)
(ispell-command-loop): Avoid add-to-list on local variables.
| -rw-r--r-- | lisp/textmodes/ispell.el | 213 |
1 files changed, 104 insertions, 109 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 5a1f4736aff..a139c061f59 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2 | 1 | ;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2 -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1994-1995, 1997-2016 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1994-1995, 1997-2016 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -46,9 +46,9 @@ | |||
| 46 | ;; your own dictionaries. | 46 | ;; your own dictionaries. |
| 47 | 47 | ||
| 48 | ;; Depending on the mail system you use, you may want to include these: | 48 | ;; Depending on the mail system you use, you may want to include these: |
| 49 | ;; (add-hook 'news-inews-hook 'ispell-message) | 49 | ;; (add-hook 'news-inews-hook #'ispell-message) |
| 50 | ;; (add-hook 'mail-send-hook 'ispell-message) | 50 | ;; (add-hook 'mail-send-hook #'ispell-message) |
| 51 | ;; (add-hook 'mh-before-send-letter-hook 'ispell-message) | 51 | ;; (add-hook 'mh-before-send-letter-hook #'ispell-message) |
| 52 | 52 | ||
| 53 | ;; Ispell has a TeX parser and a nroff parser (the default). | 53 | ;; Ispell has a TeX parser and a nroff parser (the default). |
| 54 | ;; The parsing is controlled by the variable ispell-parser. Currently | 54 | ;; The parsing is controlled by the variable ispell-parser. Currently |
| @@ -196,54 +196,46 @@ | |||
| 196 | ;; Fixed bug in returning to nroff mode from tex mode. | 196 | ;; Fixed bug in returning to nroff mode from tex mode. |
| 197 | 197 | ||
| 198 | ;;; Compatibility code for XEmacs and (not too) older emacsen: | 198 | ;;; Compatibility code for XEmacs and (not too) older emacsen: |
| 199 | 199 | (defalias 'ispell-check-minver | |
| 200 | (eval-and-compile ;; Protect against declare-function undefined in XEmacs | 200 | (if (fboundp 'version<=) 'version<= |
| 201 | (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) | 201 | (lambda (minver version) |
| 202 | 202 | "Check if string VERSION is at least string MINVER. | |
| 203 | (declare-function ispell-check-minver "ispell" (v1 v2)) | ||
| 204 | (declare-function ispell-looking-back "ispell" | ||
| 205 | (regexp &optional limit &rest ignored)) | ||
| 206 | |||
| 207 | (if (fboundp 'version<=) | ||
| 208 | (defalias 'ispell-check-minver 'version<=) | ||
| 209 | (defun ispell-check-minver (minver version) | ||
| 210 | "Check if string VERSION is at least string MINVER. | ||
| 211 | Both must be in [0-9]+.[0-9]+... format. This is a fallback | 203 | Both must be in [0-9]+.[0-9]+... format. This is a fallback |
| 212 | compatibility function in case `version<=' is not available." | 204 | compatibility function in case `version<=' is not available." |
| 213 | (let ((pending t) | 205 | (let ((pending t) |
| 214 | (return t) | 206 | (return t) |
| 215 | start-ver start-mver) | 207 | start-ver start-mver) |
| 216 | ;; Loop until an absolute greater or smaller condition is reached | 208 | ;; Loop until an absolute greater or smaller condition is reached |
| 217 | ;; or until no elements are left in any of version and minver. In | 209 | ;; or until no elements are left in any of version and minver. In |
| 218 | ;; this case version is exactly the minimal, so return OK. | 210 | ;; this case version is exactly the minimal, so return OK. |
| 219 | (while pending | 211 | (while pending |
| 220 | (let (ver mver) | 212 | (let (ver mver) |
| 221 | (if (string-match "[0-9]+" version start-ver) | 213 | (if (string-match "[0-9]+" version start-ver) |
| 222 | (setq start-ver (match-end 0) | 214 | (setq start-ver (match-end 0) |
| 223 | ver (string-to-number (match-string 0 version)))) | 215 | ver (string-to-number (match-string 0 version)))) |
| 224 | (if (string-match "[0-9]+" minver start-mver) | 216 | (if (string-match "[0-9]+" minver start-mver) |
| 225 | (setq start-mver (match-end 0) | 217 | (setq start-mver (match-end 0) |
| 226 | mver (string-to-number (match-string 0 minver)))) | 218 | mver (string-to-number (match-string 0 minver)))) |
| 227 | 219 | ||
| 228 | (if (or ver mver) | 220 | (if (or ver mver) |
| 229 | (progn | 221 | (progn |
| 230 | (or ver (setq ver 0)) | 222 | (or ver (setq ver 0)) |
| 231 | (or mver (setq mver 0)) | 223 | (or mver (setq mver 0)) |
| 232 | ;; If none of below conditions match, this element is the | 224 | ;; If none of below conditions match, this element is the |
| 233 | ;; same. Go checking next element. | 225 | ;; same. Go checking next element. |
| 234 | (if (> ver mver) | 226 | (if (> ver mver) |
| 235 | (setq pending nil) | 227 | (setq pending nil) |
| 236 | (if (< ver mver) | 228 | (if (< ver mver) |
| 237 | (setq pending nil | 229 | (setq pending nil |
| 238 | return nil)))) | 230 | return nil)))) |
| 239 | (setq pending nil)))) | 231 | (setq pending nil)))) |
| 240 | return))) | 232 | return)))) |
| 241 | 233 | ||
| 242 | ;; XEmacs does not have looking-back | 234 | ;; XEmacs does not have looking-back |
| 243 | (if (fboundp 'looking-back) | 235 | (defalias 'ispell-looking-back |
| 244 | (defalias 'ispell-looking-back 'looking-back) | 236 | (if (fboundp 'looking-back) 'looking-back |
| 245 | (defun ispell-looking-back (regexp &optional limit &rest ignored) | 237 | (lambda (regexp &optional limit &rest ignored) |
| 246 | "Return non-nil if text before point matches regular expression REGEXP. | 238 | "Return non-nil if text before point matches regular expression REGEXP. |
| 247 | Like `looking-at' except matches before point, and is slower. | 239 | Like `looking-at' except matches before point, and is slower. |
| 248 | LIMIT if non-nil speeds up the search by specifying a minimum | 240 | LIMIT if non-nil speeds up the search by specifying a minimum |
| 249 | starting position, to avoid checking matches that would start | 241 | starting position, to avoid checking matches that would start |
| @@ -251,8 +243,8 @@ before LIMIT. | |||
| 251 | 243 | ||
| 252 | This is a stripped down compatibility function for use when | 244 | This is a stripped down compatibility function for use when |
| 253 | full featured `looking-back' function is missing." | 245 | full featured `looking-back' function is missing." |
| 254 | (save-excursion | 246 | (save-excursion |
| 255 | (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t)))) | 247 | (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t))))) |
| 256 | 248 | ||
| 257 | ;;; XEmacs21 does not have `with-no-warnings'. Taken from org mode. | 249 | ;;; XEmacs21 does not have `with-no-warnings'. Taken from org mode. |
| 258 | (defmacro ispell-with-no-warnings (&rest body) | 250 | (defmacro ispell-with-no-warnings (&rest body) |
| @@ -260,6 +252,8 @@ full featured `looking-back' function is missing." | |||
| 260 | 252 | ||
| 261 | ;;; Code: | 253 | ;;; Code: |
| 262 | 254 | ||
| 255 | (eval-when-compile (require 'cl-lib)) | ||
| 256 | |||
| 263 | (defvar mail-yank-prefix) | 257 | (defvar mail-yank-prefix) |
| 264 | 258 | ||
| 265 | (defgroup ispell nil | 259 | (defgroup ispell nil |
| @@ -942,6 +936,8 @@ Otherwise returns the library directory name, if that is defined." | |||
| 942 | (setq default-directory (expand-file-name "~/"))) | 936 | (setq default-directory (expand-file-name "~/"))) |
| 943 | (apply 'call-process-region args))) | 937 | (apply 'call-process-region args))) |
| 944 | 938 | ||
| 939 | (defvar ispell-debug-buffer) | ||
| 940 | |||
| 945 | (defun ispell-create-debug-buffer (&optional append) | 941 | (defun ispell-create-debug-buffer (&optional append) |
| 946 | "Create an ispell debug buffer for debugging output. | 942 | "Create an ispell debug buffer for debugging output. |
| 947 | If APPEND is non-nil, append the info to previous buffer if exists, | 943 | If APPEND is non-nil, append the info to previous buffer if exists, |
| @@ -1182,15 +1178,15 @@ all uninitialized dicts using that affix file." | |||
| 1182 | (if (cadr (assoc tmp-dict ispell-dictionary-alist)) | 1178 | (if (cadr (assoc tmp-dict ispell-dictionary-alist)) |
| 1183 | (ispell-print-if-debug | 1179 | (ispell-print-if-debug |
| 1184 | "ispell-hfde: %s already expanded; skipping.\n" tmp-dict) | 1180 | "ispell-hfde: %s already expanded; skipping.\n" tmp-dict) |
| 1185 | (add-to-list 'use-for-dicts tmp-dict)))))) | 1181 | (cl-pushnew tmp-dict use-for-dicts :test #'equal)))))) |
| 1186 | (ispell-print-if-debug | 1182 | (ispell-print-if-debug |
| 1187 | "ispell-hfde: Filling %s entry. Use for %s.\n" dict use-for-dicts) | 1183 | "ispell-hfde: Filling %s entry. Use for %s.\n" dict use-for-dicts) |
| 1188 | ;; The final loop. | 1184 | ;; The final loop. |
| 1189 | (dolist (entry ispell-dictionary-alist) | 1185 | (dolist (entry ispell-dictionary-alist) |
| 1190 | (if (member (car entry) use-for-dicts) | 1186 | (cl-pushnew (if (member (car entry) use-for-dicts) |
| 1191 | (add-to-list 'newlist | 1187 | (cons (car entry) dict-args-cdr) |
| 1192 | (append (list (car entry)) dict-args-cdr)) | 1188 | entry) |
| 1193 | (add-to-list 'newlist entry))) | 1189 | newlist :test #'equal)) |
| 1194 | (setq ispell-dictionary-alist newlist)))) | 1190 | (setq ispell-dictionary-alist newlist)))) |
| 1195 | 1191 | ||
| 1196 | (defun ispell-parse-hunspell-affix-file (dict-key) | 1192 | (defun ispell-parse-hunspell-affix-file (dict-key) |
| @@ -1235,7 +1231,7 @@ did." | |||
| 1235 | (chars-list (append otherchars-string nil))) | 1231 | (chars-list (append otherchars-string nil))) |
| 1236 | (setq chars-list (delq ?\ chars-list)) | 1232 | (setq chars-list (delq ?\ chars-list)) |
| 1237 | (dolist (ch chars-list) | 1233 | (dolist (ch chars-list) |
| 1238 | (add-to-list 'otherchars-list ch))))) | 1234 | (cl-pushnew ch otherchars-list :test #'equal))))) |
| 1239 | ;; Cons the argument for the -d switch. | 1235 | ;; Cons the argument for the -d switch. |
| 1240 | (setq dict-arg (concat dict-arg | 1236 | (setq dict-arg (concat dict-arg |
| 1241 | (if (> (length dict-arg) 0) ",") | 1237 | (if (> (length dict-arg) 0) ",") |
| @@ -1246,7 +1242,7 @@ did." | |||
| 1246 | "[[:alpha:]]" | 1242 | "[[:alpha:]]" |
| 1247 | "[^[:alpha:]]" | 1243 | "[^[:alpha:]]" |
| 1248 | (if otherchars-list | 1244 | (if otherchars-list |
| 1249 | (regexp-opt (mapcar 'char-to-string otherchars-list)) | 1245 | (regexp-opt (mapcar #'char-to-string otherchars-list)) |
| 1250 | "") | 1246 | "") |
| 1251 | t ; many-otherchars-p: We can't tell, set to t. | 1247 | t ; many-otherchars-p: We can't tell, set to t. |
| 1252 | (list "-d" dict-arg) | 1248 | (list "-d" dict-arg) |
| @@ -1268,7 +1264,7 @@ in the list must have an affix file where Hunspell affix files are kept." | |||
| 1268 | (or (assoc first-dict ispell-local-dictionary-alist) | 1264 | (or (assoc first-dict ispell-local-dictionary-alist) |
| 1269 | (assoc first-dict ispell-dictionary-alist) | 1265 | (assoc first-dict ispell-dictionary-alist) |
| 1270 | (error "Unknown dictionary: %s" first-dict))) | 1266 | (error "Unknown dictionary: %s" first-dict))) |
| 1271 | (add-to-list 'ispell-dictionary-alist (list dict '())) | 1267 | (cl-pushnew (list dict '()) ispell-dictionary-alist :test #'equal) |
| 1272 | (ispell-hunspell-fill-dictionary-entry dict)) | 1268 | (ispell-hunspell-fill-dictionary-entry dict)) |
| 1273 | 1269 | ||
| 1274 | (defun ispell-find-hunspell-dictionaries () | 1270 | (defun ispell-find-hunspell-dictionaries () |
| @@ -1308,8 +1304,8 @@ entries if a specific dictionary was found." | |||
| 1308 | (ispell-print-if-debug | 1304 | (ispell-print-if-debug |
| 1309 | "++ ispell-fhd: dict-entry:%s name:%s basename:%s affix-file:%s\n" | 1305 | "++ ispell-fhd: dict-entry:%s name:%s basename:%s affix-file:%s\n" |
| 1310 | dict full-name basename affix-file) | 1306 | dict full-name basename affix-file) |
| 1311 | (add-to-list 'ispell-hunspell-dict-paths-alist | 1307 | (cl-pushnew (list basename affix-file) |
| 1312 | (list basename affix-file))) | 1308 | ispell-hunspell-dict-paths-alist :test #'equal)) |
| 1313 | (ispell-print-if-debug | 1309 | (ispell-print-if-debug |
| 1314 | "-- ispell-fhd: Skipping entry: %s\n" dict))))) | 1310 | "-- ispell-fhd: Skipping entry: %s\n" dict))))) |
| 1315 | ;; Remove entry from aliases alist if explicit dict was found. | 1311 | ;; Remove entry from aliases alist if explicit dict was found. |
| @@ -1319,7 +1315,7 @@ entries if a specific dictionary was found." | |||
| 1319 | (ispell-print-if-debug | 1315 | (ispell-print-if-debug |
| 1320 | "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n" | 1316 | "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n" |
| 1321 | (car dict)) | 1317 | (car dict)) |
| 1322 | (add-to-list 'newlist dict))) | 1318 | (cl-pushnew dict newlist :test #'equal))) |
| 1323 | (setq ispell-dicts-name2locale-equivs-alist newlist)) | 1319 | (setq ispell-dicts-name2locale-equivs-alist newlist)) |
| 1324 | ;; Add known hunspell aliases | 1320 | ;; Add known hunspell aliases |
| 1325 | (dolist (dict-equiv ispell-dicts-name2locale-equivs-alist) | 1321 | (dolist (dict-equiv ispell-dicts-name2locale-equivs-alist) |
| @@ -1337,22 +1333,20 @@ entries if a specific dictionary was found." | |||
| 1337 | ispell-hunspell-dict-paths-alist)))) | 1333 | ispell-hunspell-dict-paths-alist)))) |
| 1338 | (ispell-print-if-debug "++ ispell-fhd: Adding alias %s -> %s.\n" | 1334 | (ispell-print-if-debug "++ ispell-fhd: Adding alias %s -> %s.\n" |
| 1339 | dict-equiv-key affix-file) | 1335 | dict-equiv-key affix-file) |
| 1340 | (add-to-list | 1336 | (cl-pushnew (list dict-equiv-key affix-file) |
| 1341 | 'ispell-hunspell-dict-paths-alist | 1337 | ispell-hunspell-dict-paths-alist :test #'equal))))) |
| 1342 | (list dict-equiv-key affix-file)))))) | ||
| 1343 | ;; Parse and set values for default dictionary. | 1338 | ;; Parse and set values for default dictionary. |
| 1344 | (setq hunspell-default-dict (car hunspell-default-dict)) | 1339 | (setq hunspell-default-dict (car hunspell-default-dict)) |
| 1345 | (setq hunspell-default-dict-entry | 1340 | (setq hunspell-default-dict-entry |
| 1346 | (ispell-parse-hunspell-affix-file hunspell-default-dict)) | 1341 | (ispell-parse-hunspell-affix-file hunspell-default-dict)) |
| 1347 | ;; Create an alist of found dicts with only names, except for default dict. | 1342 | ;; Create an alist of found dicts with only names, except for default dict. |
| 1348 | (setq ispell-hunspell-dictionary-alist | 1343 | (setq ispell-hunspell-dictionary-alist |
| 1349 | (list (append (list nil) (cdr hunspell-default-dict-entry)))) | 1344 | (list (cons nil (cdr hunspell-default-dict-entry)))) |
| 1350 | (dolist (dict (mapcar 'car ispell-hunspell-dict-paths-alist)) | 1345 | (dolist (dict (mapcar #'car ispell-hunspell-dict-paths-alist)) |
| 1351 | (if (string= dict hunspell-default-dict) | 1346 | (cl-pushnew (if (string= dict hunspell-default-dict) |
| 1352 | (add-to-list 'ispell-hunspell-dictionary-alist | 1347 | hunspell-default-dict-entry |
| 1353 | hunspell-default-dict-entry) | 1348 | (list dict)) |
| 1354 | (add-to-list 'ispell-hunspell-dictionary-alist | 1349 | ispell-hunspell-dictionary-alist :test #'equal)))) |
| 1355 | (list dict)))))) | ||
| 1356 | 1350 | ||
| 1357 | ;; Set params according to the selected spellchecker | 1351 | ;; Set params according to the selected spellchecker |
| 1358 | 1352 | ||
| @@ -1443,17 +1437,17 @@ aspell is used along with Emacs).") | |||
| 1443 | (setq skip-dict t))) | 1437 | (setq skip-dict t))) |
| 1444 | 1438 | ||
| 1445 | (unless skip-dict | 1439 | (unless skip-dict |
| 1446 | (add-to-list 'tmp-dicts-alist | 1440 | (cl-pushnew (list |
| 1447 | (list | 1441 | dict-name ; dict name |
| 1448 | dict-name ; dict name | 1442 | (nth 1 adict) ; casechars |
| 1449 | (nth 1 adict) ; casechars | 1443 | (nth 2 adict) ; not-casechars |
| 1450 | (nth 2 adict) ; not-casechars | 1444 | (nth 3 adict) ; otherchars |
| 1451 | (nth 3 adict) ; otherchars | 1445 | (nth 4 adict) ; many-otherchars-p |
| 1452 | (nth 4 adict) ; many-otherchars-p | 1446 | ispell-args ; ispell-args |
| 1453 | ispell-args ; ispell-args | 1447 | (nth 6 adict) ; extended-character-mode |
| 1454 | (nth 6 adict) ; extended-character-mode | 1448 | (nth 7 adict) ; dict encoding |
| 1455 | (nth 7 adict) ; dict encoding | 1449 | ) |
| 1456 | )))) | 1450 | tmp-dicts-alist :test #'equal))) |
| 1457 | (setq ispell-dictionary-base-alist tmp-dicts-alist)))) | 1451 | (setq ispell-dictionary-base-alist tmp-dicts-alist)))) |
| 1458 | 1452 | ||
| 1459 | (run-hooks 'ispell-initialize-spellchecker-hook) | 1453 | (run-hooks 'ispell-initialize-spellchecker-hook) |
| @@ -1463,7 +1457,7 @@ aspell is used along with Emacs).") | |||
| 1463 | ispell-base-dicts-override-alist | 1457 | ispell-base-dicts-override-alist |
| 1464 | ispell-dictionary-base-alist)) | 1458 | ispell-dictionary-base-alist)) |
| 1465 | (unless (assoc (car dict) all-dicts-alist) | 1459 | (unless (assoc (car dict) all-dicts-alist) |
| 1466 | (add-to-list 'all-dicts-alist dict))) | 1460 | (push dict all-dicts-alist))) |
| 1467 | (setq ispell-dictionary-alist all-dicts-alist)) | 1461 | (setq ispell-dictionary-alist all-dicts-alist)) |
| 1468 | 1462 | ||
| 1469 | ;; If Emacs flavor supports [:alpha:] use it for global dicts. If | 1463 | ;; If Emacs flavor supports [:alpha:] use it for global dicts. If |
| @@ -1473,20 +1467,20 @@ aspell is used along with Emacs).") | |||
| 1473 | (if ispell-emacs-alpha-regexp | 1467 | (if ispell-emacs-alpha-regexp |
| 1474 | (let (tmp-dicts-alist) | 1468 | (let (tmp-dicts-alist) |
| 1475 | (dolist (adict ispell-dictionary-alist) | 1469 | (dolist (adict ispell-dictionary-alist) |
| 1476 | (if (cadr adict) ;; Do not touch hunspell uninitialized entries | 1470 | (cl-pushnew (if (cadr adict) ;; Do not touch hunspell uninitialized entries |
| 1477 | (add-to-list 'tmp-dicts-alist | 1471 | (list |
| 1478 | (list | 1472 | (nth 0 adict) ; dict name |
| 1479 | (nth 0 adict) ; dict name | 1473 | "[[:alpha:]]" ; casechars |
| 1480 | "[[:alpha:]]" ; casechars | 1474 | "[^[:alpha:]]" ; not-casechars |
| 1481 | "[^[:alpha:]]" ; not-casechars | 1475 | (nth 3 adict) ; otherchars |
| 1482 | (nth 3 adict) ; otherchars | 1476 | (nth 4 adict) ; many-otherchars-p |
| 1483 | (nth 4 adict) ; many-otherchars-p | 1477 | (nth 5 adict) ; ispell-args |
| 1484 | (nth 5 adict) ; ispell-args | 1478 | (nth 6 adict) ; extended-character-mode |
| 1485 | (nth 6 adict) ; extended-character-mode | 1479 | (if ispell-encoding8-command |
| 1486 | (if ispell-encoding8-command | 1480 | 'utf-8 |
| 1487 | 'utf-8 | 1481 | (nth 7 adict))) |
| 1488 | (nth 7 adict)))) | 1482 | adict) |
| 1489 | (add-to-list 'tmp-dicts-alist adict))) | 1483 | tmp-dicts-alist :test #'equal)) |
| 1490 | (setq ispell-dictionary-alist tmp-dicts-alist))))) | 1484 | (setq ispell-dictionary-alist tmp-dicts-alist))))) |
| 1491 | 1485 | ||
| 1492 | (defun ispell-valid-dictionary-list () | 1486 | (defun ispell-valid-dictionary-list () |
| @@ -2428,7 +2422,8 @@ Global `ispell-quit' set to start location to continue spell session." | |||
| 2428 | nil) | 2422 | nil) |
| 2429 | ((or (= char ?a) (= char ?A)) ; accept word without insert | 2423 | ((or (= char ?a) (= char ?A)) ; accept word without insert |
| 2430 | (ispell-send-string (concat "@" word "\n")) | 2424 | (ispell-send-string (concat "@" word "\n")) |
| 2431 | (add-to-list 'ispell-buffer-session-localwords word) | 2425 | (cl-pushnew word ispell-buffer-session-localwords |
| 2426 | :test #'equal) | ||
| 2432 | (and (fboundp 'flyspell-unhighlight-at) | 2427 | (and (fboundp 'flyspell-unhighlight-at) |
| 2433 | (flyspell-unhighlight-at start)) | 2428 | (flyspell-unhighlight-at start)) |
| 2434 | (or ispell-buffer-local-name ; session localwords might conflict | 2429 | (or ispell-buffer-local-name ; session localwords might conflict |
| @@ -2761,7 +2756,7 @@ if defined." | |||
| 2761 | ;; This is the case when a process dies or fails. The default behavior | 2756 | ;; This is the case when a process dies or fails. The default behavior |
| 2762 | ;; in this case treats the next input received as fresh input. | 2757 | ;; in this case treats the next input received as fresh input. |
| 2763 | 2758 | ||
| 2764 | (defun ispell-filter (process output) | 2759 | (defun ispell-filter (_process output) |
| 2765 | "Output filter function for ispell, grep, and look." | 2760 | "Output filter function for ispell, grep, and look." |
| 2766 | (let ((start 0) | 2761 | (let ((start 0) |
| 2767 | (continue t) | 2762 | (continue t) |
| @@ -3041,14 +3036,13 @@ Keeps argument list for future Ispell invocations for no async support." | |||
| 3041 | (ispell-send-string "\032\n") ; so Ispell prints version and exits | 3036 | (ispell-send-string "\032\n") ; so Ispell prints version and exits |
| 3042 | t))) | 3037 | t))) |
| 3043 | 3038 | ||
| 3044 | |||
| 3045 | (defun ispell-init-process () | 3039 | (defun ispell-init-process () |
| 3046 | "Check status of Ispell process and start if necessary." | 3040 | "Check status of Ispell process and start if necessary." |
| 3047 | (let* (;; Basename of dictionary used by the spell-checker | 3041 | (let* (;; Basename of dictionary used by the spell-checker |
| 3048 | (dict-bname (or (car (cdr (member "-d" (ispell-get-ispell-args)))) | 3042 | (dict-bname (or (car (cdr (member "-d" (ispell-get-ispell-args)))) |
| 3049 | ispell-current-dictionary)) | 3043 | ispell-current-dictionary)) |
| 3050 | ;; The directory where process was started. | 3044 | ;; The directory where process was started. |
| 3051 | (current-ispell-directory default-directory) | 3045 | (current-ispell-directory default-directory) ;FIXME: Unused? |
| 3052 | ;; The default directory for the process. | 3046 | ;; The default directory for the process. |
| 3053 | ;; Use "~/" as default-directory unless using Ispell with per-dir | 3047 | ;; Use "~/" as default-directory unless using Ispell with per-dir |
| 3054 | ;; personal dictionaries and not in a minibuffer under XEmacs | 3048 | ;; personal dictionaries and not in a minibuffer under XEmacs |
| @@ -3151,7 +3145,7 @@ Keeps argument list for future Ispell invocations for no async support." | |||
| 3151 | ;; Otherwise we get cool errors like "Can't open ". | 3145 | ;; Otherwise we get cool errors like "Can't open ". |
| 3152 | (sleep-for 1) | 3146 | (sleep-for 1) |
| 3153 | (ispell-accept-output 3) | 3147 | (ispell-accept-output 3) |
| 3154 | (error "%s" (mapconcat 'identity ispell-filter "\n")))) | 3148 | (error "%s" (mapconcat #'identity ispell-filter "\n")))) |
| 3155 | (setq ispell-filter nil) ; Discard version ID line | 3149 | (setq ispell-filter nil) ; Discard version ID line |
| 3156 | (let ((extended-char-mode (ispell-get-extended-character-mode))) | 3150 | (let ((extended-char-mode (ispell-get-extended-character-mode))) |
| 3157 | (if extended-char-mode ; ~ extended character mode | 3151 | (if extended-char-mode ; ~ extended character mode |
| @@ -3207,7 +3201,7 @@ By just answering RET you can find out what the current dictionary is." | |||
| 3207 | (list (completing-read | 3201 | (list (completing-read |
| 3208 | "Use new dictionary (RET for current, SPC to complete): " | 3202 | "Use new dictionary (RET for current, SPC to complete): " |
| 3209 | (and (fboundp 'ispell-valid-dictionary-list) | 3203 | (and (fboundp 'ispell-valid-dictionary-list) |
| 3210 | (mapcar 'list (ispell-valid-dictionary-list))) | 3204 | (mapcar #'list (ispell-valid-dictionary-list))) |
| 3211 | nil t) | 3205 | nil t) |
| 3212 | current-prefix-arg)) | 3206 | current-prefix-arg)) |
| 3213 | (ispell-set-spellchecker-params) ; Initialize variables and dicts alists | 3207 | (ispell-set-spellchecker-params) ; Initialize variables and dicts alists |
| @@ -3413,7 +3407,7 @@ ispell-region: Search for first region to skip after (ispell-begin-skip-region-r | |||
| 3413 | Includes `ispell-skip-region-alist' plus tex, tib, html, and comment keys. | 3407 | Includes `ispell-skip-region-alist' plus tex, tib, html, and comment keys. |
| 3414 | Must be called after `ispell-buffer-local-parsing' due to dependence on mode." | 3408 | Must be called after `ispell-buffer-local-parsing' due to dependence on mode." |
| 3415 | (mapconcat | 3409 | (mapconcat |
| 3416 | 'identity | 3410 | #'identity |
| 3417 | (delq nil | 3411 | (delq nil |
| 3418 | (list | 3412 | (list |
| 3419 | ;; messages | 3413 | ;; messages |
| @@ -3870,7 +3864,7 @@ Standard ispell choices are then available." | |||
| 3870 | (setq case-fold-search nil) ; Try and respect case of word. | 3864 | (setq case-fold-search nil) ; Try and respect case of word. |
| 3871 | (cond | 3865 | (cond |
| 3872 | ((string-equal (upcase word) word) | 3866 | ((string-equal (upcase word) word) |
| 3873 | (setq possibilities (mapcar 'upcase possibilities))) | 3867 | (setq possibilities (mapcar #'upcase possibilities))) |
| 3874 | ((eq (upcase (aref word 0)) (aref word 0)) | 3868 | ((eq (upcase (aref word 0)) (aref word 0)) |
| 3875 | (setq possibilities (mapcar (function | 3869 | (setq possibilities (mapcar (function |
| 3876 | (lambda (pos) | 3870 | (lambda (pos) |
| @@ -4104,10 +4098,10 @@ The `X' command aborts sending the message so that you can edit the buffer. | |||
| 4104 | 4098 | ||
| 4105 | To spell-check whenever a message is sent, include the appropriate lines | 4099 | To spell-check whenever a message is sent, include the appropriate lines |
| 4106 | in your init file: | 4100 | in your init file: |
| 4107 | (add-hook \\='message-send-hook \\='ispell-message) ;; GNUS 5 | 4101 | (add-hook \\='message-send-hook #\\='ispell-message) ;; GNUS 5 |
| 4108 | (add-hook \\='news-inews-hook \\='ispell-message) ;; GNUS 4 | 4102 | (add-hook \\='news-inews-hook #\\='ispell-message) ;; GNUS 4 |
| 4109 | (add-hook \\='mail-send-hook \\='ispell-message) | 4103 | (add-hook \\='mail-send-hook #\\='ispell-message) |
| 4110 | (add-hook \\='mh-before-send-letter-hook \\='ispell-message) | 4104 | (add-hook \\='mh-before-send-letter-hook #\\='ispell-message) |
| 4111 | 4105 | ||
| 4112 | You can bind this to the key C-c i in GNUS or mail by adding to | 4106 | You can bind this to the key C-c i in GNUS or mail by adding to |
| 4113 | `news-reply-mode-hook' or `mail-mode-hook' the following lambda expression: | 4107 | `news-reply-mode-hook' or `mail-mode-hook' the following lambda expression: |
| @@ -4429,6 +4423,7 @@ Both should not be used to define a buffer-local dictionary." | |||
| 4429 | (insert comment-end))))) | 4423 | (insert comment-end))))) |
| 4430 | (insert (concat " " word)))))))) | 4424 | (insert (concat " " word)))))))) |
| 4431 | 4425 | ||
| 4426 | ;;FIXME: Use `user-error' instead! | ||
| 4432 | (add-to-list 'debug-ignored-errors "^No word found to check!$") | 4427 | (add-to-list 'debug-ignored-errors "^No word found to check!$") |
| 4433 | 4428 | ||
| 4434 | (provide 'ispell) | 4429 | (provide 'ispell) |