Doc fixes.
[bpt/emacs.git] / lisp / textmodes / ispell.el
1 ;;; ispell.el --- Interface to International Ispell Version 3.1
2
3 ;; Copyright (C) 1994, 1995, 1997, 1998 Free Software Foundation, Inc.
4
5 ;; Authors : Ken Stevens <k.stevens@ieee.org>
6 ;; Stevens Mod Date: Tue Apr 28 14:40:01 PDT 1998
7 ;; Stevens Revision: 3.0
8 ;; Status : Release with 3.1.12+ ispell.
9 ;; Bug Reports : ispell-el-bugs@itcorp.com
10 ;; Web Site : http://kdstevens.com/~stevens/ispell-page.html
11
12 ;; This file is part of GNU Emacs.
13
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; any later version.
18
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
28
29 ;; Note: version numbers and time stamp are not updated
30 ;; when this file is edited for release with GNU emacs.
31
32 ;;; Commentary:
33
34 ;; INSTRUCTIONS
35
36 ;; This code contains a section of user-settable variables that you should
37 ;; inspect prior to installation. Look past the end of the history list.
38 ;; Set them up for your locale and the preferences of the majority of the
39 ;; users. Otherwise the users may need to set a number of variables
40 ;; themselves.
41 ;; You particularly may want to change the default dictionary for your
42 ;; country and language.
43
44 ;; Depending on the mail system you use, you may want to include these:
45
46 ;; (add-hook 'news-inews-hook 'ispell-message)
47 ;; (add-hook 'mail-send-hook 'ispell-message)
48 ;; (add-hook 'mh-before-send-letter-hook 'ispell-message)
49
50
51 ;; Ispell has a TeX parser and a nroff parser (the default).
52 ;; The parsing is controlled by the variable ispell-parser. Currently
53 ;; it is just a "toggle" between TeX and nroff, but if more parsers are
54 ;; added it will be updated. See the variable description for more info.
55
56
57 ;; TABLE OF CONTENTS
58
59 ;; ispell-word
60 ;; ispell-region
61 ;; ispell-buffer
62 ;; ispell-message
63 ;; ispell-comments-and-strings
64 ;; ispell-continue
65 ;; ispell-complete-word
66 ;; ispell-complete-word-interior-frag
67 ;; ispell-change-dictionary
68 ;; ispell-kill-ispell
69 ;; ispell-pdict-save
70 ;; ispell-skip-region-alist
71
72 ;; Commands in ispell-region:
73 ;; Character replacement: Replace word with choice. May query-replace.
74 ;; ` ': Accept word this time.
75 ;; `i': Accept word and insert into private dictionary.
76 ;; `a': Accept word for this session.
77 ;; `A': Accept word and place in buffer-local dictionary.
78 ;; `r': Replace word with typed-in value. Rechecked.
79 ;; `R': Replace word with typed-in value. Query-replaced in buffer. Rechecked.
80 ;; `?': Show these commands
81 ;; `x': Exit spelling buffer. Move cursor to original point.
82 ;; `X': Exit spelling buffer. Leaves cursor at the current point, and permits
83 ;; the check to be completed later.
84 ;; `q': Quit spelling session (Kills ispell process).
85 ;; `l': Look up typed-in replacement in alternate dictionary. Wildcards okay.
86 ;; `u': Like `i', but the word is lower-cased first.
87 ;; `m': Place entered value in personal dictionary, then recheck current word.
88 ;; `C-l': redraws screen
89 ;; `C-r': recursive edit
90 ;; `C-z': suspend emacs or iconify frame
91
92 ;; Buffer-Local features:
93 ;; There are a number of buffer-local features that can be used to customize
94 ;; ispell for the current buffer. This includes language dictionaries,
95 ;; personal dictionaries, parsing, and local word spellings. Each of these
96 ;; local customizations are done either through local variables, or by
97 ;; including the keyword and argument(s) at the end of the buffer (usually
98 ;; prefixed by the comment characters). See the end of this file for
99 ;; examples. The local keywords and variables are:
100
101 ;; ispell-dictionary-keyword language-dictionary
102 ;; uses local variable ispell-local-dictionary
103 ;; ispell-pdict-keyword personal-dictionary
104 ;; uses local variable ispell-local-pdict
105 ;; ispell-parsing-keyword mode-arg extended-char-arg
106 ;; ispell-words-keyword any number of local word spellings
107
108 ;; Region skipping:
109 ;; Place new regular expression definitions of regions you prefer not to
110 ;; spell check in `ispell-skip-region-alist'. Mode-dependent features can
111 ;; be added to latex by modifying `ispell-tex-skip-alists'.
112 ;; `ispell-message' contains some custom skipping code for e-mail messages.
113
114 ;; BUGS:
115 ;; Highlighting in version 19 still doesn't work on tty's.
116 ;; On some versions of emacs, growing the minibuffer fails.
117 ;; Autoloading ispell can result in problems if you need to use a local or
118 ;; modified dictionary. Place the following in your .emacs file to
119 ;; override the autoload definitions:
120 ;; (setq ispell-dictionary-alist (cons '(dictionary ...)
121 ;; ispell-dictionary-alist))
122 ;; (setq ispell-menu-map nil)
123 ;; (load-library "ispell")
124
125 ;;; Code:
126
127 ;;; Custom.el macros require recompiling this when they are not present.
128 ;;; Add in backward compatible custom support.
129 (eval-when-compile
130 (if (not (fboundp 'defcustom))
131 (defmacro defcustom (symbol value doc &rest args)
132 "Empty replacement for defcustom when not supplied."
133 `(defvar ,symbol ,value ,doc))))
134
135 (eval-when-compile
136 (if (fboundp 'defgroup)
137 (defgroup ispell nil
138 "User variables for emacs ispell interface."
139 :group 'applications)))
140
141
142 ;;; **********************************************************************
143 ;;; The following variables should be set according to personal preference
144 ;;; and location of binaries:
145 ;;; **********************************************************************
146
147
148 ;;; ******* THIS FILE IS WRITTEN FOR ISPELL VERSION 3.1
149 ;;; Code:
150
151 (defcustom ispell-highlight-p 'block
152 "*Highlight spelling errors when non-nil.
153 When set to `block', assumes a block cursor with TTY displays."
154 :type '(choice (const block) (const t) (const nil))
155 :group 'ispell)
156
157 (defcustom ispell-highlight-face 'highlight
158 "*The face used for Ispell highlighting. For Emacses with overlays.
159 Possible values are `highlight', `modeline', `secondary-selection',
160 `region', and `underline'.
161 This variable can be set by the user to whatever face they desire.
162 It's most convenient if the cursor color and highlight color are
163 slightly different."
164 :type 'face
165 :group 'ispell)
166
167 (defcustom ispell-check-comments t
168 "*Spelling of comments checked when non-nil.
169 When set to `exclusive', ONLY comments are checked. (For code comments).
170 Warning! Not checking comments, when a comment start is embedded in strings,
171 may produce undesired results."
172 :type '(choice (const exclusive) (const t) (const nil))
173 :group 'ispell)
174
175 (defcustom ispell-query-replace-choices nil
176 "*Corrections made throughout region when non-nil.
177 Uses `query-replace' (\\[query-replace]) for corrections."
178 :type 'boolean
179 :group 'ispell)
180
181 (defcustom ispell-skip-tib nil
182 "*Does not spell check `tib' bibliography references when non-nil.
183 Skips any text between strings matching regular expressions
184 `ispell-tib-ref-beginning' and `ispell-tib-ref-end'.
185
186 TeX users beware: Any field starting with [. will skip until a .] -- even
187 your whole buffer -- unless you set `ispell-skip-tib' to nil. That includes
188 a [.5mm] type of number...."
189 :type 'boolean
190 :group 'ispell)
191
192 (defvar ispell-tib-ref-beginning "[[<]\\."
193 "Regexp matching the beginning of a Tib reference.")
194
195 (defvar ispell-tib-ref-end "\\.[]>]"
196 "Regexp matching the end of a Tib reference.")
197
198 (defcustom ispell-keep-choices-win t
199 "*When not nil, the `*Choices*' window remains for spelling session.
200 This minimizes redisplay thrashing."
201 :type 'boolean
202 :group 'ispell)
203
204 (defcustom ispell-choices-win-default-height 2
205 "*The default size of the `*Choices*' window, including status line.
206 Must be greater than 1."
207 :type 'integer
208 :group 'ispell)
209
210 (defcustom ispell-program-name "ispell"
211 "Program invoked by \\[ispell-word] and \\[ispell-region] commands."
212 :type 'string
213 :group 'ispell)
214
215 (defcustom ispell-alternate-dictionary
216 (cond ((file-exists-p "/usr/dict/web2") "/usr/dict/web2")
217 ((file-exists-p "/usr/share/dict/web2") "/usr/share/dict/web2")
218 ((file-exists-p "/usr/dict/words") "/usr/dict/words")
219 ((file-exists-p "/usr/lib/dict/words") "/usr/lib/dict/words")
220 ((file-exists-p "/usr/share/dict/words") "/usr/share/dict/words")
221 ((file-exists-p "/sys/dict") "/sys/dict")
222 (t "/usr/dict/words"))
223 "*Alternate dictionary for spelling help."
224 :type 'file
225 :group 'ispell)
226
227 (defcustom ispell-complete-word-dict ispell-alternate-dictionary
228 "*Dictionary used for word completion."
229 :type 'file
230 :group 'ispell)
231
232 (defcustom ispell-message-dictionary-alist nil
233 "*List used by `ispell-message' to select a new dictionary.
234 It consists of pairs (REGEXP . DICTIONARY). If REGEXP is found
235 in the message headers, `ispell-local-dictionary' will be set to
236 DICTIONARY if `ispell-local-dictionary' is not buffer-local.
237 E.g. you may use the following value:
238 '((\"^Newsgroups:[ \\t]*de\\\\.\" . \"deutsch8\")
239 (\"^To:[^\\n,]+\\\\.de[ \\t\\n,>]\" . \"deutsch8\"))"
240 :type '(repeat (cons regexp string))
241 :group 'ispell)
242
243
244 (defcustom ispell-grep-command "egrep"
245 "Name of the grep command for search processes."
246 :type 'string
247 :group 'ispell)
248
249 (defcustom ispell-grep-options "-i"
250 "String of options to use when running the program in `ispell-grep-command'.
251 Should probably be \"-i\" or \"-e\".
252 Some machines (like the NeXT) don't support \"-i\""
253 :type 'string
254 :group 'ispell)
255
256 (defcustom ispell-look-command
257 (cond ((file-exists-p "/bin/look") "/bin/look")
258 ((file-exists-p "/usr/local/bin/look") "/usr/local/bin/look")
259 ((file-exists-p "/usr/bin/look") "/usr/bin/look")
260 (t "look"))
261 "Name of the look command for search processes.
262 This must be an absolute file name."
263 :type 'file
264 :group 'ispell)
265
266 (defcustom ispell-look-p (file-exists-p ispell-look-command)
267 "*Non-nil means use `look' rather than `grep'.
268 Default is based on whether `look' seems to be available."
269 :type 'boolean
270 :group 'ispell)
271
272 (defcustom ispell-have-new-look nil
273 "*Non-nil means use the `-r' option (regexp) when running `look'."
274 :type 'boolean
275 :group 'ispell)
276
277 (defcustom ispell-look-options (if ispell-have-new-look "-dfr" "-df")
278 "String of command options for `ispell-look-command'."
279 :type 'string
280 :group 'ispell)
281
282 (defcustom ispell-use-ptys-p nil
283 "When non-nil, Emacs uses ptys to communicate with Ispell.
284 When nil, Emacs uses pipes."
285 :type 'boolean
286 :group 'ispell)
287
288 (defcustom ispell-following-word nil
289 "*Non-nil means `ispell-word' checks the word around or after point.
290 Otherwise `ispell-word' checks the preceding word."
291 :type 'boolean
292 :group 'ispell)
293
294 (defcustom ispell-help-in-bufferp nil
295 "*Non-nil means display interactive keymap help in a buffer.
296 The following valued are supported:
297 nil Expand the minibuffer and display a short help message
298 there for a couple of seconds.
299 t Pop up a new buffer and display a short help message there
300 for a couple of seconds.
301 electric Pop up a new buffer and display a long help message there.
302 User can browse and then exit the help mode."
303 :type '(choice (const electric) (const t) (const nil))
304
305 :group 'ispell)
306
307 (defcustom ispell-quietly nil
308 "*Non-nil means suppress messages in `ispell-word'."
309 :type 'boolean
310 :group 'ispell)
311
312 (defcustom ispell-format-word (function upcase)
313 "*Formatting function for displaying word being spell checked.
314 The function must take one string argument and return a string."
315 :type 'function
316 :group 'ispell)
317
318 (defcustom ispell-use-framepop-p nil
319 "When non-nil ispell uses framepop to display choices in a dedicated frame.
320 You can set this variable to dynamically use framepop if you are in a
321 window system by evaluating the following on startup to set this variable:
322 (and window-system (condition-case () (require 'framepop) (error nil)))"
323 :type 'boolean
324 :group 'ispell)
325
326 ;;;###autoload
327 (defcustom ispell-personal-dictionary nil
328 "*File name of your personal spelling dictionary, or nil.
329 If nil, the default personal dictionary, \"~/.ispell_DICTNAME\" is used,
330 where DICTNAME is the name of your default dictionary."
331 :type '(choice file
332 (const :tag "default" nil))
333 :group 'ispell)
334
335 (defcustom ispell-silently-savep nil
336 "*When non-nil, save the personal dictionary without confirmation."
337 :type 'boolean
338 :group 'ispell)
339
340 ;;; This is the local dictionary to use. When nil the default dictionary will
341 ;;; be used. Change set-default call to use a new default dictionary.
342 (defcustom ispell-local-dictionary nil
343 "If non-nil, the dictionary to be used for Ispell commands.
344 The value must be a string dictionary name in `ispell-dictionary-alist'.
345 This variable becomes buffer-local when set in any fashion.
346
347 Setting ispell-local-dictionary to a value has the same effect as
348 calling \\[ispell-change-dictionary] with that value. This variable
349 is automatically set when defined in the file with either
350 `ispell-dictionary-keyword' or the Local Variable syntax.
351
352 To create a non-standard default dictionary (not from ispell-dictionary-alist)
353 call function set-default with the new dictionary name."
354 :type '(choice string
355 (const :tag "default" nil))
356 :group 'ispell)
357
358 (make-variable-buffer-local 'ispell-local-dictionary)
359
360 ;; Call this function set up the default dictionary if not English.
361 ;;(set-default 'ispell-local-dictionary nil)
362
363
364 (defcustom ispell-extra-args nil
365 "*If non-nil, a list of extra switches to pass to the Ispell program.
366 For example, (\"-W\" \"3\") to cause it to accept all 1-3 character
367 words as correct. See also `ispell-dictionary-alist', which may be used
368 for language-specific arguments."
369 :type '(repeat string)
370 :group 'ispell)
371
372 ;;; The preparation of the menu bar menu must be autoloaded
373 ;;; because otherwise this file gets autoloaded every time Emacs starts
374 ;;; so that it can set up the menus and determine keyboard equivalents.
375
376 ;;; split dictionary so line length is smaller in loaddefs.el
377
378 ;;;###autoload
379 (defvar ispell-dictionary-alist-1
380 '((nil ; default (English.aff)
381 "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil nil)
382 ("american" ; make English explicitly selectable
383 "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil nil)
384 ("british" ; British version
385 "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B" "-d" "british") nil nil)
386 ("castellano" ; Spanish mode
387 "[A-Z\301\311\315\323\332\334\321a-z\341\351\355\363\372\374\361]"
388 "[^A-Z\301\311\315\323\332\334\321a-z\341\351\355\363\372\374\361]"
389 "[---]" nil ("-B" "-d" "castellano") "~tex" iso-latin-1)
390 ("castellano8" ; 8 bit Spanish mode
391 "[A-Z\301\311\315\323\332\334\321a-z\341\351\355\363\372\374\361]"
392 "[^A-Z\301\311\315\323\332\334\321a-z\341\351\355\363\372\374\361]"
393 "[---]" nil ("-B" "-d" "castellano") "~latin1" iso-latin-1)
394 ("czech"
395 "[A-Za-z\301\311\314\315\323\332\331\335\256\251\310\330\317\253\322\341\351\354\355\363\372\371\375\276\271\350\370\357\273\362]"
396 "[^A-Za-z\301\311\314\315\323\332\331\335\256\251\310\330\317\253\322\341\351\354\355\363\372\371\375\276\271\350\370\357\273\362]"
397 "" nil ("-B" "-d" "czech") nil iso-latin-2)
398 ("dansk" ; Dansk.aff
399 "[A-Z\306\330\305a-z\346\370\345]" "[^A-Z\306\330\305a-z\346\370\345]"
400 "[']" nil ("-C") nil iso-latin-1)
401 ("deutsch" ; Deutsch.aff
402 "[a-zA-Z\"]" "[^a-zA-Z\"]" "[']" t ("-C") "~tex" nil)
403 ("deutsch8"
404 "[a-zA-Z\304\326\334\344\366\337\374]"
405 "[^a-zA-Z\304\326\334\344\366\337\374]"
406 "[']" t ("-C" "-d" "deutsch") "~latin1" iso-latin-1)
407 ("english" ; make English explicitly selectable
408 "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil nil))
409 "First half of dictionary, shortened for loaddefs.el")
410
411 ;;;###autoload
412 (defvar ispell-dictionary-alist-2
413 '(("esperanto"
414 "[A-Za-z\246\254\266\274\306\330\335\336\346\370\375\376]"
415 "[^A-Za-z\246\254\266\274\306\330\335\336\346\370\375\376]"
416 "[-']" t ("-C") "~latin3" nil)
417 ("esperanto-tex"
418 "[A-Za-z^\\]" "[^A-Za-z^\\]" "[-'`\"]" t ("-C" "-d" "esperanto") "~tex"
419 nil)
420 ("francais7"
421 "[A-Za-z]" "[^A-Za-z]" "[`'^---]" t nil nil nil)
422 ("francais" ; Francais.aff
423 "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"
424 "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"
425 "[---']" t nil "~list" iso-latin-1)
426 ("francais-tex" ; Francais.aff
427 "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"
428 "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"
429 "[---'^`\"]" t nil "~tex" iso-latin-1)
430 ("nederlands" ; Nederlands.aff
431 "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
432 "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
433 "[']" t ("-C") nil iso-latin-1)
434 ("nederlands8" ; Dutch8.aff
435 "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
436 "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
437 "[']" t ("-C") nil iso-latin-1)
438 ("norsk" ;8 bit Norwegian mode
439 "[A-Za-z\351\346\370\345\350\364\362\311\306\330\305\310\324\322]"
440 "[^A-Za-z\351\346\370\345\350\364\362\311\306\330\305\310\324\322]"
441 "[']" nil ("-C" "-d" "norsk") "~list" nil)
442 ("russian" ; russian.aff (KOI8-R charset)
443 "[\341\342\367\347\344\345\263\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\370\371\377\374\340\361\301\302\327\307\304\305\243\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\330\331\337\334\300\321]"
444 "[^\341\342\367\347\344\345\263\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\370\371\377\374\340\361\301\302\327\307\304\305\243\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\330\331\337\334\300\321]"
445 "[']" t ("-C" "-d" "russian") "~latin1" iso-latin-1)
446 ("svenska" ;7 bit Swedish mode
447 "[A-Za-z}{|\\133\\135\\\\]" "[^A-Za-z}{|\\133\\135\\\\]"
448 "[']" nil ("-C") nil nil)
449 ("svenska8" ;8 bit Swedish mode
450 "[A-Za-z\345\344\366\305\304\366]" "[^A-Za-z\345\344\366\305\304\366]"
451 "[']" nil ("-C" "-d" "svenska") "~list" ; Add `"-T" "list"' instead?
452 iso-latin-1))
453 "Second half of dictionary, shortened for loaddefs.el")
454
455 ;;; The preparation of the menu bar menu must be autoloaded
456 ;;; because otherwise this file gets autoloaded every time Emacs starts
457 ;;; so that it can set up the menus and determine keyboard equivalents.
458
459 ;;;###autoload
460 (defcustom ispell-dictionary-alist
461 (append ispell-dictionary-alist-1 ispell-dictionary-alist-2)
462 "An alist of dictionaries and their associated parameters.
463
464 Each element of this list is also a list:
465
466 \(DICTIONARY-NAME CASECHARS NOT-CASECHARS OTHERCHARS MANY-OTHERCHARS-P
467 ISPELL-ARGS EXTENDED-CHARACTER-MODE CHARACTER-SET\)
468
469 DICTIONARY-NAME is a possible string value of variable `ispell-dictionary',
470 nil means the default dictionary.
471
472 CASECHARS is a regular expression of valid characters that comprise a
473 word.
474
475 NOT-CASECHARS is the opposite regexp of CASECHARS.
476
477 OTHERCHARS is a regexp of characters in the NOT-CASECHARS set but which can be
478 used to construct words in some special way. If OTHERCHARS characters follow
479 and precede characters from CASECHARS, they are parsed as part of a word,
480 otherwise they become word-breaks. As an example in English, assume the
481 regular expression \"[']\" for OTHERCHARS. Then \"they're\" and
482 \"Steven's\" are parsed as single words including the \"'\" character, but
483 \"Stevens'\" does not include the quote character as part of the word.
484 If you want OTHERCHARS to be empty, use the empty string.
485 Hint: regexp syntax requires the hyphen to be declared first here.
486
487 MANY-OTHERCHARS-P is non-nil when multiple OTHERCHARS are allowed in a word.
488 Otherwise only a single OTHERCHARS character is allowed to be part of any
489 single word.
490
491 ISPELL-ARGS is a list of additional arguments passed to the ispell
492 subprocess.
493
494 EXTENDED-CHARACTER-MODE should be used when dictionaries are used which
495 have been configured in an Ispell affix file. (For example, umlauts
496 can be encoded as \\\"a, a\\\", \"a, ...) Defaults are ~tex and ~nroff
497 in English. This has the same effect as the command-line `-T' option.
498 The buffer Major Mode controls Ispell's parsing in tex or nroff mode,
499 but the dictionary can control the extended character mode.
500 Both defaults can be overruled in a buffer-local fashion. See
501 `ispell-parsing-keyword' for details on this.
502
503 CHARACTER-SET used for languages with multibyte characters.
504
505 Note that the CASECHARS and OTHERCHARS slots of the alist should
506 contain the same character set as casechars and otherchars in the
507 LANGUAGE.aff file \(e.g., english.aff\)."
508 :type '(repeat (list (choice :tag "Dictionary"
509 (string :tag "Dictionary name")
510 (const :tag "default" nil))
511 (regexp :tag "Case characters")
512 (regexp :tag "Non case characters")
513 (regexp :tag "Other characters")
514 (boolean :tag "Many other characters")
515 (repeat :tag "Ispell command line args"
516 (string :tag "Arg"))
517 (choice :tag "Extended character mode"
518 (const "~tex") (const "~list") (const "~nroff")
519 (const "~latin3") (const "~latin1")
520 (const :tag "default" nil))
521 (choice :tag "Character set"
522 (const iso-latin-1)
523 (const iso-latin-2)
524 (const :tag "default" nil))))
525 :group 'ispell)
526
527
528 ;;;###autoload
529 (defvar ispell-menu-map nil "Key map for ispell menu")
530
531 ;;;###autoload
532 (defvar ispell-menu-xemacs nil
533 "Spelling menu for XEmacs.
534 If nil when package is loaded, a standard menu will be set,
535 and added as a submenu of the \"Edit\" menu.")
536
537 ;;; Break out XEmacs menu and split into several calls to avoid having
538 ;;; long lines in loaddefs.el. Detect need off following constant.
539
540 ;;; Set up dictionary
541 ;;;###autoload
542 (defconst ispell-menu-map-needed
543 ;; only needed when not version 18 and not XEmacs.
544 (and (not ispell-menu-map)
545 (not (string-match "18\\.[0-9]+\\.[0-9]+" emacs-version))
546 (not (string-match "Lucid\\|XEmacs" emacs-version))))
547
548 ;;;###autoload
549 (if ispell-menu-map-needed
550 (let ((dicts (reverse (cons (cons "default" nil) ispell-dictionary-alist)))
551 name)
552 (setq ispell-menu-map (make-sparse-keymap "Spell"))
553 ;; add the dictionaries to the bottom of the list.
554 (while dicts
555 (setq name (car (car dicts))
556 dicts (cdr dicts))
557 (if (stringp name)
558 (define-key ispell-menu-map (vector (intern name))
559 (cons (concat "Select " (capitalize name))
560 (list 'lambda () '(interactive)
561 (list 'ispell-change-dictionary name))))))))
562
563 ;;; define commands in menu in opposite order you want them to appear.
564 ;;;###autoload
565 (if ispell-menu-map-needed
566 (progn
567 (define-key ispell-menu-map [ispell-change-dictionary]
568 '("Change Dictionary" . ispell-change-dictionary))
569 (define-key ispell-menu-map [ispell-kill-ispell]
570 '("Kill Process" . ispell-kill-ispell))
571 (define-key ispell-menu-map [ispell-pdict-save]
572 '("Save Dictionary" . (lambda () (interactive) (ispell-pdict-save t t))))
573 (define-key ispell-menu-map [ispell-complete-word]
574 '("Complete Word" . ispell-complete-word))
575 (define-key ispell-menu-map [ispell-complete-word-interior-frag]
576 '("Complete Word Frag" . ispell-complete-word-interior-frag))))
577
578 ;;;###autoload
579 (if ispell-menu-map-needed
580 (progn
581 (define-key ispell-menu-map [ispell-continue]
582 '("Continue Check" . ispell-continue))
583 (define-key ispell-menu-map [ispell-word]
584 '("Check Word" . ispell-word))
585 (define-key ispell-menu-map [ispell-comments-and-strings]
586 '("Check Comments" . ispell-comments-and-strings))
587 (define-key ispell-menu-map [ispell-region]
588 '("Check Region" . ispell-region))
589 (define-key ispell-menu-map [ispell-buffer]
590 '("Check Buffer" . ispell-buffer))))
591
592 ;;;###autoload
593 (if ispell-menu-map-needed
594 (progn
595 (define-key ispell-menu-map [ispell-message]
596 '("Check Message" . ispell-message))
597 (define-key ispell-menu-map [ispell-help]
598 ;; use (x-popup-menu last-nonmenu-event(list "" ispell-help-list)) ?
599 '("Help" . (lambda () (interactive) (describe-function 'ispell-help))))
600 (put 'ispell-region 'menu-enable 'mark-active)
601 (fset 'ispell-menu-map (symbol-value 'ispell-menu-map))))
602
603 ;;; XEmacs version 19 & 20
604 (if (and (not (string-match "18\\.[0-9]+\\.[0-9]+" emacs-version))
605 (string-match "Lucid\\|XEmacs" emacs-version)
606 (featurep 'menubar)
607 (null ispell-menu-xemacs)
608 (not (and (boundp 'infodock-version) infodock-version)))
609 (let ((dicts (cons (cons "default" nil) ispell-dictionary-alist))
610 (current-menubar (or current-menubar default-menubar))
611 (menu
612 '(["Help" (describe-function 'ispell-help) t]
613 ;;["Help" (popup-menu ispell-help-list) t]
614 ["Check Message" ispell-message t]
615 ["Check Buffer" ispell-buffer t]
616 ["Check Comments" ispell-comments-and-strings t]
617 ["Check Word" ispell-word t]
618 ["Check Region" ispell-region (or (not zmacs-regions) (mark))]
619 ["Continue Check" ispell-continue t]
620 ["Complete Word Frag"ispell-complete-word-interior-frag t]
621 ["Complete Word" ispell-complete-word t]
622 ["Kill Process" ispell-kill-ispell t]
623 "-"
624 ["Save Dictionary" (ispell-pdict-save t t) t]
625 ["Change Dictionary" ispell-change-dictionary t]))
626 name)
627 (while dicts
628 (setq name (car (car dicts))
629 dicts (cdr dicts))
630 (if (stringp name)
631 (setq menu (append menu
632 (list
633 (vector (concat "Select " (capitalize name))
634 (list 'ispell-change-dictionary name)
635 t))))))
636 (setq ispell-menu-xemacs menu)
637 (if current-menubar
638 (progn
639 (delete-menu-item '("Edit" "Spell")) ; in case already defined
640 (add-menu '("Edit") "Spell" ispell-menu-xemacs)))))
641
642 ;;; Allow incrementing characters as integers in XEmacs 20
643 (if (and (string-match "XEmacs" emacs-version)
644 (fboundp 'int-char))
645 (fset 'ispell-int-char 'int-char)
646 ;; Emacs and XEmacs 19 or earlier
647 (fset 'ispell-int-char 'identity))
648
649
650 ;;; **********************************************************************
651 ;;; The following are used by ispell, and should not be changed.
652 ;;; **********************************************************************
653
654
655 ;;; The version must be 3.1 or greater for this version of ispell.el
656 ;;; There is an incompatibility between version 3.1.12 and lower versions.
657 (defconst ispell-required-version '("3.1." 12)
658 "Ispell versions with which this version of ispell.el is known to work.")
659 (defvar ispell-offset -1
660 "Offset that maps protocol differences between ispell 3.1 versions.")
661
662 ;;; This variable contains the current dictionary being used if the ispell
663 ;;; process is running. Otherwise it contains the global default.
664 (defvar ispell-dictionary nil
665 "The name of the current dictionary, or nil for the default.
666 When `ispell-local-dictionary' is nil, `ispell-dictionary' is used to select
667 the dictionary for new buffers.
668
669 This is passed to the ispell process using the `-d' switch and is
670 used as key in `ispell-dictionary-alist' (which see).")
671
672 (defun ispell-decode-string (str)
673 "Decodes multibyte character strings."
674 (if (and (boundp 'enable-multibyte-characters)
675 (fboundp 'decode-coding-string)
676 enable-multibyte-characters
677 (ispell-get-coding-system))
678 (decode-coding-string str (ispell-get-coding-system))
679 str))
680
681 (defun ispell-get-casechars ()
682 (ispell-decode-string
683 (nth 1 (assoc ispell-dictionary ispell-dictionary-alist))))
684 (defun ispell-get-not-casechars ()
685 (ispell-decode-string
686 (nth 2 (assoc ispell-dictionary ispell-dictionary-alist))))
687 (defun ispell-get-otherchars ()
688 (ispell-decode-string
689 (nth 3 (assoc ispell-dictionary ispell-dictionary-alist))))
690 (defun ispell-get-many-otherchars-p ()
691 (nth 4 (assoc ispell-dictionary ispell-dictionary-alist)))
692 (defun ispell-get-ispell-args ()
693 (nth 5 (assoc ispell-dictionary ispell-dictionary-alist)))
694 (defun ispell-get-extended-character-mode ()
695 (nth 6 (assoc ispell-dictionary ispell-dictionary-alist)))
696 (defun ispell-get-coding-system ()
697 (nth 7 (assoc ispell-dictionary ispell-dictionary-alist)))
698
699 (defvar ispell-process nil
700 "The process object for Ispell.")
701
702 (defvar ispell-pdict-modified-p nil
703 "Non-nil means personal dictionary has modifications to be saved.")
704
705 ;;; If you want to save the dictionary when quitting, must do so explicitly.
706 ;;; When non-nil, the spell session is terminated.
707 ;;; When numeric, contains cursor location in buffer, and cursor remains there.
708 (defvar ispell-quit nil)
709
710 (defvar ispell-filter nil
711 "Output filter from piped calls to Ispell.")
712
713 (defvar ispell-filter-continue nil
714 "Control variable for Ispell filter function.")
715
716 (defvar ispell-process-directory nil
717 "The directory where `ispell-process' was started.")
718
719 (defvar ispell-query-replace-marker (make-marker)
720 "Marker for `query-replace' processing.")
721
722 (defvar ispell-recursive-edit-marker (make-marker)
723 "Marker for return point from recursive edit.")
724
725 (defvar ispell-checking-message nil
726 "Non-nil when we're checking a mail message")
727
728 (defconst ispell-choices-buffer "*Choices*")
729
730 (defvar ispell-overlay nil "Overlay variable for Ispell highlighting.")
731
732 ;;; *** Buffer Local Definitions ***
733
734 (defconst ispell-words-keyword "LocalWords: "
735 "The keyword for local oddly-spelled words to accept.
736 The keyword will be followed by any number of local word spellings.
737 There can be multiple of these keywords in the file.")
738
739 (defconst ispell-dictionary-keyword "Local IspellDict: "
740 "The keyword for a local dictionary to use.
741 The keyword must be followed by a correct dictionary name in
742 `ispell-dictionary-alist'. When multiple occurrences exist, the last keyword
743 definition is used.")
744
745 (defconst ispell-pdict-keyword "Local IspellPersDict: "
746 "The keyword for defining buffer local dictionaries.
747 Keyword must be followed by the filename of a personal dictionary.
748 The last occurring definition in the buffer will be used.")
749
750 (defconst ispell-parsing-keyword "Local IspellParsing: "
751 "The keyword for overriding default Ispell parsing.
752 The above keyword string should be followed by `latex-mode' or
753 `nroff-mode' to put the current buffer into the desired parsing mode.
754
755 Extended character mode can be changed for this buffer by placing
756 a `~' followed by an extended-character mode -- such as `~.tex'.
757 The last occurring definition in the buffer will be used.")
758
759 ;;;###autoload
760 (defvar ispell-skip-region-alist
761 '((ispell-words-keyword forward-line)
762 (ispell-dictionary-keyword forward-line)
763 (ispell-pdict-keyword forward-line)
764 (ispell-parsing-keyword forward-line)
765 ("^---*BEGIN PGP [A-Z ]*--*" . "^---*END PGP [A-Z ]*--*")
766 ("^---* \\(Start of \\)?[Ff]orwarded [Mm]essage" . "^---* End of [Ff]orwarded [Mm]essage")
767 ;; matches e-mail addresses, file names, http addresses, etc.
768 ("\\(/\\|\\(\\(\\w\\|-\\)+[.:@]\\)\\)\\(\\w\\|-\\)*\\([.:/@]+\\(\\w\\|-\\|~\\)+\\)+")
769 ;; This is a pretty complex regexp. It can be simplified to the following:
770 ;; "\\(\\w\\|-\\)*\\([.:/@]+\\(\\w\\|-\\|~\\)+\\)+"
771 ;; but some valid text will be skipped, e.g. "his/herr". This could be
772 ;; fixed up (at the expense of a moderately more complex regexp)
773 ;; by not allowing "/" to be the character which triggers the
774 ;; identification of the computer name, e.g.:
775 ;; "\\(\\w\\|-\\)+[.:@]\\(\\w\\|-\\)*\\([.:/@]+\\(\\w\\|-\\|~\\)+\\)+"
776 )
777 "Alist expressing beginning and end of regions not to spell check.
778 The alist key must be a regular expression.
779 Valid forms include:
780 (KEY) - just skip the key.
781 (KEY . REGEXP) - skip to the end of REGEXP. REGEXP may be string or symbol.
782 (KEY REGEXP) - skip to end of REGEXP. REGEXP must be a string.
783 (KEY FUNCTION ARGS) - FUNCTION called with ARGS returns end of region.")
784
785
786
787 ;;;###autoload
788 (defvar ispell-tex-skip-alists
789 '((("%\\[" . "%\\]")
790 ;; All the standard LaTeX keywords from L. Lamport's guide:
791 ;; \cite, \hspace, \hspace*, \hyphenation, \include, \includeonly, \input,
792 ;; \label, \nocite, \rule (in ispell - rest included here)
793 ("\\\\addcontentsline" ispell-tex-arg-end 2)
794 ("\\\\add\\(tocontents\\|vspace\\)" ispell-tex-arg-end)
795 ("\\\\\\([aA]lph\\|arabic\\)" ispell-tex-arg-end)
796 ("\\\\author" ispell-tex-arg-end)
797 ("\\\\bibliographystyle" ispell-tex-arg-end)
798 ("\\\\makebox" ispell-tex-arg-end 0)
799 ;;("\\\\epsfig" ispell-tex-arg-end)
800 ("\\\\document\\(class\\|style\\)" .
801 "\\\\begin[ \t\n]*{[ \t\n]*document[ \t\n]*}"))
802 (;; delimited with \begin. In ispell: displaymath, eqnarray, eqnarray*,
803 ;; equation, minipage, picture, tabular, tabular* (ispell)
804 ("\\(figure\\|table\\)\\*?" ispell-tex-arg-end 0)
805 ("list" ispell-tex-arg-end 2)
806 ("program" . "\\\\end[ \t\n]*{[ \t\n]*program[ \t\n]*}")
807 ("verbatim\\*?" . "\\\\end[ \t\n]*{[ \t\n]*verbatim\\*?[ \t\n]*}")))
808 "*Lists of regions to be skipped in TeX mode.
809 First list is used raw.
810 Second list has key placed inside \\begin{}.
811
812 Delete or add any regions you want to be automatically selected
813 for skipping in latex mode.")
814
815
816 (defcustom ispell-skip-sgml 'use-mode-name
817 "*Indicates whether ispell should skip spell checking of SGML markup.
818 If t, always skip SGML markup; if nil, never skip; if non-t and non-nil,
819 guess whether SGML markup should be skipped according to the name of the
820 buffer's major mode."
821 :type '(choice (const use-mode-name) (const t) (const nil))
822 :group 'ispell)
823
824 (defvar ispell-local-pdict ispell-personal-dictionary
825 "A buffer local variable containing the current personal dictionary.
826 If non-nil, the value must be a string, which is a file name.
827
828 If you specify a personal dictionary for the current buffer which is
829 different from the current personal dictionary, the effect is similar
830 to calling \\[ispell-change-dictionary]. This variable is automatically
831 set when defined in the file with either `ispell-pdict-keyword' or the
832 local variable syntax.")
833
834 (make-variable-buffer-local 'ispell-local-pdict)
835
836 (defvar ispell-buffer-local-name nil
837 "Contains the buffer name if local word definitions were used.
838 Ispell is then restarted because the local words could conflict.")
839
840 (defvar ispell-parser 'use-mode-name
841 "*Indicates whether ispell should parse the current buffer as TeX Code.
842 Special value `use-mode-name' tries to guess using the name of major-mode.
843 Default parser is `nroff'.
844 Currently the only other valid parser is `tex'.
845
846 You can set this variable in hooks in your init file -- eg:
847
848 (add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex))))")
849
850 (defvar ispell-region-end (make-marker)
851 "Marker that allows spelling continuations.")
852
853 (defvar ispell-check-only nil
854 "If non-nil, `ispell-word' does not try to correct the word.")
855
856
857 ;;; **********************************************************************
858 ;;; **********************************************************************
859
860
861
862 (and (not (string-match "18\\.[0-9]+\\.[0-9]+" emacs-version))
863 (not (boundp 'epoch::version))
864 (defalias 'ispell 'ispell-buffer))
865
866 (if (not (fboundp 'buffer-substring-no-properties))
867 (defun buffer-substring-no-properties (start end)
868 (buffer-substring start end)))
869
870 ;;;###autoload
871 (define-key esc-map "$" 'ispell-word)
872
873 ;;;###autoload
874 (defun ispell-word (&optional following quietly continue)
875 "Check spelling of word under or before the cursor.
876 If the word is not found in dictionary, display possible corrections
877 in a window allowing you to choose one.
878
879 With a prefix argument (or if CONTINUE is non-nil),
880 resume interrupted spell-checking of a buffer or region.
881
882 If optional argument FOLLOWING is non-nil or if `ispell-following-word'
883 is non-nil when called interactively, then the following word
884 \(rather than preceding\) is checked when the cursor is not over a word.
885 When the optional argument QUIETLY is non-nil or `ispell-quietly' is non-nil
886 when called interactively, non-corrective messages are suppressed.
887
888 Word syntax described by `ispell-dictionary-alist' (which see).
889
890 This will check or reload the dictionary. Use \\[ispell-change-dictionary]
891 or \\[ispell-region] to update the Ispell process."
892 (interactive (list nil nil current-prefix-arg))
893 (if continue
894 (ispell-continue)
895 (if (interactive-p)
896 (setq following ispell-following-word
897 quietly ispell-quietly))
898 (ispell-accept-buffer-local-defs) ; use the correct dictionary
899 (let ((cursor-location (point)) ; retain cursor location
900 (word (ispell-get-word following))
901 start end poss new-word replace)
902 ;; De-structure return word info list.
903 (setq start (car (cdr word))
904 end (car (cdr (cdr word)))
905 word (car word))
906
907 ;; now check spelling of word if it has 3 or more characters.
908 (when (> (length word) 2)
909 (or quietly
910 (message "Checking spelling of %s..."
911 (funcall ispell-format-word word)))
912 (process-send-string ispell-process "%\n") ;put in verbose mode
913 (process-send-string ispell-process (concat "^" word "\n"))
914 ;; wait until ispell has processed word
915 (while (progn
916 (accept-process-output ispell-process)
917 (not (string= "" (car ispell-filter)))))
918 ;;(process-send-string ispell-process "!\n") ;back to terse mode.
919 (setq ispell-filter (cdr ispell-filter)) ; remove extra \n
920 (if (listp ispell-filter)
921 (setq poss (ispell-parse-output (car ispell-filter))))
922 (cond ((eq poss t)
923 (or quietly
924 (message "%s is correct"
925 (funcall ispell-format-word word))))
926 ((stringp poss)
927 (or quietly
928 (message "%s is correct because of root %s"
929 (funcall ispell-format-word word)
930 (funcall ispell-format-word poss))))
931 ((null poss) (message "Error in ispell process"))
932 (ispell-check-only ; called from ispell minor mode.
933 (beep)
934 (message "%s is incorrect" (funcall ispell-format-word word)))
935 (t ; prompt for correct word.
936 (save-window-excursion
937 (setq replace (ispell-command-loop
938 (car (cdr (cdr poss)))
939 (car (cdr (cdr (cdr poss))))
940 (car poss) start end)))
941 (cond ((equal 0 replace)
942 (ispell-add-per-file-word-list (car poss)))
943 (replace
944 (setq new-word (if (atom replace) replace (car replace))
945 cursor-location (+ (- (length word) (- end start))
946 cursor-location))
947 (if (not (equal new-word (car poss)))
948 (progn
949 (delete-region start end)
950 (setq start (point))
951 (insert new-word)
952 (setq end (point))))
953 (if (not (atom replace)) ;recheck spelling of replacement
954 (progn
955 (if (car (cdr replace)) ; query replace requested
956 (save-window-excursion
957 (query-replace word new-word t)))
958 (ispell-region start end)))))
959 (if (get-buffer ispell-choices-buffer)
960 (kill-buffer ispell-choices-buffer))))
961 (goto-char cursor-location) ; return to original location
962 (ispell-pdict-save ispell-silently-savep)
963 (if ispell-quit (setq ispell-quit nil))))))
964
965
966 (defun ispell-get-word (following &optional extra-otherchars)
967 "Return the word for spell-checking according to ispell syntax.
968 If optional argument FOLLOWING is non-nil or if `ispell-following-word'
969 is non-nil when called interactively, then the following word
970 \(rather than preceding\) is checked when the cursor is not over a word.
971 Optional second argument contains otherchars that can be included in word
972 many times.
973
974 Word syntax described by `ispell-dictionary-alist' (which see)."
975 (let* ((ispell-casechars (ispell-get-casechars))
976 (ispell-not-casechars (ispell-get-not-casechars))
977 (ispell-otherchars (ispell-get-otherchars))
978 (ispell-many-otherchars-p (ispell-get-many-otherchars-p))
979 (word-regexp (concat ispell-casechars
980 "+\\("
981 (if (not (string= "" ispell-otherchars))
982 (concat ispell-otherchars "?"))
983 (if extra-otherchars
984 (concat extra-otherchars "?"))
985 ispell-casechars
986 "+\\)"
987 (if (or ispell-many-otherchars-p
988 extra-otherchars)
989 "*" "?")))
990 did-it-once prevpt
991 start end word)
992 ;; find the word
993 (if (not (looking-at ispell-casechars))
994 (if following
995 (re-search-forward ispell-casechars (point-max) t)
996 (re-search-backward ispell-casechars (point-min) t)))
997 ;; move to front of word
998 (re-search-backward ispell-not-casechars (point-min) 'start)
999 (while (and (or (and (not (string= "" ispell-otherchars))
1000 (looking-at ispell-otherchars))
1001 (and extra-otherchars (looking-at extra-otherchars)))
1002 (not (bobp))
1003 (or (not did-it-once)
1004 ispell-many-otherchars-p)
1005 (not (eq prevpt (point))))
1006 (if (and extra-otherchars (looking-at extra-otherchars))
1007 (progn
1008 (backward-char 1)
1009 (if (looking-at ispell-casechars)
1010 (re-search-backward ispell-not-casechars (point-min) 'move)))
1011 (setq did-it-once t
1012 prevpt (point))
1013 (backward-char 1)
1014 (if (looking-at ispell-casechars)
1015 (re-search-backward ispell-not-casechars (point-min) 'move)
1016 (backward-char -1))))
1017 ;; Now mark the word and save to string.
1018 (if (not (re-search-forward word-regexp (point-max) t))
1019 (if ispell-check-only
1020 ;; return dummy word when just flagging misspellings
1021 (list "" (point) (point))
1022 (error "No word found to check!"))
1023 (setq start (match-beginning 0)
1024 end (point)
1025 word (buffer-substring-no-properties start end))
1026 (list word start end))))
1027
1028
1029 ;;; Global ispell-pdict-modified-p is set by ispell-command-loop and
1030 ;;; tracks changes in the dictionary. The global may either be
1031 ;;; a value or a list, whose value is the state of whether the
1032 ;;; dictionary needs to be saved.
1033
1034 ;;; ###autoload
1035 (defun ispell-pdict-save (&optional no-query force-save)
1036 "Check to see if the personal dictionary has been modified.
1037 If so, ask if it needs to be saved."
1038 (interactive (list ispell-silently-savep t))
1039 (if (and ispell-pdict-modified-p (listp ispell-pdict-modified-p))
1040 (setq ispell-pdict-modified-p (car ispell-pdict-modified-p)))
1041 (if (or ispell-pdict-modified-p force-save)
1042 (if (or no-query (y-or-n-p "Personal dictionary modified. Save? "))
1043 (progn
1044 (process-send-string ispell-process "#\n")
1045 (message "Personal dictionary saved."))))
1046 ;; unassert variable, even if not saved to avoid questioning.
1047 (setq ispell-pdict-modified-p nil))
1048
1049
1050 (defun ispell-command-loop (miss guess word start end)
1051 "Display possible corrections from list MISS.
1052 GUESS lists possibly valid affix construction of WORD.
1053 Returns nil to keep word.
1054 Returns 0 to insert locally into buffer-local dictionary.
1055 Returns string for new chosen word.
1056 Returns list for new replacement word (will be rechecked).
1057 Query-replace when list length is 2.
1058 Automatic query-replace when second element is `query-replace'.
1059 Highlights the word, which is assumed to run from START to END.
1060 Global `ispell-pdict-modified-p' becomes a list where the only value
1061 indicates whether the dictionary has been modified when option `a' or `i' is
1062 used.
1063 Global `ispell-quit' set to start location to continue spell session."
1064 (let ((textbuf (current-buffer))
1065 (count ?0)
1066 (line 2)
1067 (max-lines (- (window-height) 4)) ; assure 4 context lines.
1068 (choices miss)
1069 (window-min-height (min window-min-height
1070 ispell-choices-win-default-height))
1071 (command-characters '( ? ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m ))
1072 (dedicated (window-dedicated-p (selected-window)))
1073 (skipped 0)
1074 char num result textwin dedicated-win highlighted)
1075
1076 ;; setup the *Choices* buffer with valid data.
1077 (save-excursion
1078 (set-buffer (get-buffer-create ispell-choices-buffer))
1079 (setq mode-line-format (concat "-- %b -- word: " word))
1080 (and (fboundp 'set-specifier) ; prevent XEmacs modeline hiding
1081 (set-specifier has-modeline-p (cons (current-buffer) nil)))
1082 (erase-buffer)
1083 (if guess
1084 (progn
1085 (insert "Affix rules generate and capitalize "
1086 "this word as shown below:\n\t")
1087 (while guess
1088 (if (> (+ 4 (current-column) (length (car guess)))
1089 (window-width))
1090 (progn
1091 (insert "\n\t")
1092 (setq line (1+ line))))
1093 (insert (car guess) " ")
1094 (setq guess (cdr guess)))
1095 (insert "\nUse option `i' if this is a correct composition"
1096 " from the derivative root.\n")
1097 (setq line (+ line (if choices 3 2)))))
1098 (while (and choices
1099 (< (if (> (+ 7 (current-column) (length (car choices))
1100 (if (> count ?~) 3 0))
1101 (window-width))
1102 (progn
1103 (insert "\n")
1104 (setq line (1+ line)))
1105 line)
1106 max-lines))
1107 ;; not so good if there are over 20 or 30 options, but then, if
1108 ;; there are that many you don't want to scan them all anyway...
1109 (while (memq count command-characters) ; skip command characters.
1110 (setq count (ispell-int-char (1+ count))
1111 skipped (1+ skipped)))
1112 (insert "(" count ") " (car choices) " ")
1113 (setq choices (cdr choices)
1114 count (ispell-int-char (1+ count))))
1115 (setq count (ispell-int-char (- count ?0 skipped))))
1116
1117 ;; Assure word is visible
1118 (if (not (pos-visible-in-window-p end))
1119 (sit-for 0))
1120
1121 ;; allow temporary split of dedicated windows...
1122 (if dedicated
1123 (progn
1124 (setq dedicated-win (selected-window))
1125 (set-window-dedicated-p dedicated-win nil)))
1126
1127 ;; Display choices for misspelled word.
1128 (ispell-show-choices line end)
1129
1130 (select-window (setq textwin (next-window)))
1131
1132 ;; highlight word, protecting current buffer status
1133 (unwind-protect
1134 (progn
1135 (and ispell-highlight-p
1136 (ispell-highlight-spelling-error start end t))
1137 ;; Loop until a valid choice is made.
1138 (while
1139 (eq
1140 t
1141 (setq
1142 result
1143 (progn
1144 (undo-boundary)
1145 (let (message-log-max)
1146 (message (concat "C-h or ? for more options; SPC to leave "
1147 "unchanged, Character to replace word")))
1148 (let ((inhibit-quit t))
1149 (setq char (if (fboundp 'read-char-exclusive)
1150 (read-char-exclusive)
1151 (read-char))
1152 skipped 0)
1153 (if (or quit-flag (= char ?\C-g)) ; C-g is like typing X
1154 (setq char ?X
1155 quit-flag nil)))
1156 ;; Adjust num to array offset skipping command characters.
1157 (let ((com-chars command-characters))
1158 (while com-chars
1159 (if (and (> (car com-chars) ?0) (< (car com-chars) char))
1160 (setq skipped (1+ skipped)))
1161 (setq com-chars (cdr com-chars)))
1162 (setq num (- char ?0 skipped)))
1163
1164 (cond
1165 ((= char ? ) nil) ; accept word this time only
1166 ((= char ?i) ; accept and insert word into pers dict
1167 (process-send-string ispell-process (concat "*" word "\n"))
1168 (setq ispell-pdict-modified-p '(t)) ; dictionary modified!
1169 nil)
1170 ((or (= char ?a) (= char ?A)) ; accept word without insert
1171 (process-send-string ispell-process (concat "@" word "\n"))
1172 (if (null ispell-pdict-modified-p)
1173 (setq ispell-pdict-modified-p
1174 (list ispell-pdict-modified-p)))
1175 (if (= char ?A) 0)) ; return 0 for ispell-add buffer-local
1176 ((or (= char ?r) (= char ?R)) ; type in replacement
1177 (and (eq 'block ispell-highlight-p) ; refresh tty's
1178 (ispell-highlight-spelling-error start end nil t))
1179 (let ((result
1180 (if (or (= char ?R) ispell-query-replace-choices)
1181 (list (read-string "Query-replacement for: "
1182 word) t)
1183 (cons (read-string "Replacement for: " word)
1184 nil))))
1185 (and (eq 'block ispell-highlight-p)
1186 (ispell-highlight-spelling-error start end nil
1187 'block))
1188 result))
1189 ((or (= char ??) (= char help-char) (= char ?\C-h))
1190 (and (eq 'block ispell-highlight-p)
1191 (ispell-highlight-spelling-error start end nil t))
1192 (ispell-help)
1193 (and (eq 'block ispell-highlight-p)
1194 (ispell-highlight-spelling-error start end nil
1195 'block))
1196 t)
1197 ;; Quit and move point back.
1198 ((= char ?x)
1199 (ispell-pdict-save ispell-silently-savep)
1200 (message "Exited spell-checking")
1201 (setq ispell-quit t)
1202 nil)
1203 ;; Quit and preserve point.
1204 ((= char ?X)
1205 (ispell-pdict-save ispell-silently-savep)
1206 (message "%s"
1207 (substitute-command-keys
1208 (concat "Spell-checking suspended;"
1209 " use C-u \\[ispell-word] to resume")))
1210 (setq ispell-quit start)
1211 nil)
1212 ((= char ?q)
1213 (if (y-or-n-p "Really kill Ispell process? ")
1214 (progn
1215 (ispell-kill-ispell t) ; terminate process.
1216 (setq ispell-quit (or (not ispell-checking-message)
1217 (point))
1218 ispell-pdict-modified-p nil))
1219 t)) ; continue if they don't quit.
1220 ((= char ?l)
1221 (and (eq 'block ispell-highlight-p) ; refresh tty displays
1222 (ispell-highlight-spelling-error start end nil t))
1223 (let ((new-word (read-string
1224 "Lookup string (`*' is wildcard): "
1225 word))
1226 (new-line 2))
1227 (if new-word
1228 (progn
1229 (save-excursion
1230 (set-buffer (get-buffer-create
1231 ispell-choices-buffer))
1232 (erase-buffer)
1233 (setq count ?0
1234 skipped 0
1235 mode-line-format (concat
1236 "-- %b -- word: "
1237 new-word)
1238 miss (lookup-words new-word)
1239 choices miss)
1240 (while (and choices ; adjust choices window.
1241 (< (if (> (+ 7 (current-column)
1242 (length (car choices))
1243 (if (> count ?~) 3 0))
1244 (window-width))
1245 (progn
1246 (insert "\n")
1247 (setq new-line
1248 (1+ new-line)))
1249 new-line)
1250 max-lines))
1251 (while (memq count command-characters)
1252 (setq count (ispell-int-char (1+ count))
1253 skipped (1+ skipped)))
1254 (insert "(" count ") " (car choices) " ")
1255 (setq choices (cdr choices)
1256 count (ispell-int-char (1+ count))))
1257 (setq count (ispell-int-char
1258 (- count ?0 skipped))))
1259 (select-window (previous-window))
1260 (if (and (/= new-line line)
1261 (> (max line new-line)
1262 ispell-choices-win-default-height))
1263 (let* ((minh ispell-choices-win-default-height)
1264 (gr-bl (if (< line minh) ; blanks
1265 (- minh line)
1266 0))
1267 (shr-bl (if (< new-line minh) ; blanks
1268 (- minh new-line)
1269 0)))
1270 (if (> new-line line)
1271 (enlarge-window (- new-line line gr-bl))
1272 (shrink-window (- line new-line shr-bl)))
1273 (setq line new-line)))
1274 (select-window (next-window)))))
1275 (and (eq 'block ispell-highlight-p)
1276 (ispell-highlight-spelling-error start end nil
1277 'block))
1278 t) ; reselect from new choices
1279 ((= char ?u)
1280 (process-send-string ispell-process
1281 (concat "*" (downcase word) "\n"))
1282 (setq ispell-pdict-modified-p '(t)) ; dictionary modified!
1283 nil)
1284 ((= char ?m) ; type in what to insert
1285 (process-send-string
1286 ispell-process (concat "*" (read-string "Insert: " word)
1287 "\n"))
1288 (setq ispell-pdict-modified-p '(t))
1289 (cons word nil))
1290 ((and (>= num 0) (< num count))
1291 (if ispell-query-replace-choices ; Query replace flag
1292 (list (nth num miss) 'query-replace)
1293 (nth num miss)))
1294 ((= char ?\C-l)
1295 (redraw-display) t)
1296 ((= char ?\C-r)
1297 (if (marker-position ispell-recursive-edit-marker)
1298 (progn
1299 (message "Only one recursive edit session supported")
1300 (beep))
1301 (set-marker ispell-recursive-edit-marker start)
1302 ;;(set-marker ispell-region-end reg-end)
1303 (and ispell-highlight-p ; unhighlight
1304 (ispell-highlight-spelling-error start end))
1305 (unwind-protect
1306 (progn
1307 (save-window-excursion (save-excursion
1308 (recursive-edit)) t)
1309 (if (not (equal (marker-buffer
1310 ispell-recursive-edit-marker)
1311 (current-buffer)))
1312 (error
1313 "Cannot continue ispell from this buffer."))
1314 (goto-char ispell-recursive-edit-marker))
1315 (set-marker ispell-recursive-edit-marker nil)))
1316 (cons word nil)) ; recheck starting at this word.
1317 ((= char ?\C-z)
1318 (funcall (key-binding "\C-z"))
1319 t)
1320 (t (ding) t))))))
1321 result)
1322 ;; protected
1323 (and ispell-highlight-p ; unhighlight
1324 (save-window-excursion
1325 (select-window textwin)
1326 (ispell-highlight-spelling-error start end)))
1327 (if dedicated
1328 (set-window-dedicated-p dedicated-win t)))))
1329
1330
1331
1332 (defun ispell-show-choices (line end)
1333 "Shows the choices in another buffer or frame."
1334 (if ispell-use-framepop-p
1335 (progn
1336 (framepop-display-buffer (get-buffer ispell-choices-buffer))
1337 (get-buffer-window ispell-choices-buffer t)
1338 (select-window (previous-window))) ; *Choices* window
1339 ;; standard selection by splitting a small buffer out of this window.
1340 (let ((choices-window (get-buffer-window ispell-choices-buffer)))
1341 (if choices-window
1342 (if (= line (window-height choices-window))
1343 (select-window choices-window)
1344 ;; *Choices* window changed size. Adjust the choices window
1345 ;; without scrolling the spelled window when possible
1346 (let ((window-line (- line (window-height choices-window)))
1347 (visible (progn (vertical-motion -1) (point))))
1348 (if (< line ispell-choices-win-default-height)
1349 (setq window-line (+ window-line
1350 (- ispell-choices-win-default-height
1351 line))))
1352 (move-to-window-line 0)
1353 (vertical-motion window-line)
1354 (set-window-start (selected-window)
1355 (if (> (point) visible) visible (point)))
1356 (goto-char end)
1357 (select-window (previous-window)) ; *Choices* window
1358 (enlarge-window window-line)))
1359 ;; Overlay *Choices* window when it isn't showing
1360 (ispell-overlay-window (max line ispell-choices-win-default-height)))
1361 (switch-to-buffer ispell-choices-buffer)
1362 (goto-char (point-min)))))
1363
1364
1365 ;;;###autoload
1366 (defun ispell-help ()
1367 "Display a list of the options available when a misspelling is encountered.
1368
1369 Selections are:
1370
1371 DIGIT: Replace the word with a digit offered in the *Choices* buffer.
1372 SPC: Accept word this time.
1373 `i': Accept word and insert into private dictionary.
1374 `a': Accept word for this session.
1375 `A': Accept word and place in `buffer-local dictionary'.
1376 `r': Replace word with typed-in value. Rechecked.
1377 `R': Replace word with typed-in value. Query-replaced in buffer. Rechecked.
1378 `?': Show these commands.
1379 `x': Exit spelling buffer. Move cursor to original point.
1380 `X': Exit spelling buffer. Leaves cursor at the current point, and permits
1381 the aborted check to be completed later.
1382 `q': Quit spelling session (Kills ispell process).
1383 `l': Look up typed-in replacement in alternate dictionary. Wildcards okay.
1384 `u': Like `i', but the word is lower-cased first.
1385 `m': Place typed-in value in personal dictionary, then recheck current word.
1386 `C-l': redraws screen
1387 `C-r': recursive edit
1388 `C-z': suspend emacs or iconify frame"
1389
1390 (if (equal ispell-help-in-bufferp 'electric)
1391 (progn
1392 (require 'ehelp)
1393 (with-electric-help
1394 (function (lambda ()
1395 ;;This shouldn't be necessary: with-electric-help needs
1396 ;; an optional argument telling it about the smallest
1397 ;; acceptable window-height of the help buffer.
1398 (if (< (window-height) 15)
1399 (enlarge-window (- 15 (window-height))))
1400 (princ "Selections are:
1401
1402 DIGIT: Replace the word with a digit offered in the *Choices* buffer.
1403 SPC: Accept word this time.
1404 `i': Accept word and insert into private dictionary.
1405 `a': Accept word for this session.
1406 `A': Accept word and place in `buffer-local dictionary'.
1407 `r': Replace word with typed-in value. Rechecked.
1408 `R': Replace word with typed-in value. Query-replaced in buffer. Rechecked.
1409 `?': Show these commands.
1410 `x': Exit spelling buffer. Move cursor to original point.
1411 `X': Exit spelling buffer. Leaves cursor at the current point, and permits
1412 the aborted check to be completed later.
1413 `q': Quit spelling session (Kills ispell process).
1414 `l': Look up typed-in replacement in alternate dictionary. Wildcards okay.
1415 `u': Like `i', but the word is lower-cased first.
1416 `m': Place typed-in value in personal dictionary, then recheck current word.
1417 `C-l': redraws screen
1418 `C-r': recursive edit
1419 `C-z': suspend emacs or iconify frame")
1420 nil ;undocumented requirement of with-electric-help
1421 ))))
1422
1423
1424 (let ((help-1 (concat "[r/R]eplace word; [a/A]ccept for this session; "
1425 "[i]nsert into private dictionary"))
1426 (help-2 (concat "[l]ook a word up in alternate dictionary; "
1427 "e[x/X]it; [q]uit session"))
1428 (help-3 (concat "[u]ncapitalized insert into dict. "
1429 "Type 'x C-h d ispell-help' for more help")))
1430 (save-window-excursion
1431 (if ispell-help-in-bufferp
1432 (progn
1433 (ispell-overlay-window 4)
1434 (switch-to-buffer (get-buffer-create "*Ispell Help*"))
1435 (insert (concat help-1 "\n" help-2 "\n" help-3))
1436 (sit-for 5)
1437 (kill-buffer "*Ispell Help*"))
1438 (select-window (minibuffer-window))
1439 ;;(enlarge-window 2)
1440 (erase-buffer)
1441 (cond ((string-match "Lucid\\|XEmacs" emacs-version)
1442 (message help-3)
1443 (enlarge-window 1)
1444 (message help-2)
1445 (enlarge-window 1)
1446 (message help-1)
1447 (goto-char (point-min)))
1448 (t
1449 (if (not (string-match "18\\.[0-9]+\\.[0-9]+" emacs-version))
1450 (message nil))
1451 ;;(set-minibuffer-window (selected-window))
1452 (enlarge-window 2)
1453 (insert (concat help-1 "\n" help-2 "\n" help-3))))
1454 (sit-for 5)
1455 (erase-buffer))))))
1456
1457
1458 (defun lookup-words (word &optional lookup-dict)
1459 "Look up word in word-list dictionary.
1460 A `*' serves as a wild card. If no wild cards, `look' is used if it exists.
1461 Otherwise the variable `ispell-grep-command' contains the command used to
1462 search for the words (usually egrep).
1463
1464 Optional second argument contains the dictionary to use; the default is
1465 `ispell-alternate-dictionary'."
1466 ;; We don't use the filter for this function, rather the result is written
1467 ;; into a buffer. Hence there is no need to save the filter values.
1468 (if (null lookup-dict)
1469 (setq lookup-dict ispell-alternate-dictionary))
1470
1471 (let* ((process-connection-type ispell-use-ptys-p)
1472 (wild-p (string-match "\\*" word))
1473 (look-p (and ispell-look-p ; Only use look for an exact match.
1474 (or ispell-have-new-look (not wild-p))))
1475 (ispell-grep-buffer (get-buffer-create "*Ispell-Temp*")) ; result buf
1476 (prog (if look-p ispell-look-command ispell-grep-command))
1477 (args (if look-p ispell-look-options ispell-grep-options))
1478 status results loc)
1479 (unwind-protect
1480 (save-window-excursion
1481 (message "Starting \"%s\" process..." (file-name-nondirectory prog))
1482 (set-buffer ispell-grep-buffer)
1483 (if look-p
1484 nil
1485 ;; convert * to .*
1486 (insert "^" word "$")
1487 (while (search-backward "*" nil t) (insert "."))
1488 (setq word (buffer-string))
1489 (erase-buffer))
1490 (setq status (call-process prog nil t nil args word lookup-dict))
1491 ;; grep returns status 1 and no output when word not found, which
1492 ;; is a perfectly normal thing.
1493 (if (stringp status)
1494 (setq results (cons (format "error: %s exited with signal %s"
1495 (file-name-nondirectory prog) status)
1496 results))
1497 ;; else collect words into `results' in FIFO order
1498 (goto-char (point-max))
1499 ;; assure we've ended with \n
1500 (or (bobp) (= (preceding-char) ?\n) (insert ?\n))
1501 (while (not (bobp))
1502 (setq loc (point))
1503 (forward-line -1)
1504 (setq results (cons (buffer-substring-no-properties (point)
1505 (1- loc))
1506 results)))))
1507 ;; protected
1508 (kill-buffer ispell-grep-buffer)
1509 (if (and results (string-match ".+: " (car results)))
1510 (error "%s error: %s" ispell-grep-command (car results))))
1511 results))
1512
1513
1514 ;;; "ispell-filter" is a list of output lines from the generating function.
1515 ;;; Each full line (ending with \n) is a separate item on the list.
1516 ;;; "output" can contain multiple lines, part of a line, or both.
1517 ;;; "start" and "end" are used to keep bounds on lines when "output" contains
1518 ;;; multiple lines.
1519 ;;; "ispell-filter-continue" is true when we have received only part of a
1520 ;;; line as output from a generating function ("output" did not end with \n)
1521 ;;; THIS FUNCTION WILL FAIL IF THE PROCESS OUTPUT DOESN'T END WITH \n!
1522 ;;; This is the case when a process dies or fails. The default behavior
1523 ;;; in this case treats the next input received as fresh input.
1524
1525 (defun ispell-filter (process output)
1526 "Output filter function for ispell, grep, and look."
1527 (let ((start 0)
1528 (continue t)
1529 end)
1530 (while continue
1531 (setq end (string-match "\n" output start)) ; get text up to the newline.
1532 ;; If we get out of sync and ispell-filter-continue is asserted when we
1533 ;; are not continuing, treat the next item as a separate list. When
1534 ;; ispell-filter-continue is asserted, ispell-filter *should* always be a
1535 ;; list!
1536
1537 ;; Continue with same line (item)?
1538 (if (and ispell-filter-continue ispell-filter (listp ispell-filter))
1539 ;; Yes. Add it to the prev item
1540 (setcar ispell-filter
1541 (concat (car ispell-filter) (substring output start end)))
1542 ;; No. This is a new line and item.
1543 (setq ispell-filter
1544 (cons (substring output start end) ispell-filter)))
1545 (if (null end)
1546 ;; We've completed reading the output, but didn't finish the line.
1547 (setq ispell-filter-continue t continue nil)
1548 ;; skip over newline, this line complete.
1549 (setq ispell-filter-continue nil end (1+ end))
1550 (if (= end (length output)) ; No more lines in output
1551 (setq continue nil) ; so we can exit the filter.
1552 (setq start end)))))) ; else move start to next line of input
1553
1554
1555 ;;; This function destroys the mark location if it is in the word being
1556 ;;; highlighted.
1557 (defun ispell-highlight-spelling-error-generic (start end &optional highlight
1558 refresh)
1559 "Highlight the word from START to END with a kludge using `inverse-video'.
1560 When the optional third arg HIGHLIGHT is set, the word is highlighted;
1561 otherwise it is displayed normally.
1562 Uses block cursor to highlight one character.
1563 Optional REFRESH will unhighlighted then highlight, using block cursor
1564 highlighting when REFRESH is equal to `block'."
1565 (and (eq 'block ispell-highlight-p)
1566 (or (eq 'block refresh)
1567 (setq start (1+ start)))) ; On block non-refresh, inc start.
1568 (let ((modified (buffer-modified-p)) ; don't allow this fn to modify buffer
1569 (buffer-read-only nil) ; Allow highlighting read-only buffers.
1570 (text (buffer-substring-no-properties start end)) ; Save hilight region
1571 (inhibit-quit t) ; inhibit interrupt processing here.
1572 (buffer-undo-list t)) ; don't clutter the undo list.
1573 (goto-char end)
1574 (delete-region start end)
1575 (insert-char ? (- end start)) ; minimize amount of redisplay
1576 (sit-for 0) ; update display
1577 (if highlight (setq inverse-video (not inverse-video))) ; toggle video
1578 (delete-region start end) ; delete whitespace
1579 (insert text) ; insert text in inverse video.
1580 (sit-for 0) ; update display showing inverse video.
1581 (if (not highlight)
1582 (goto-char end)
1583 (setq inverse-video (not inverse-video)) ; toggle video
1584 (and (eq 'block ispell-highlight-p)
1585 (goto-char (1- start)))) ; use block cursor to "highlight" char
1586 (set-buffer-modified-p modified) ; don't modify if flag not set.
1587 (and refresh ; re-highlight
1588 (ispell-highlight-spelling-error-generic
1589 (if (eq 'block refresh) start (- start 2)) end t))))
1590
1591
1592 (defun ispell-highlight-spelling-error-xemacs (start end &optional highlight)
1593 "Highlight the word from START to END using `isearch-highlight'.
1594 When the optional third arg HIGHLIGHT is set, the word is highlighted,
1595 otherwise it is displayed normally."
1596 (if highlight
1597 (isearch-highlight start end)
1598 (isearch-dehighlight t))
1599 ;;(sit-for 0)
1600 )
1601
1602
1603 (defun ispell-highlight-spelling-error-overlay (start end &optional highlight)
1604 "Highlight the word from START to END using overlays.
1605 When the optional third arg HIGHLIGHT is set, the word is highlighted
1606 otherwise it is displayed normally.
1607
1608 The variable `ispell-highlight-face' selects the face to use for highlighting."
1609 (if highlight
1610 (progn
1611 (setq ispell-overlay (make-overlay start end))
1612 (overlay-put ispell-overlay 'face ispell-highlight-face))
1613 (delete-overlay ispell-overlay)))
1614
1615
1616 (defun ispell-highlight-spelling-error (start end &optional highlight refresh)
1617 (cond
1618 ((string-match "Lucid\\|XEmacs" emacs-version)
1619 (ispell-highlight-spelling-error-xemacs start end highlight))
1620 ((and (not (string-match "18\\.[0-9]+\\.[0-9]+" emacs-version))
1621 (featurep 'faces) window-system)
1622 (ispell-highlight-spelling-error-overlay start end highlight))
1623 (t (ispell-highlight-spelling-error-generic start end highlight refresh))))
1624
1625
1626 (defun ispell-overlay-window (height)
1627 "Create a window covering the top HEIGHT lines of the current window.
1628 Ensure that the line above point is still visible but otherwise avoid
1629 scrolling the current window. Leave the new window selected."
1630 (save-excursion
1631 (let ((oldot (save-excursion (forward-line -1) (point)))
1632 (top (save-excursion (move-to-window-line height) (point))))
1633 ;; If line above old point (line starting at olddot) would be
1634 ;; hidden by new window, scroll it to just below new win
1635 ;; otherwise set top line of other win so it doesn't scroll.
1636 (if (< oldot top) (setq top oldot))
1637 ;; NB: XEmacs 19.9 bug: If a window of size N (N includes the mode
1638 ;; line) is demanded, the last line is not visible.
1639 ;; At least this happens on AIX 3.2, XEmacs w/ Motif, font 9x15.
1640 ;; So we increment the height for this case.
1641 (if (and (string-match "Lucid\\|XEmacs" emacs-version)
1642 (string-match "19\\.9\\.[0-9]+" emacs-version))
1643 (setq height (1+ height)))
1644 ;; if frame is unsplitable, temporarily disable that...
1645 (if (cdr (assq 'unsplittable (frame-parameters (selected-frame))))
1646 (let ((frame (selected-frame)))
1647 (modify-frame-parameters frame '((unsplittable . nil)))
1648 (split-window nil height)
1649 (modify-frame-parameters frame '((unsplittable . t))))
1650 (split-window nil height))
1651 (set-window-start (next-window) top))))
1652
1653
1654 ;;; Should we add a compound word match return value?
1655 (defun ispell-parse-output (output)
1656 "Parse the OUTPUT string from Ispell process and return:
1657 1: t for an exact match.
1658 2: A string containing the root word matched via suffix removal.
1659 3: A list of possible correct spellings of the format:
1660 (\"ORIGINAL-WORD\" OFFSET MISS-LIST GUESS-LIST)
1661 ORIGINAL-WORD is a string of the possibly misspelled word.
1662 OFFSET is an integer giving the line offset of the word.
1663 MISS-LIST and GUESS-LIST are possibly null lists of guesses and misses.
1664 4: Nil when an error has occurred."
1665 (cond
1666 ((string= output "") t) ; for startup with pipes...
1667 ((string= output "*") t) ; exact match
1668 ((string= output "-") t) ; compound word match
1669 ((string= (substring output 0 1) "+") ; found because of root word
1670 (substring output 2)) ; return root word
1671 ((equal 0 (string-match "[\ a-zA-Z]" output))
1672 (ding) ; error message from ispell!
1673 (message (concat "Ispell error: " output))
1674 (sit-for 5)
1675 nil)
1676 (t ; need to process &, ?, and #'s
1677 (let ((type (substring output 0 1)) ; &, ?, or #
1678 (original-word (substring output 2 (string-match " " output 2)))
1679 (cur-count 0) ; contains number of misses + guesses
1680 count miss-list guess-list offset)
1681 (setq output (substring output (match-end 0))) ; skip over misspelling
1682 (if (string= type "#")
1683 (setq count 0) ; no misses for type #
1684 (setq count (string-to-int output) ; get number of misses.
1685 output (substring output (1+ (string-match " " output 1)))))
1686 (setq offset (string-to-int output))
1687 (if (string= type "#") ; No miss or guess list.
1688 (setq output nil)
1689 (setq output (substring output (1+ (string-match " " output 1)))))
1690 (while output
1691 (let ((end (string-match ", \\|\\($\\)" output))) ; end of miss/guess.
1692 (setq cur-count (1+ cur-count))
1693 (if (> cur-count count)
1694 (setq guess-list (cons (substring output 0 end) guess-list))
1695 (setq miss-list (cons (substring output 0 end) miss-list)))
1696 (if (match-end 1) ; True only when at end of line.
1697 (setq output nil) ; no more misses or guesses
1698 (setq output (substring output (+ end 2))))))
1699 (list original-word offset miss-list guess-list)))))
1700
1701
1702 (defun check-ispell-version (&optional interactivep)
1703 ;; This is a little wasteful as we actually launch ispell twice: once
1704 ;; to make sure it's the right version, and once for real. But people
1705 ;; get confused by version mismatches *all* the time (and I've got the
1706 ;; email to prove it) so I think this is worthwhile. And the -v[ersion]
1707 ;; option is the only way I can think of to do this that works with
1708 ;; all versions, since versions earlier than 3.0.09 didn't identify
1709 ;; themselves on startup.
1710 (interactive "p")
1711 (save-excursion
1712 (let (case-fold-search status
1713 ;; avoid bugs when syntax of `.' changes in various default modes
1714 (default-major-mode 'fundamental-mode)
1715 (result t))
1716 (set-buffer (get-buffer-create " *ispell-tmp*"))
1717 (setq case-fold-search t)
1718 (erase-buffer)
1719 (setq status (call-process ispell-program-name nil t nil "-v"))
1720 (goto-char (point-min))
1721 (if interactivep
1722 (progn
1723 (end-of-line)
1724 (setq result (concat (buffer-substring-no-properties (point-min)
1725 (point))
1726 ", "
1727 ispell-version))
1728 (message result)
1729 (goto-char (point-min))))
1730 (if (not (memq status '(0 nil)))
1731 (error "%s exited with %s %s" ispell-program-name
1732 (if (stringp status) "signal" "code") status))
1733 (if (not (re-search-forward
1734 (concat "\\<\\("
1735 (regexp-quote (car ispell-required-version))
1736 "\\)\\([0-9]*\\)\\>")
1737 nil t))
1738 (error "%s version 3 release %s%s or greater is required"
1739 ispell-program-name (car ispell-required-version)
1740 (car (cdr ispell-required-version)))
1741 ;; check that it is the correct version.
1742 (if (< (car (read-from-string (buffer-substring-no-properties
1743 (match-beginning 2) (match-end 2))))
1744 (car (cdr ispell-required-version)))
1745 (setq ispell-offset 0)))
1746 (kill-buffer (current-buffer))
1747 result)))
1748
1749
1750 (defun ispell-init-process ()
1751 "Check status of Ispell process and start if necessary."
1752 (if (and ispell-process
1753 (eq (process-status ispell-process) 'run)
1754 ;; If we're using a personal dictionary, assure
1755 ;; we're in the same default directory!
1756 (or (not ispell-personal-dictionary)
1757 (equal ispell-process-directory default-directory)))
1758 (setq ispell-filter nil ispell-filter-continue nil)
1759 ;; may need to restart to select new personal dictionary.
1760 (ispell-kill-ispell t)
1761 (message "Starting new Ispell process...")
1762 (sit-for 0)
1763 (check-ispell-version)
1764 (setq ispell-process
1765 (let ((process-connection-type ispell-use-ptys-p))
1766 (apply 'start-process
1767 "ispell" nil ispell-program-name
1768 "-a" ; accept single input lines
1769 "-m" ; make root/affix combos not in dict
1770 (let (args)
1771 ;; Local dictionary becomes the global dictionary in use.
1772 (if ispell-local-dictionary
1773 (setq ispell-dictionary ispell-local-dictionary))
1774 (setq args (ispell-get-ispell-args))
1775 (if ispell-dictionary ; use specified dictionary
1776 (setq args
1777 (append (list "-d" ispell-dictionary) args)))
1778 (if ispell-personal-dictionary ; use specified pers dict
1779 (setq args
1780 (append args
1781 (list "-p"
1782 (expand-file-name
1783 ispell-personal-dictionary)))))
1784 (setq args (append args ispell-extra-args))
1785 args)))
1786 ispell-filter nil
1787 ispell-filter-continue nil
1788 ispell-process-directory default-directory)
1789 (set-process-filter ispell-process 'ispell-filter)
1790 (if (and (boundp 'enable-multibyte-characters)
1791 (fboundp 'set-process-coding-system)
1792 enable-multibyte-characters)
1793 (set-process-coding-system ispell-process (ispell-get-coding-system)))
1794 ;; Get version ID line
1795 (if (not (string-match "18\\.[0-9]+\\.[0-9]+" emacs-version))
1796 (accept-process-output ispell-process 5)
1797 (accept-process-output ispell-process))
1798 ;; get more output if filter empty?
1799 (if (null ispell-filter) (accept-process-output ispell-process 5))
1800 (cond ((null ispell-filter)
1801 (error "%s did not output version line" ispell-program-name))
1802 ((and
1803 (stringp (car ispell-filter))
1804 (if (string-match "warning: " (car ispell-filter))
1805 (progn
1806 (if (not (string-match "18\\.[0-9]+\\.[0-9]+" emacs-version))
1807 (accept-process-output ispell-process 5) ; was warn msg.
1808 (accept-process-output ispell-process))
1809 (stringp (car ispell-filter)))
1810 (null (cdr ispell-filter)))
1811 (string-match "^@(#) " (car ispell-filter)))
1812 ;; got the version line as expected (we already know it's the right
1813 ;; version, so don't bother checking again.)
1814 nil)
1815 (t
1816 ;; Otherwise, it must be an error message. Show the user.
1817 ;; But first wait to see if some more output is going to arrive.
1818 ;; Otherwise we get cool errors like "Can't open ".
1819 (sleep-for 1)
1820 (accept-process-output)
1821 (error "%s" (mapconcat 'identity ispell-filter "\n"))))
1822 (setq ispell-filter nil) ; Discard version ID line
1823 (let ((extended-char-mode (ispell-get-extended-character-mode)))
1824 (if extended-char-mode
1825 (process-send-string ispell-process
1826 (concat extended-char-mode "\n"))))
1827 (process-kill-without-query ispell-process)))
1828
1829 ;;;###autoload
1830 (defun ispell-kill-ispell (&optional no-error)
1831 "Kill current Ispell process (so that you may start a fresh one).
1832 With NO-ERROR, just return non-nil if there was no Ispell running."
1833 (interactive)
1834 (if (not (and ispell-process
1835 (eq (process-status ispell-process) 'run)))
1836 (or no-error
1837 (error "There is no ispell process running!"))
1838 (kill-process ispell-process)
1839 (setq ispell-process nil)
1840 (message "Ispell process killed")
1841 nil))
1842
1843
1844 ;;; ispell-change-dictionary is set in some people's hooks. Maybe this should
1845 ;;; call ispell-init-process rather than wait for a spell checking command?
1846
1847 ;;;###autoload
1848 (defun ispell-change-dictionary (dict &optional arg)
1849 "Change `ispell-dictionary' (q.v.) and kill old Ispell process.
1850 A new one will be started as soon as necessary.
1851
1852 By just answering RET you can find out what the current dictionary is.
1853
1854 With prefix argument, set the default directory."
1855 (interactive
1856 (list (completing-read
1857 "Use new dictionary (RET for current, SPC to complete): "
1858 (cons (cons "default" nil) ispell-dictionary-alist) nil t)
1859 current-prefix-arg))
1860 (if (equal dict "default") (setq dict nil))
1861 ;; This relies on completing-read's bug of returning "" for no match
1862 (cond ((equal dict "")
1863 (message "Using %s dictionary"
1864 (or ispell-local-dictionary ispell-dictionary "default")))
1865 ((and (equal dict ispell-dictionary)
1866 (or (null ispell-local-dictionary)
1867 (equal dict ispell-local-dictionary)))
1868 ;; Specified dictionary is the default already. No-op
1869 (and (interactive-p)
1870 (message "No change, using %s dictionary" (or dict "default"))))
1871 (t ; reset dictionary!
1872 (if (assoc dict ispell-dictionary-alist)
1873 (progn
1874 (if (or arg (null dict)) ; set default dictionary
1875 (setq ispell-dictionary dict))
1876 (if (null arg) ; set local dictionary
1877 (setq ispell-local-dictionary dict)))
1878 (error "Undefined dictionary: %s" dict))
1879 (ispell-kill-ispell t)
1880 (message "(Next %sIspell command will use %s dictionary)"
1881 (cond ((equal ispell-local-dictionary ispell-dictionary)
1882 "")
1883 (arg "global ")
1884 (t "local "))
1885 (or (if (or (equal ispell-local-dictionary ispell-dictionary)
1886 (null arg))
1887 ispell-local-dictionary
1888 ispell-dictionary)
1889 "default")))))
1890
1891
1892 ;;; Spelling of comments are checked when ispell-check-comments is non-nil.
1893
1894 ;;;###autoload
1895 (defun ispell-region (reg-start reg-end)
1896 "Interactively check a region for spelling errors.
1897 Return non-nil if not aborted."
1898 (interactive "r") ; Don't flag errors on read-only bufs.
1899 (ispell-accept-buffer-local-defs) ; set up dictionary, local words, etc.
1900 (unwind-protect
1901 (save-excursion
1902 (message "Spell checking %s using %s dictionary..."
1903 (if (and (= reg-start (point-min)) (= reg-end (point-max)))
1904 (buffer-name) "region")
1905 (or ispell-dictionary "default"))
1906 ;; Returns cursor to original location.
1907 (save-window-excursion
1908 (goto-char reg-start)
1909 (let ((transient-mark-mode nil)
1910 (case-fold-search case-fold-search)
1911 (skip-region-start (make-marker))
1912 (skip-regexp (ispell-begin-skip-region-regexp))
1913 (skip-alist ispell-skip-region-alist)
1914 key)
1915 (if (eq ispell-parser 'tex)
1916 (setq case-fold-search nil
1917 skip-alist
1918 (append (car ispell-tex-skip-alists)
1919 (car (cdr ispell-tex-skip-alists))
1920 skip-alist)))
1921 (let (message-log-max)
1922 (message "searching for regions to skip"))
1923 (if (re-search-forward skip-regexp reg-end t)
1924 (progn
1925 (setq key (buffer-substring-no-properties
1926 (match-beginning 0) (match-end 0)))
1927 (set-marker skip-region-start (- (point) (length key)))
1928 (goto-char reg-start)))
1929 (let (message-log-max)
1930 (message "Continuing spelling check using %s dictionary..."
1931 (or ispell-dictionary "default")))
1932 (set-marker ispell-region-end reg-end)
1933 (while (and (not ispell-quit)
1934 (< (point) ispell-region-end))
1935 ;; spell-check region with skipping
1936 (if (and (marker-position skip-region-start)
1937 (<= skip-region-start (point)))
1938 (progn
1939 (ispell-skip-region key skip-alist) ; moves pt past region.
1940 (setq reg-start (point))
1941 (if (and (< reg-start ispell-region-end)
1942 (re-search-forward skip-regexp
1943 ispell-region-end t))
1944 (progn
1945 (setq key (buffer-substring-no-properties
1946 (car (match-data))
1947 (car (cdr (match-data)))))
1948 (set-marker skip-region-start
1949 (- (point) (length key)))
1950 (goto-char reg-start))
1951 (set-marker skip-region-start nil))))
1952 (setq reg-end (if (marker-position skip-region-start)
1953 (min skip-region-start ispell-region-end)
1954 (marker-position ispell-region-end)))
1955 (let* ((start (point))
1956 (end (save-excursion (end-of-line) (min (point) reg-end)))
1957 (string (ispell-get-line start end reg-end)))
1958 (setq end (point)) ; "end" tracks region retrieved.
1959 (if string ; there is something to spell check!
1960 (ispell-process-line string)) ; (special start end)
1961 (goto-char end)))))
1962 (not ispell-quit)
1963 )
1964 ;; protected
1965 (if (get-buffer ispell-choices-buffer)
1966 (kill-buffer ispell-choices-buffer))
1967 (if ispell-quit
1968 (progn
1969 ;; preserve or clear the region for ispell-continue.
1970 (if (not (numberp ispell-quit))
1971 (set-marker ispell-region-end nil)
1972 ;; Ispell-continue enabled - ispell-region-end is set.
1973 (goto-char ispell-quit))
1974 ;; Check for aborting
1975 (if (and ispell-checking-message (numberp ispell-quit))
1976 (progn
1977 (setq ispell-quit nil)
1978 (error "Message send aborted.")))
1979 (setq ispell-quit nil))
1980 (set-marker ispell-region-end nil)
1981 ;; Only save if successful exit.
1982 (ispell-pdict-save ispell-silently-savep)
1983 (message "Spell-checking done"))))
1984
1985
1986 ;;; Creates the regexp for skipping a region.
1987 ;;; Makes the skip-regexp local for tex buffers adding in the
1988 ;;; tex expressions to skip as well.
1989 ;;; Call AFTER ispell-buffer-local-parsing.
1990 (defun ispell-begin-skip-region-regexp ()
1991 (let ((skip-regexp (ispell-begin-skip-region)))
1992 (if (and (null ispell-check-comments) comment-start)
1993 (setq skip-regexp (concat (regexp-quote comment-start) "\\|"
1994 skip-regexp)))
1995 (if (and (eq 'exclusive ispell-check-comments) comment-start)
1996 (setq skip-regexp (concat (if (string= "" comment-end) "^"
1997 (regexp-quote comment-end))
1998 "\\|" skip-regexp)))
1999 (if ispell-skip-tib
2000 (setq skip-regexp (concat ispell-tib-ref-beginning "\\|" skip-regexp)))
2001 (if ispell-skip-sgml
2002 (setq skip-regexp (concat "[<&]\\|" skip-regexp)))
2003 (if (eq ispell-parser 'tex)
2004 (setq skip-regexp (concat (ispell-begin-tex-skip-regexp) "\\|"
2005 skip-regexp)))
2006 skip-regexp))
2007
2008
2009 ;;; Regular expression of tex commands to skip.
2010 ;;; Generated from `ispell-tex-skip-alists'
2011 (defun ispell-begin-tex-skip-regexp ()
2012 (concat
2013 (mapconcat (function (lambda (lst) (car lst)))
2014 (car ispell-tex-skip-alists)
2015 "\\|")
2016 "\\|"
2017 (mapconcat (function (lambda (lst)
2018 (concat "\\\\begin[ \t\n]*{[ \t\n]*"
2019 (car lst)
2020 "[ \t\n]*}")))
2021 (car (cdr ispell-tex-skip-alists))
2022 "\\|")))
2023
2024
2025 ;;; Regular expression of regions to skip for all buffers.
2026 ;;; Each selection should be a key of `ispell-skip-region-alist'
2027 ;;; otherwise, the current line is skipped.
2028 (defun ispell-begin-skip-region ()
2029 (mapconcat (function (lambda (lst) (if (stringp (car lst)) (car lst)
2030 (eval (car lst)))))
2031 ispell-skip-region-alist
2032 "\\|"))
2033
2034
2035 (defun ispell-tex-arg-end (&optional arg)
2036 (condition-case nil
2037 (progn
2038 (while (looking-at "[ \t\n]*\\[") (forward-sexp))
2039 (forward-sexp (or arg 1)))
2040 (error
2041 (message "error skipping s-expressions at point %d." (point))
2042 (beep)
2043 (sit-for 2))))
2044
2045
2046 ;;; Skips to region-end from point, or a single line.
2047 ;;; Places point at end of region skipped.
2048 (defun ispell-skip-region (key alist)
2049 ;; move over key to begin checking.
2050 (forward-char (length key))
2051 (let ((start (point))
2052 alist-key null-skip)
2053 (cond
2054 ;; what about quoted comment, or comment inside strings?
2055 ((and (null ispell-check-comments) comment-start
2056 (string= key comment-start))
2057 (if (string= "" comment-end)
2058 (forward-line)
2059 (search-forward comment-end ispell-region-end t)))
2060 ((and (eq 'exclusive ispell-check-comments) comment-start
2061 (string= key comment-end))
2062 (search-forward comment-start ispell-region-end :end))
2063 ((and ispell-skip-tib (string-match ispell-tib-ref-beginning key))
2064 (re-search-forward ispell-tib-ref-end ispell-region-end t))
2065 ((and ispell-skip-sgml (string-match "<" key))
2066 (search-forward ">" ispell-region-end t))
2067 ((and ispell-skip-sgml (string-match "&" key))
2068 (search-forward ";" ispell-region-end t))
2069 ;; markings from alist
2070 (t
2071 (while alist
2072 (setq alist-key (eval (car (car alist))))
2073 (if (string-match alist-key key)
2074 (progn
2075 (setq alist (cdr (car alist)))
2076 (cond
2077 ((null alist) (setq null-skip t)) ; done! Just skip key.
2078 ((not (consp alist))
2079 ;; Search past end of spell region to find this region end.
2080 (re-search-forward (eval alist) (point-max) t))
2081 ((consp alist)
2082 (if (stringp alist)
2083 (re-search-forward alist (point-max) t)
2084 (setq null-skip t) ; error handling in functions!
2085 (if (consp (cdr alist))
2086 (apply (car alist) (cdr alist))
2087 (funcall (car alist))))))
2088 (setq alist nil))
2089 (setq alist (cdr alist))))))
2090 (if (and (= start (point)) (null null-skip))
2091 (progn
2092 (message "Matching region end for `%s' point %d not found"
2093 key (point))
2094 (beep)
2095 (sit-for 2)))))
2096
2097
2098 ;;; Grab the next line of data.
2099 ;;; Returns a string with the line data
2100 (defun ispell-get-line (start end reg-end)
2101 (let ((ispell-casechars (ispell-get-casechars))
2102 string)
2103 (cond ; LOOK AT THIS LINE AND SKIP OR PROCESS
2104 ((eolp) ; END OF LINE, just go to next line.
2105 (forward-line))
2106 ((looking-at "[---#@*+!%~^]") ; SKIP SPECIAL ISPELL CHARACTERS
2107 (forward-char 1))
2108 ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS
2109 (re-search-forward "[][()${}]" end t)) ; or MATH COMMANDS
2110 (setq string (concat "^" (buffer-substring-no-properties start end)
2111 "\n"))
2112 (goto-char end))
2113 (t (goto-char end))) ; EMPTY LINE, skip it.
2114 string))
2115
2116
2117 (defun ispell-process-line (string)
2118 ;;(declare special start end)
2119 (let (poss)
2120 ;; send string to spell process and get input.
2121 (process-send-string ispell-process string)
2122 (while (progn
2123 (accept-process-output ispell-process)
2124 ;; Last item of output contains a blank line.
2125 (not (string= "" (car ispell-filter)))))
2126 ;; parse all inputs from the stream one word at a time.
2127 ;; Place in FIFO order and remove the blank item.
2128 (setq ispell-filter (nreverse (cdr ispell-filter)))
2129 (while (and (not ispell-quit) ispell-filter)
2130 (setq poss (ispell-parse-output (car ispell-filter)))
2131 (if (and poss (listp poss)) ; spelling error occurred.
2132 ;; Whenever we have misspellings, we can change
2133 ;; the buffer. Keep boundaries as markers.
2134 ;; Markers can move with highlighting! This destroys
2135 ;; end of region markers line-end and ispell-region-end
2136 (let ((word-start
2137 (copy-marker
2138 (if (and (boundp 'enable-multibyte-characters)
2139 enable-multibyte-characters
2140 (ispell-get-coding-system))
2141 ;; skip over multibyte characters correctly
2142 (save-excursion
2143 (goto-char (+ start ispell-offset))
2144 (forward-char (car (cdr poss)))
2145 (point))
2146 (+ start ispell-offset (car (cdr poss))))))
2147 (word-len (length (car poss)))
2148 (line-end (copy-marker end))
2149 (line-start (copy-marker start))
2150 recheck-region replace)
2151 (goto-char word-start)
2152 ;; Adjust the horizontal scroll & point
2153 (ispell-horiz-scroll)
2154 (goto-char (+ word-len word-start))
2155 (ispell-horiz-scroll)
2156 (goto-char word-start)
2157 (ispell-horiz-scroll)
2158 (if (/= (+ word-len (point))
2159 (progn
2160 (search-forward (car poss) (+ word-len (point)) t)
2161 (point)))
2162 ;; This occurs due to filter pipe problems
2163 (error (concat "Ispell misalignment: word "
2164 "`%s' point %d; probably incompatible versions")
2165 (car poss) (marker-position word-start)))
2166
2167 ;; ispell-cmd-loop can go recursive & change buffer
2168 (if ispell-keep-choices-win
2169 (setq replace (ispell-command-loop
2170 (car (cdr (cdr poss)))
2171 (car (cdr (cdr (cdr poss))))
2172 (car poss) (marker-position word-start)
2173 (+ word-len (marker-position word-start))))
2174 (save-window-excursion
2175 (setq replace (ispell-command-loop
2176 (car (cdr (cdr poss)))
2177 (car (cdr (cdr (cdr poss))))
2178 (car poss) (marker-position word-start)
2179 (+ word-len (marker-position word-start))))))
2180
2181 ;; Recheck when recursive edit changes misspelled word
2182 (goto-char word-start)
2183 (if (not (string-equal (buffer-substring-no-properties
2184 (point) (+ word-len (point)))
2185 (car poss)))
2186 (progn
2187 (set-marker line-end (point))
2188 (setq ispell-filter nil
2189 recheck-region t)))
2190
2191 (cond
2192 ((and replace (listp replace))
2193 ;; REPLACEMENT WORD
2194 ;; Recheck line starting with the replacement word.
2195 (setq ispell-filter nil
2196 recheck-region t)
2197 (delete-region (point) (+ word-len (point)))
2198 (insert (car replace))
2199 ;; Only typed-in replacements need to be re-checked.
2200 (if (not (eq 'query-replace (car (cdr replace))))
2201 (backward-char (length (car replace))))
2202 (set-marker line-end (point)) ; continue checking from here.
2203 (if (car (cdr replace))
2204 (unwind-protect
2205 (save-window-excursion
2206 (delete-other-windows) ; to correctly show help.
2207 ;; Assume case-replace &
2208 ;; case-fold-search correct?
2209 (query-replace (car poss) (car replace) t))
2210 (goto-char word-start))))
2211 ((or (null replace)
2212 (equal 0 replace)) ; ACCEPT/INSERT
2213 (if (equal 0 replace) ; BUFFER-LOCAL DICT ADD
2214 (ispell-add-per-file-word-list (car poss)))
2215 ;; This avoids pointing out the word that was
2216 ;; just accepted (via 'i' or 'a') if it follows
2217 ;; on the same line.
2218 ;; Redo check following the accepted word.
2219 (if (and ispell-pdict-modified-p
2220 (listp ispell-pdict-modified-p))
2221 ;; Word accepted. Recheck line.
2222 (progn
2223 (setq ispell-pdict-modified-p ;update flag
2224 (car ispell-pdict-modified-p)
2225 ispell-filter nil
2226 recheck-region t)
2227 (set-marker line-end (marker-position word-start)))))
2228 (replace ; STRING REPLACEMENT for this word.
2229 (delete-region (point) (+ word-len (point)))
2230 (insert replace)
2231 (set-marker line-start (+ line-start
2232 (- (length replace)
2233 (length (car poss)))))))
2234 (if (not ispell-quit)
2235 (let (message-log-max)
2236 (message "Continuing spelling check using %s dictionary..."
2237 (or ispell-dictionary "default"))))
2238 (sit-for 0)
2239 (setq start (marker-position line-start)
2240 end (marker-position line-end))
2241 ;; Adjust markers when end of region lost from highlighting.
2242 (if (and (not recheck-region) (< end (+ word-start word-len)))
2243 (setq end (+ word-start word-len)))
2244 (if (= word-start ispell-region-end)
2245 (set-marker ispell-region-end (+ word-start word-len)))
2246 ;; going out of scope - unneeded
2247 (set-marker line-start nil)
2248 (set-marker word-start nil)
2249 (set-marker line-end nil)))
2250 ;; finished with misspelling!
2251 (setq ispell-filter (cdr ispell-filter)))))
2252
2253
2254 ;;;###autoload
2255 (defun ispell-comments-and-strings ()
2256 "Check comments and strings in the current buffer for spelling errors."
2257 (interactive)
2258 (goto-char (point-min))
2259 (let (state done)
2260 (while (not done)
2261 (setq done t)
2262 (setq state (parse-partial-sexp (point) (point-max)
2263 nil nil state 'syntax-table))
2264 (when (or (nth 3 state) (nth 4 state))
2265 (let ((start (point)))
2266 (setq state (parse-partial-sexp start (point-max)
2267 nil nil state 'syntax-table))
2268 (when (or (nth 3 state) (nth 4 state))
2269 (error "Unterminated string or comment."))
2270 (save-excursion
2271 (setq done (not (ispell-region start (point))))))))))
2272
2273
2274 ;;;###autoload
2275 (defun ispell-buffer ()
2276 "Check the current buffer for spelling errors interactively."
2277 (interactive)
2278 (ispell-region (point-min) (point-max)))
2279
2280
2281 ;;;###autoload
2282 (defun ispell-continue ()
2283 (interactive)
2284 "Continue a halted spelling session beginning with the current word."
2285 (if (not (marker-position ispell-region-end))
2286 (message "No session to continue. Use 'X' command when checking!")
2287 (if (not (equal (marker-buffer ispell-region-end) (current-buffer)))
2288 (message "Must continue ispell from buffer %s"
2289 (buffer-name (marker-buffer ispell-region-end)))
2290 (ispell-region
2291 ;; find beginning of current word:
2292 (car (cdr (ispell-get-word t)))
2293 (marker-position ispell-region-end)))))
2294
2295
2296 ;;; Horizontal scrolling
2297 (defun ispell-horiz-scroll ()
2298 "Places point within the horizontal visibility of its window area."
2299 (if truncate-lines ; display truncating lines?
2300 ;; See if display needs to be scrolled.
2301 (let ((column (- (current-column) (max (window-hscroll) 1))))
2302 (if (and (< column 0) (> (window-hscroll) 0))
2303 (scroll-right (max (- column) 10))
2304 (if (>= column (- (window-width) 2))
2305 (scroll-left (max (- column (window-width) -3) 10)))))))
2306
2307
2308 ;;; Interactive word completion.
2309 ;;; Forces "previous-word" processing. Do we want to make this selectable?
2310
2311 ;;;###autoload
2312 (defun ispell-complete-word (&optional interior-frag)
2313 "Look up word before or under point in dictionary (see lookup-words command)
2314 and try to complete it. If optional INTERIOR-FRAG is non-nil then the word
2315 may be a character sequence inside of a word.
2316
2317 Standard ispell choices are then available."
2318 (interactive "P")
2319 (let ((cursor-location (point))
2320 case-fold-search
2321 (word (ispell-get-word nil "\\*")) ; force "previous-word" processing.
2322 start end possibilities replacement)
2323 (setq start (car (cdr word))
2324 end (car (cdr (cdr word)))
2325 word (car word)
2326 possibilities
2327 (or (string= word "") ; Will give you every word
2328 (lookup-words (concat (and interior-frag "*") word
2329 (if (or interior-frag (null ispell-look-p))
2330 "*"))
2331 ispell-complete-word-dict)))
2332 (cond ((eq possibilities t)
2333 (message "No word to complete"))
2334 ((null possibilities)
2335 (message "No match for \"%s\"" word))
2336 (t ; There is a modification...
2337 (cond ; Try and respect case of word.
2338 ((string-match "^[^A-Z]+$" word)
2339 (setq possibilities (mapcar 'downcase possibilities)))
2340 ((string-match "^[^a-z]+$" word)
2341 (setq possibilities (mapcar 'upcase possibilities)))
2342 ((string-match "^[A-Z]" word)
2343 (setq possibilities (mapcar 'capitalize possibilities))))
2344 (save-window-excursion
2345 (setq replacement
2346 (ispell-command-loop possibilities nil word start end)))
2347 (cond
2348 ((equal 0 replacement) ; BUFFER-LOCAL ADDITION
2349 (ispell-add-per-file-word-list word))
2350 (replacement ; REPLACEMENT WORD
2351 (delete-region start end)
2352 (setq word (if (atom replacement) replacement (car replacement))
2353 cursor-location (+ (- (length word) (- end start))
2354 cursor-location))
2355 (insert word)
2356 (if (not (atom replacement)) ; recheck spelling of replacement.
2357 (progn
2358 (goto-char cursor-location)
2359 (ispell-word nil t)))))
2360 (if (get-buffer ispell-choices-buffer)
2361 (kill-buffer ispell-choices-buffer))))
2362 (ispell-pdict-save ispell-silently-savep)
2363 (goto-char cursor-location)))
2364
2365
2366 ;;;###autoload
2367 (defun ispell-complete-word-interior-frag ()
2368 "Completes word matching character sequence inside a word."
2369 (interactive)
2370 (ispell-complete-word t))
2371
2372
2373 ;;; **********************************************************************
2374 ;;; Ispell Minor Mode
2375 ;;; **********************************************************************
2376
2377 (defvar ispell-minor-mode nil
2378 "Non-nil if Ispell minor mode is enabled.")
2379 ;; Variable indicating that ispell minor mode is active.
2380 (make-variable-buffer-local 'ispell-minor-mode)
2381
2382 (or (assq 'ispell-minor-mode minor-mode-alist)
2383 (setq minor-mode-alist
2384 (cons '(ispell-minor-mode " Spell") minor-mode-alist)))
2385
2386 (defvar ispell-minor-keymap
2387 (let ((map (make-sparse-keymap)))
2388 (define-key map " " 'ispell-minor-check)
2389 (define-key map "\r" 'ispell-minor-check)
2390 map)
2391 "Keymap used for Ispell minor mode.")
2392
2393 (or (not (boundp 'minor-mode-map-alist))
2394 (assoc 'ispell-minor-mode minor-mode-map-alist)
2395 (setq minor-mode-map-alist
2396 (cons (cons 'ispell-minor-mode ispell-minor-keymap)
2397 minor-mode-map-alist)))
2398
2399 ;;;###autoload
2400 (defun ispell-minor-mode (&optional arg)
2401 "Toggle Ispell minor mode.
2402 With prefix arg, turn Ispell minor mode on iff arg is positive.
2403
2404 In Ispell minor mode, pressing SPC or RET
2405 warns you if the previous word is incorrectly spelled.
2406
2407 All the buffer-local variables and dictionaries are ignored -- to read
2408 them into the running ispell process, type \\[ispell-word] SPC."
2409 (interactive "P")
2410 (setq ispell-minor-mode
2411 (not (or (and (null arg) ispell-minor-mode)
2412 (<= (prefix-numeric-value arg) 0))))
2413 (force-mode-line-update))
2414
2415 (defun ispell-minor-check ()
2416 "Check previous word then continue with the normal binding of this key.
2417 Don't check previous word when character before point is a space or newline.
2418 Don't read buffer-local settings or word lists."
2419 (interactive "*")
2420 (let ((ispell-minor-mode nil)
2421 (ispell-check-only t)
2422 (last-char (char-after (1- (point)))))
2423 (if (or (eq last-char ?\ ) (eq last-char ?\n))
2424 nil
2425 (save-window-excursion
2426 (save-restriction
2427 (narrow-to-region (save-excursion (forward-line -1) (point)) (point))
2428 (ispell-word nil t))))
2429 (call-interactively (key-binding (this-command-keys)))))
2430
2431
2432 ;;; **********************************************************************
2433 ;;; Ispell Message
2434 ;;; **********************************************************************
2435 ;;; Original from D. Quinlan, E. Bradford, A. Albert, and M. Ernst
2436
2437
2438 (defvar ispell-message-text-end
2439 (mapconcat (function identity)
2440 '(
2441 ;; Don't spell check signatures
2442 "^-- $"
2443 ;; Matches postscript files.
2444 "^%!PS-Adobe-[123].0"
2445 ;; Matches uuencoded text
2446 "^begin [0-9][0-9][0-9] .*\nM.*\nM.*\nM"
2447 ;; Matches shell files (esp. auto-decoding)
2448 "^#! /bin/[ck]?sh"
2449 ;; Matches context difference listing
2450 "\\(\\(^cd .*\n\\)?diff -c .*\\)?\n\\*\\*\\* .*\n--- .*\n\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*"
2451 ;; Matches unidiff difference listing
2452 "\\(diff -u .*\\)?\n--- .*\n\\+\\+\\+ .*\n@@ [-+][0-9]+,[0-9]+ [-+][0-9]+,[0-9]+ @@\n"
2453 ;; Matches reporter.el bug report
2454 "^current state:\n==============\n"
2455 ;; Matches commonly used "cut" boundaries
2456 "^\\(- \\)?[-=_]+\\s ?\\(cut here\\|Environment Follows\\)")
2457 "\\|")
2458 "*End of text which will be checked in ispell-message.
2459 If it is a string, limit at first occurrence of that regular expression.
2460 Otherwise, it must be a function which is called to get the limit.")
2461
2462
2463
2464 ;;;###autoload
2465 (defun ispell-message ()
2466 "Check the spelling of a mail message or news post.
2467 Don't check spelling of message headers except the Subject field.
2468 Don't check included messages.
2469
2470 To abort spell checking of a message region and send the message anyway,
2471 use the `x' command. (Any subsequent regions will be checked.)
2472 The `X' command aborts the message send so that you can edit the buffer.
2473
2474 To spell-check whenever a message is sent, include the appropriate lines
2475 in your .emacs file:
2476 (add-hook 'message-send-hook 'ispell-message) ;; GNUS 5
2477 (add-hook 'news-inews-hook 'ispell-message) ;; GNUS 4
2478 (add-hook 'mail-send-hook 'ispell-message)
2479 (add-hook 'mh-before-send-letter-hook 'ispell-message)
2480
2481 You can bind this to the key C-c i in GNUS or mail by adding to
2482 `news-reply-mode-hook' or `mail-mode-hook' the following lambda expression:
2483 (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))"
2484 (interactive)
2485 (save-excursion
2486 (goto-char (point-min))
2487 (let* (
2488 ;; Nil when message came from outside (eg calling emacs as editor)
2489 ;; Non-nil marker of end of headers.
2490 (internal-messagep
2491 (re-search-forward
2492 (concat "^" (regexp-quote mail-header-separator) "$") nil t))
2493 (end-of-headers ; Start of body.
2494 (copy-marker
2495 (or internal-messagep
2496 (re-search-forward "^$" nil t)
2497 (point-min))))
2498 (limit (copy-marker ; End of region we will spell check.
2499 (cond
2500 ((not ispell-message-text-end) (point-max))
2501 ((char-or-string-p ispell-message-text-end)
2502 (if (re-search-forward ispell-message-text-end nil t)
2503 (match-beginning 0)
2504 (point-max)))
2505 (t (min (point-max) (funcall ispell-message-text-end))))))
2506 (default-prefix ; Vanilla cite prefix (just used for cite-regexp)
2507 (if (and (boundp 'mail-yank-prefix) mail-yank-prefix)
2508 (ispell-non-empty-string mail-yank-prefix)
2509 " \\|\t"))
2510 (cite-regexp ;Prefix of quoted text
2511 (cond
2512 ((featurep 'supercite) ; sc 3.0
2513 (concat "\\(" (sc-cite-regexp) "\\)" "\\|"
2514 (ispell-non-empty-string sc-reference-tag-string)))
2515 ((featurep 'sc) ; sc 2.3
2516 (concat "\\(" sc-cite-regexp "\\)" "\\|"
2517 (ispell-non-empty-string sc-reference-tag-string)))
2518 ((or (equal major-mode 'news-reply-mode) ;GNUS 4 & below
2519 (equal major-mode 'message-mode)) ;GNUS 5
2520 (concat "In article <" "\\|"
2521 "[^,;&+=]+ <[^,;&+=]+> writes:" "\\|"
2522 default-prefix))
2523 ((equal major-mode 'mh-letter-mode) ; mh mail message
2524 (ispell-non-empty-string mh-ins-buf-prefix))
2525 ((not internal-messagep) ; Assume nn sent us this message.
2526 (concat "In [a-zA-Z.]+ you write:" "\\|"
2527 "In <[^,;&+=]+> [^,;&+=]+ writes:" "\\|"
2528 " *> *"))
2529 ((boundp 'vm-included-text-prefix) ; VM mail message
2530 (concat "[^,;&+=]+ writes:" "\\|"
2531 (ispell-non-empty-string vm-included-text-prefix)))
2532 (t default-prefix)))
2533 (ispell-skip-region-alist
2534 (cons (list (concat "^\\(" cite-regexp "\\)")
2535 (function forward-line))
2536 ispell-skip-region-alist))
2537 (old-case-fold-search case-fold-search)
2538 (case-fold-search t)
2539 (dictionary-alist ispell-message-dictionary-alist)
2540 (ispell-checking-message t))
2541
2542 ;; Select dictionary for message
2543 (or (local-variable-p 'ispell-local-dictionary (current-buffer))
2544 (while dictionary-alist
2545 (goto-char (point-min))
2546 (if (re-search-forward (car (car dictionary-alist))
2547 end-of-headers t)
2548 (setq ispell-local-dictionary (cdr (car dictionary-alist))
2549 dictionary-alist nil)
2550 (setq dictionary-alist (cdr dictionary-alist)))))
2551
2552 (unwind-protect
2553 (progn
2554 ;; Spell check any original Subject:
2555 (goto-char (point-min))
2556 (if (re-search-forward "^Subject: *" end-of-headers t)
2557 (progn
2558 (goto-char (match-end 0))
2559 (if (and (not (looking-at ".*Re\\>"))
2560 (not (looking-at "\\[")))
2561 (let ((case-fold-search old-case-fold-search))
2562 (ispell-region (point)
2563 (progn ;Tab-initiated continuation lns.
2564 (end-of-line)
2565 (while (looking-at "\n[ \t]")
2566 (end-of-line 2))
2567 (point)))))))
2568 (goto-char end-of-headers)
2569 (forward-line 1)
2570 (ispell-region (point) limit))
2571 (set-marker end-of-headers nil)
2572 (set-marker limit nil)))))
2573
2574
2575 (defun ispell-non-empty-string (string)
2576 (if (or (not string) (string-equal string ""))
2577 "\\'\\`" ; An unmatchable string if string is null.
2578 (regexp-quote string)))
2579
2580
2581 ;;; **********************************************************************
2582 ;;; Buffer Local Functions
2583 ;;; **********************************************************************
2584
2585
2586 (defun ispell-accept-buffer-local-defs ()
2587 "Load all buffer-local information, restarting Ispell when necessary."
2588 (ispell-buffer-local-dict) ; May kill ispell-process.
2589 (ispell-buffer-local-words) ; Will initialize ispell-process.
2590 (ispell-buffer-local-parsing))
2591
2592
2593 (defun ispell-buffer-local-parsing ()
2594 "Place Ispell into parsing mode for this buffer.
2595 Overrides the default parsing mode.
2596 Includes Latex/Nroff modes and extended character mode."
2597 ;; (ispell-init-process) must already be called.
2598 (process-send-string ispell-process "!\n") ; Put process in terse mode.
2599 ;; We assume all major modes with "tex-mode" in them should use latex parsing
2600 (if (or (and (eq ispell-parser 'use-mode-name)
2601 (string-match "[Tt][Ee][Xx]-mode" (symbol-name major-mode)))
2602 (eq ispell-parser 'tex))
2603 (progn
2604 (process-send-string ispell-process "+\n") ; set ispell mode to tex
2605 (if (not (eq ispell-parser 'tex))
2606 (set (make-local-variable 'ispell-parser) 'tex)))
2607 (process-send-string ispell-process "-\n")) ; set mode to normal (nroff)
2608 ;; If needed, test for SGML & HTML modes and set a buffer local nil/t value.
2609 (if (and ispell-skip-sgml (not (eq ispell-skip-sgml t)))
2610 (set (make-local-variable 'ispell-skip-sgml)
2611 (not (null (let ((case-fold-search t))
2612 (string-match "sgml\\|html"
2613 (symbol-name major-mode)))))))
2614 ;; Set default extended character mode for given buffer, if any.
2615 (let ((extended-char-mode (ispell-get-extended-character-mode)))
2616 (if extended-char-mode
2617 (process-send-string ispell-process (concat extended-char-mode "\n"))))
2618 ;; Set buffer-local parsing mode and extended character mode, if specified.
2619 (save-excursion
2620 (goto-char (point-max))
2621 ;; Uses last occurrence of ispell-parsing-keyword
2622 (if (search-backward ispell-parsing-keyword nil t)
2623 (let ((end (save-excursion (end-of-line) (point)))
2624 (case-fold-search t)
2625 string)
2626 (search-forward ispell-parsing-keyword)
2627 (while (re-search-forward " *\\([^ \"]+\\)" end t)
2628 ;; space separated definitions.
2629 (setq string (buffer-substring-no-properties (match-beginning 1)
2630 (match-end 1)))
2631 (cond ((string-match "latex-mode" string)
2632 (process-send-string ispell-process "+\n~tex\n"))
2633 ((string-match "nroff-mode" string)
2634 (process-send-string ispell-process "-\n~nroff"))
2635 ((string-match "~" string) ; Set extended character mode.
2636 (process-send-string ispell-process (concat string "\n")))
2637 (t (message "Invalid Ispell Parsing argument!")
2638 (sit-for 2))))))))
2639
2640
2641 ;;; Can kill the current ispell process
2642
2643 (defun ispell-buffer-local-dict ()
2644 "Initializes local dictionary and local personal dictionary.
2645 When a dictionary is defined in the buffer (see variable
2646 `ispell-dictionary-keyword'), it will override the local setting
2647 from \\[ispell-change-dictionary].
2648 Both should not be used to define a buffer-local dictionary."
2649 (save-excursion
2650 (goto-char (point-min))
2651 (let (end)
2652 ;; Override the local variable definition.
2653 ;; Uses last occurrence of ispell-dictionary-keyword.
2654 (goto-char (point-max))
2655 (if (search-backward ispell-dictionary-keyword nil t)
2656 (progn
2657 (search-forward ispell-dictionary-keyword)
2658 (setq end (save-excursion (end-of-line) (point)))
2659 (if (re-search-forward " *\\([^ \"]+\\)" end t)
2660 (setq ispell-local-dictionary
2661 (buffer-substring-no-properties (match-beginning 1)
2662 (match-end 1))))))
2663 (goto-char (point-max))
2664 (if (search-backward ispell-pdict-keyword nil t)
2665 (progn
2666 (search-forward ispell-pdict-keyword)
2667 (setq end (save-excursion (end-of-line) (point)))
2668 (if (re-search-forward " *\\([^ \"]+\\)" end t)
2669 (setq ispell-local-pdict
2670 (buffer-substring-no-properties (match-beginning 1)
2671 (match-end 1))))))))
2672 ;; Reload if new personal dictionary defined.
2673 (if (and ispell-local-pdict
2674 (not (equal ispell-local-pdict ispell-personal-dictionary)))
2675 (progn
2676 (ispell-kill-ispell t)
2677 (setq ispell-personal-dictionary ispell-local-pdict)))
2678 ;; Reload if new dictionary defined.
2679 (if (and ispell-local-dictionary
2680 (not (equal ispell-local-dictionary ispell-dictionary)))
2681 (ispell-change-dictionary ispell-local-dictionary)))
2682
2683
2684 (defun ispell-buffer-local-words ()
2685 "Loads the buffer-local dictionary in the current buffer."
2686 (if (and ispell-buffer-local-name
2687 (not (equal ispell-buffer-local-name (buffer-name))))
2688 (progn
2689 (ispell-kill-ispell t)
2690 (setq ispell-buffer-local-name nil)))
2691 (ispell-init-process)
2692 (save-excursion
2693 (goto-char (point-min))
2694 (while (search-forward ispell-words-keyword nil t)
2695 (or ispell-buffer-local-name
2696 (setq ispell-buffer-local-name (buffer-name)))
2697 (let ((end (save-excursion (end-of-line) (point)))
2698 (ispell-casechars (ispell-get-casechars))
2699 string)
2700 ;; buffer-local words separated by a space, and can contain
2701 ;; any character other than a space. Not rigorous enough.
2702 (while (re-search-forward " *\\([^ ]+\\)" end t)
2703 (setq string (buffer-substring-no-properties (match-beginning 1)
2704 (match-end 1)))
2705 ;; This can fail when string contains a word with illegal chars.
2706 ;; Error handling needs to be added between ispell and emacs.
2707 (if (and (< 1 (length string))
2708 (equal 0 (string-match ispell-casechars string)))
2709 (process-send-string ispell-process
2710 (concat "@" string "\n"))))))))
2711
2712
2713 ;;; returns optionally adjusted region-end-point.
2714
2715 (defun ispell-add-per-file-word-list (word)
2716 "Adds new word to the per-file word list."
2717 (or ispell-buffer-local-name
2718 (setq ispell-buffer-local-name (buffer-name)))
2719 (save-excursion
2720 (goto-char (point-min))
2721 (let (case-fold-search line-okay search done string)
2722 (while (not done)
2723 (setq search (search-forward ispell-words-keyword nil 'move)
2724 line-okay (< (+ (length word) 1 ; 1 for space after word..
2725 (progn (end-of-line) (current-column)))
2726 80))
2727 (if (or (and search line-okay)
2728 (null search))
2729 (progn
2730 (setq done t)
2731 (if (null search)
2732 (progn
2733 (open-line 1)
2734 (setq string (concat comment-start " "
2735 ispell-words-keyword))
2736 (insert string)
2737 (if (and comment-end (not (equal "" comment-end)))
2738 (save-excursion
2739 (open-line 1)
2740 (forward-line 1)
2741 (insert comment-end)))))
2742 (insert (concat " " word))))))))
2743
2744
2745 (defconst ispell-version "ispell.el 3.0 -- Tue Apr 28 14:40:01 PDT 1998")
2746
2747 (provide 'ispell)
2748
2749 \f
2750 ;;; LOCAL VARIABLES AND BUFFER-LOCAL VALUE EXAMPLES.
2751
2752 ;;; Local Variable options:
2753 ;;; mode: name(-mode)
2754 ;;; eval: expression
2755 ;;; local-variable: value
2756
2757 ;;; The following sets the buffer local dictionary to 'american' English
2758 ;;; and spell checks only comments.
2759
2760 ;;; Local Variables:
2761 ;;; mode: emacs-lisp
2762 ;;; comment-column: 40
2763 ;;; ispell-check-comments: exclusive
2764 ;;; Local IspellDict: "american"
2765 ;;; End:
2766
2767
2768 ;;; MORE EXAMPLES OF ISPELL BUFFER-LOCAL VALUES
2769
2770 ;;; The following places this file in nroff parsing and extended char modes.
2771 ;;; Local IspellParsing: nroff-mode ~nroff
2772 ;;; Change IspellPersDict to IspellPersDict: to enable the following line.
2773 ;;; Local IspellPersDict ~/.ispell_lisp
2774 ;;; The following were automatically generated by ispell using the 'A' command:
2775 ; LocalWords: Moellmann copyleft Dansk russian KOI charset minipage hspace mh
2776 ; LocalWords: unsplitable includeonly nocite epsfig displaymath eqnarray init
2777 ; LocalWords: settable autoload inews frag pdict alist Wildcards iconify arg
2778 ; LocalWords: tex alists minibuffer Autoloading setq changelog kss stevens reg
2779 ; LocalWords: Castellano framepop sgml modeline Wedler Dirk Froembgen fn Gerd
2780 ; LocalWords: pgp NZST Vignaux autoloaded loaddefs aff Francais Nederlands SPC
2781 ; LocalWords: popup nonmenu regexp herr num pers dict unhighlight ccept uit NB
2782 ; LocalWords: buf grep sync prev inc hilight olddot AIX ersion msg read's op
2783 ; LocalWords: bufs pt multibyte cmd Quinlan uuencoded esp unidiff eg sc
2784 ; LocalWords: VM lns HTML eval american IspellPersDict
2785
2786 ;;; ispell.el ends here
2787