comparison lisp/textmodes/=ispell4.el @ 3623:739ba36097c9

Doc fixes. (ispell-command, ispell-command-options): New defvars. (start-ispell): Use them.
author Richard M. Stallman <rms@gnu.org>
date Thu, 10 Jun 1993 20:35:05 +0000
parents 507f64624555
children c9938769a6b7
comparison
equal deleted inserted replaced
3622:62c03085c0d9 3623:739ba36097c9
26 ;; spelling checker. 26 ;; spelling checker.
27 27
28 ;;; Code: 28 ;;; Code:
29 29
30 (defvar ispell-have-new-look t 30 (defvar ispell-have-new-look t
31 "T if default 'look' program has the -r flag.") 31 "Non-nil means use the `-r' option when running `look'.")
32 32
33 (defvar ispell-enable-tex-parser nil 33 (defvar ispell-enable-tex-parser nil
34 "T to enable experimental tex parser in ispell for tex buffers.") 34 "Non-nil enables experimental TeX parser in Ispell for TeX-mode buffers.")
35 35
36 (defvar ispell-process nil "The process running ISPELL") 36 (defvar ispell-process nil "The process running Ispell")
37 (defvar ispell-next-message nil 37 (defvar ispell-next-message nil
38 "An integer telling where in the *ispell* buffer where 38 "An integer: where in `*ispell*' buffer to find next message from Ispell.")
39 to look for the next message from the ISPELL program.") 39
40 (defvar ispell-command "ispell"
41 "Command for running Ispell.")
42 (defvar ispell-command-options nil
43 "*String (or list of strings) to pass to Ispell as command arguments.
44 You can use this to specify the name of your private dictionary.
45 The -S option is always passed to Ispell as the last parameter,
46 and need not be mentioned here.")
40 47
41 ;Each marker in this list points to the start of a word that 48 ;Each marker in this list points to the start of a word that
42 ;ispell thought was bad last time it did the :file command. 49 ;ispell thought was bad last time it did the :file command.
43 ;Notice that if the user accepts or inserts a word into his 50 ;Notice that if the user accepts or inserts a word into his
44 ;private dictionary, then some "good" words will be on the list. 51 ;private dictionary, then some "good" words will be on the list.
45 ;We would like to deal with this by looking up the words again just before 52 ;We would like to deal with this by looking up the words again just before
46 ;presenting them to the user, but that is too slow on machines 53 ;presenting them to the user, but that is too slow on machines
47 ;without the select system call. Therefore, see the variable 54 ;without the select system call. Therefore, see the variable
48 ;ispell-recently-accepted. 55 ;ispell-recently-accepted.
49 (defvar ispell-bad-words nil 56 (defvar ispell-bad-words nil
50 "A list of markers corresponding to the output of the ISPELL :file command.") 57 "A list of markers reflecting the output of the Ispell `:file' command.")
51 58
52 ;list of words that the user has accepted, but that might still 59 ;list of words that the user has accepted, but that might still
53 ;be on the bad-words list 60 ;be on the bad-words list
54 (defvar ispell-recently-accepted nil) 61 (defvar ispell-recently-accepted nil)
55 62
66 (set-marker (car ispell-bad-words) nil)) 73 (set-marker (car ispell-bad-words) nil))
67 (setq ispell-bad-words (cdr ispell-bad-words))) 74 (setq ispell-bad-words (cdr ispell-bad-words)))
68 (setq ispell-recently-accepted nil)) 75 (setq ispell-recently-accepted nil))
69 76
70 (defun kill-ispell () 77 (defun kill-ispell ()
71 "Kill the ispell process. 78 "Kill the Ispell process.
72 Any changes in your private dictionary 79 Any changes in your private dictionary
73 that have not already been dumped will be lost." 80 that have not already been dumped will be lost."
74 (interactive) 81 (interactive)
75 (if ispell-process 82 (if ispell-process
76 (delete-process ispell-process)) 83 (delete-process ispell-process))
80 (put 'ispell-startup-error 'error-conditions 87 (put 'ispell-startup-error 'error-conditions
81 '(ispell-startup-error error)) 88 '(ispell-startup-error error))
82 (put 'ispell-startup-error 'error-message 89 (put 'ispell-startup-error 'error-message
83 "Problem starting ispell - see buffer *ispell*") 90 "Problem starting ispell - see buffer *ispell*")
84 91
92 ;; Start an ispell subprocess; check the version; and display the greeting.
93
85 (defun start-ispell () 94 (defun start-ispell ()
86 "Start an ispell subprocess; check the version; and display the greeting."
87 (message "Starting ispell ...") 95 (message "Starting ispell ...")
88 (let ((buf (get-buffer "*ispell*"))) 96 (let ((buf (get-buffer "*ispell*")))
89 (if buf 97 (if buf
90 (kill-buffer buf))) 98 (kill-buffer buf)))
91 (condition-case err 99 (condition-case err
92 (setq ispell-process (start-process "ispell" "*ispell*" "ispell" "-S")) 100 (setq ispell-process
101 (apply 'start-process "ispell" "*ispell*" ispell-command
102 (append (if (listp ispell-command-options)
103 ispell-command-options
104 (list ispell-command-options))
105 '("-S"))))
93 (file-error (signal 'ispell-startup-error nil))) 106 (file-error (signal 'ispell-startup-error nil)))
94 (process-kill-without-query ispell-process) 107 (process-kill-without-query ispell-process)
95 (buffer-disable-undo (process-buffer ispell-process)) 108 (buffer-disable-undo (process-buffer ispell-process))
96 (accept-process-output ispell-process) 109 (accept-process-output ispell-process)
97 (let (last-char) 110 (let (last-char)
110 (if (not (= (car greeting) 1)) 123 (if (not (= (car greeting) 1))
111 (error "Bad ispell version: wanted 1, got %d" (car greeting))) 124 (error "Bad ispell version: wanted 1, got %d" (car greeting)))
112 (message (car (cdr greeting)))) 125 (message (car (cdr greeting))))
113 (delete-region (point-min) last-char)))) 126 (delete-region (point-min) last-char))))
114 127
115 ;leaves buffer set to *ispell*, point at '=' 128 ;; Make sure ispell is ready for a command.
129 ;; Leaves buffer set to *ispell*, point at '='.
130
116 (defun ispell-sync (intr) 131 (defun ispell-sync (intr)
117 "Make sure ispell is ready for a command."
118 (if (or (null ispell-process) 132 (if (or (null ispell-process)
119 (not (eq (process-status ispell-process) 'run))) 133 (not (eq (process-status ispell-process) 'run)))
120 (start-ispell)) 134 (start-ispell))
121 (if intr 135 (if intr
122 (interrupt-process ispell-process)) 136 (interrupt-process ispell-process))
127 (while (not (eq (char-after last-char) ?=)) 141 (while (not (eq (char-after last-char) ?=))
128 (accept-process-output ispell-process) 142 (accept-process-output ispell-process)
129 (setq last-char (- (point-max) 1))) 143 (setq last-char (- (point-max) 1)))
130 (goto-char last-char))) 144 (goto-char last-char)))
131 145
146 ;; Send a command to ispell. Choices are:
147 ;;
148 ;; WORD Check spelling of WORD. Result is
149 ;;
150 ;; nil not found
151 ;; t spelled ok
152 ;; list of strings near misses
153 ;;
154 ;; :file FILENAME scan the named file, and print the file offsets of
155 ;; any misspelled words
156 ;;
157 ;; :insert WORD put word in private dictionary
158 ;;
159 ;; :accept WORD don't complain about word any more this session
160 ;;
161 ;; :dump write out the current private dictionary, if necessary.
162 ;;
163 ;; :reload reread `~/ispell.words'
164 ;;
165 ;; :tex
166 ;; :troff
167 ;; :generic set type of parser to use when scanning whole files
168
132 (defun ispell-cmd (&rest strings) 169 (defun ispell-cmd (&rest strings)
133 "Send a command to ispell. Choices are:
134
135 WORD Check spelling of WORD. Result is
136
137 nil not found
138 t spelled ok
139 list of strings near misses
140
141 :file FILENAME scan the named file, and print the file offsets of
142 any misspelled words
143
144 :insert WORD put word in private dictionary
145
146 :accept WORD don't complain about word any more this session
147
148 :dump write out the current private dictionary, if necessary.
149
150 :reload reread `~/ispell.words'
151
152 :tex
153 :troff
154 :generic set type of parser to use when scanning whole files
155 "
156 (save-excursion 170 (save-excursion
157 (ispell-sync t) 171 (ispell-sync t)
158 (set-buffer (process-buffer ispell-process)) 172 (set-buffer (process-buffer ispell-process))
159 (bury-buffer (current-buffer)) 173 (bury-buffer (current-buffer))
160 (erase-buffer) 174 (erase-buffer)
180 (defun ispell-accept (word) 194 (defun ispell-accept (word)
181 (ispell-cmd ":accept " word) 195 (ispell-cmd ":accept " word)
182 (if ispell-bad-words 196 (if ispell-bad-words
183 (setq ispell-recently-accepted (cons word ispell-recently-accepted)))) 197 (setq ispell-recently-accepted (cons word ispell-recently-accepted))))
184 198
199 ;; Return the next message sent by the Ispell subprocess.
185 200
186 (defun ispell-next-message () 201 (defun ispell-next-message ()
187 "Return the next message sent by the ispell subprocess."
188 (save-excursion 202 (save-excursion
189 (set-buffer (process-buffer ispell-process)) 203 (set-buffer (process-buffer ispell-process))
190 (bury-buffer (current-buffer)) 204 (bury-buffer (current-buffer))
191 (save-restriction 205 (save-restriction
192 (goto-char ispell-next-message) 206 (goto-char ispell-next-message)
279 293
280 ;;;###autoload 294 ;;;###autoload
281 (defalias 'ispell-buffer 'ispell) 295 (defalias 'ispell-buffer 'ispell)
282 296
283 (defun ispell-next () 297 (defun ispell-next ()
284 "Resume command loop for most recent ispell command." 298 "Resume command loop for most recent Ispell command."
285 (interactive) 299 (interactive)
286 (setq ispell-window-configuration nil) 300 (setq ispell-window-configuration nil)
287 (unwind-protect 301 (unwind-protect
288 (catch 'quit 302 (catch 'quit
289 ;; There used to be a save-excursion here, 303 ;; There used to be a save-excursion here,
315 (ispell-dump)) 329 (ispell-dump))
316 330
317 ;;;###autoload 331 ;;;###autoload
318 (defun ispell-word (&optional resume) 332 (defun ispell-word (&optional resume)
319 "Check the spelling of the word under the cursor. 333 "Check the spelling of the word under the cursor.
320 See `ispell' for more information. 334 See the command `ispell' for more information.
321 With a prefix argument, resume handling of the previous Ispell command." 335 With a prefix argument, resume handling of the previous Ispell command."
322 (interactive "P") 336 (interactive "P")
323 (if resume 337 (if resume
324 (ispell-next) 338 (ispell-next)
325 (condition-case err 339 (condition-case err
558 (goto-char start) 572 (goto-char start)
559 (insert new) 573 (insert new)
560 (delete-region (point) end)) 574 (delete-region (point) end))
561 575
562 (defun reload-ispell () 576 (defun reload-ispell ()
563 "Tell ispell to re-read your private dictionary." 577 "Tell Ispell to re-read your private dictionary."
564 (interactive) 578 (interactive)
565 (ispell-cmd ":reload")) 579 (ispell-cmd ":reload"))
566 580
567 (defun batch-make-ispell () 581 (defun batch-make-ispell ()
568 (byte-compile-file "ispell.el") 582 (byte-compile-file "ispell.el")