Mercurial > emacs
annotate lisp/textmodes/=ispell4.el @ 25383:57e815ace9e2
Mode provide to end.
(timezone-parse-date): Simplify somewhat. Assume 2-digit years <70 are
2000+.
(timezone-parse-time): Simplify somewhat.
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 24 Aug 1999 16:43:44 +0000 |
parents | 0308bce52ae4 |
children |
rev | line source |
---|---|
14169 | 1 ;;; ispell4.el --- this is the GNU EMACS interface to GNU ISPELL version 4. |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
317
diff
changeset
|
2 |
14169 | 3 ;; Copyright (C) 1990, 1991, 1993 Free Software Foundation, Inc. |
792
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
4 |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
5 ;; Keywords: wp |
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
6 |
14169 | 7 ;; This file is part of GNU Emacs. |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
55 | 23 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
24 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
25 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
26 ;; This package provides a graceful interface to ispell, the GNU |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
27 ;; spelling checker. |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
28 |
792
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
29 ;;; Code: |
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
30 |
21088 | 31 (defgroup ispell4 nil |
32 "Interface to GNU ISPELL version 4." | |
33 :prefix "ispell-" | |
34 :group 'applications) | |
35 | |
36 (defcustom ispell-have-new-look t | |
37 "Non-nil means use the `-r' option when running `look'." | |
38 :type 'boolean | |
39 :group 'ispell4) | |
55 | 40 |
41 (defvar ispell-enable-tex-parser nil | |
3623 | 42 "Non-nil enables experimental TeX parser in Ispell for TeX-mode buffers.") |
43 | |
44 (defvar ispell-process nil "The process running Ispell") | |
45 (defvar ispell-next-message nil | |
46 "An integer: where in `*ispell*' buffer to find next message from Ispell.") | |
55 | 47 |
21088 | 48 (defcustom ispell-command "ispell" |
49 "Command for running Ispell." | |
50 :type 'string | |
51 :group 'ispell4) | |
52 | |
53 (defcustom ispell-command-options nil | |
3623 | 54 "*String (or list of strings) to pass to Ispell as command arguments. |
5293
346d921eaf3b
Don't imply private dictionary is always ispell.words.
Richard M. Stallman <rms@gnu.org>
parents:
4933
diff
changeset
|
55 You can specify your private dictionary via the -p <filename> option. |
3623 | 56 The -S option is always passed to Ispell as the last parameter, |
21088 | 57 and need not be mentioned here." |
58 :type '(repeat string) | |
59 :group 'ispell4) | |
55 | 60 |
21088 | 61 (defcustom ispell-look-command "look" |
62 "*Command for running look." | |
63 :type 'string | |
64 :group 'ispell4) | |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
65 |
55 | 66 ;Each marker in this list points to the start of a word that |
67 ;ispell thought was bad last time it did the :file command. | |
68 ;Notice that if the user accepts or inserts a word into his | |
69 ;private dictionary, then some "good" words will be on the list. | |
70 ;We would like to deal with this by looking up the words again just before | |
71 ;presenting them to the user, but that is too slow on machines | |
72 ;without the select system call. Therefore, see the variable | |
73 ;ispell-recently-accepted. | |
74 (defvar ispell-bad-words nil | |
3623 | 75 "A list of markers reflecting the output of the Ispell `:file' command.") |
55 | 76 |
77 ;list of words that the user has accepted, but that might still | |
78 ;be on the bad-words list | |
79 (defvar ispell-recently-accepted nil) | |
80 | |
2837
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
81 ;; Non-nil means we have started showing an alternatives window. |
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
82 ;; This is the window config from before then. |
4105
230eede21566
(ispell-menu-map): Add missing quote in defalias.
Richard M. Stallman <rms@gnu.org>
parents:
4062
diff
changeset
|
83 (defvar ispell-window-configuration nil) |
2837
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
84 |
55 | 85 ;t when :dump command needed |
86 (defvar ispell-dump-needed nil) | |
87 | |
88 (defun ispell-flush-bad-words () | |
89 (while ispell-bad-words | |
90 (if (markerp (car ispell-bad-words)) | |
91 (set-marker (car ispell-bad-words) nil)) | |
92 (setq ispell-bad-words (cdr ispell-bad-words))) | |
93 (setq ispell-recently-accepted nil)) | |
94 | |
95 (defun kill-ispell () | |
3623 | 96 "Kill the Ispell process. |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3112
diff
changeset
|
97 Any changes in your private dictionary |
55 | 98 that have not already been dumped will be lost." |
99 (interactive) | |
100 (if ispell-process | |
101 (delete-process ispell-process)) | |
102 (setq ispell-process nil) | |
103 (ispell-flush-bad-words)) | |
104 | |
105 (put 'ispell-startup-error 'error-conditions | |
106 '(ispell-startup-error error)) | |
107 (put 'ispell-startup-error 'error-message | |
108 "Problem starting ispell - see buffer *ispell*") | |
109 | |
3623 | 110 ;; Start an ispell subprocess; check the version; and display the greeting. |
111 | |
55 | 112 (defun start-ispell () |
113 (message "Starting ispell ...") | |
114 (let ((buf (get-buffer "*ispell*"))) | |
115 (if buf | |
116 (kill-buffer buf))) | |
117 (condition-case err | |
3623 | 118 (setq ispell-process |
119 (apply 'start-process "ispell" "*ispell*" ispell-command | |
120 (append (if (listp ispell-command-options) | |
121 ispell-command-options | |
122 (list ispell-command-options)) | |
123 '("-S")))) | |
55 | 124 (file-error (signal 'ispell-startup-error nil))) |
125 (process-kill-without-query ispell-process) | |
126 (buffer-disable-undo (process-buffer ispell-process)) | |
127 (accept-process-output ispell-process) | |
128 (let (last-char) | |
129 (save-excursion | |
130 (set-buffer (process-buffer ispell-process)) | |
131 (bury-buffer (current-buffer)) | |
132 (setq last-char (- (point-max) 1)) | |
133 (while (not (eq (char-after last-char) ?=)) | |
134 (cond ((not (eq (process-status ispell-process) 'run)) | |
135 (kill-ispell) | |
136 (signal 'ispell-startup-error nil))) | |
137 (accept-process-output ispell-process) | |
138 (setq last-char (- (point-max) 1))) | |
139 (goto-char (point-min)) | |
140 (let ((greeting (read (current-buffer)))) | |
141 (if (not (= (car greeting) 1)) | |
142 (error "Bad ispell version: wanted 1, got %d" (car greeting))) | |
14347
f5f5fa38faa7
(start-ispell, ispell-next): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
143 (message "%s" (car (cdr greeting)))) |
55 | 144 (delete-region (point-min) last-char)))) |
145 | |
3623 | 146 ;; Make sure ispell is ready for a command. |
147 ;; Leaves buffer set to *ispell*, point at '='. | |
148 | |
55 | 149 (defun ispell-sync (intr) |
150 (if (or (null ispell-process) | |
151 (not (eq (process-status ispell-process) 'run))) | |
152 (start-ispell)) | |
153 (if intr | |
154 (interrupt-process ispell-process)) | |
155 (let (last-char) | |
156 (set-buffer (process-buffer ispell-process)) | |
157 (bury-buffer (current-buffer)) | |
158 (setq last-char (- (point-max) 1)) | |
159 (while (not (eq (char-after last-char) ?=)) | |
160 (accept-process-output ispell-process) | |
161 (setq last-char (- (point-max) 1))) | |
162 (goto-char last-char))) | |
163 | |
3623 | 164 ;; Send a command to ispell. Choices are: |
165 ;; | |
166 ;; WORD Check spelling of WORD. Result is | |
167 ;; | |
168 ;; nil not found | |
169 ;; t spelled ok | |
170 ;; list of strings near misses | |
171 ;; | |
172 ;; :file FILENAME scan the named file, and print the file offsets of | |
173 ;; any misspelled words | |
174 ;; | |
175 ;; :insert WORD put word in private dictionary | |
176 ;; | |
177 ;; :accept WORD don't complain about word any more this session | |
178 ;; | |
179 ;; :dump write out the current private dictionary, if necessary. | |
180 ;; | |
5293
346d921eaf3b
Don't imply private dictionary is always ispell.words.
Richard M. Stallman <rms@gnu.org>
parents:
4933
diff
changeset
|
181 ;; :reload reread private dictionary (default: `~/ispell.words') |
3623 | 182 ;; |
183 ;; :tex | |
184 ;; :troff | |
185 ;; :generic set type of parser to use when scanning whole files | |
55 | 186 |
3623 | 187 (defun ispell-cmd (&rest strings) |
55 | 188 (save-excursion |
189 (ispell-sync t) | |
190 (set-buffer (process-buffer ispell-process)) | |
191 (bury-buffer (current-buffer)) | |
192 (erase-buffer) | |
193 (setq ispell-next-message (point-min)) | |
194 (while strings | |
195 (process-send-string ispell-process (car strings)) | |
196 (setq strings (cdr strings))) | |
197 (process-send-string ispell-process "\n") | |
198 (accept-process-output ispell-process) | |
199 (ispell-sync nil))) | |
200 | |
201 (defun ispell-dump () | |
202 (cond (ispell-dump-needed | |
203 (setq ispell-dump-needed nil) | |
204 (ispell-cmd ":dump")))) | |
205 | |
206 (defun ispell-insert (word) | |
207 (ispell-cmd ":insert " word) | |
208 (if ispell-bad-words | |
209 (setq ispell-recently-accepted (cons word ispell-recently-accepted))) | |
210 (setq ispell-dump-needed t)) | |
211 | |
212 (defun ispell-accept (word) | |
213 (ispell-cmd ":accept " word) | |
214 (if ispell-bad-words | |
215 (setq ispell-recently-accepted (cons word ispell-recently-accepted)))) | |
216 | |
3623 | 217 ;; Return the next message sent by the Ispell subprocess. |
55 | 218 |
219 (defun ispell-next-message () | |
220 (save-excursion | |
221 (set-buffer (process-buffer ispell-process)) | |
222 (bury-buffer (current-buffer)) | |
223 (save-restriction | |
224 (goto-char ispell-next-message) | |
225 (narrow-to-region (point) | |
226 (progn (forward-sexp 1) (point))) | |
227 (setq ispell-next-message (point)) | |
228 (goto-char (point-min)) | |
229 (read (current-buffer))))) | |
230 | |
231 (defun ispell-tex-buffer-p () | |
8311
ace71f0fc661
(ispell-tex-buffer-p): Write names in lower case. Add slitex-mode.
Richard M. Stallman <rms@gnu.org>
parents:
8221
diff
changeset
|
232 (memq major-mode '(plain-tex-mode latex-mode slitex-mode))) |
55 | 233 |
4062
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
234 (defvar ispell-menu-map (make-sparse-keymap "Spell")) |
4105
230eede21566
(ispell-menu-map): Add missing quote in defalias.
Richard M. Stallman <rms@gnu.org>
parents:
4062
diff
changeset
|
235 (defalias 'ispell-menu-map ispell-menu-map) |
4062
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
236 |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
237 (define-key ispell-menu-map [ispell-complete-word-interior-frag] |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
238 '("Complete Interior Fragment" . ispell-complete-word-interior-frag)) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
239 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
240 (define-key ispell-menu-map [ispell-complete-word] |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
241 '("Complete Word" . ispell-complete-word)) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
242 |
4062
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
243 (define-key ispell-menu-map [reload-ispell] |
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
244 '("Reload Dictionary" . reload-ispell)) |
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
245 |
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
246 (define-key ispell-menu-map [ispell-next] |
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
247 '("Continue Check" . ispell-next)) |
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
248 |
4749
fe223c0faf71
(ispell-message): New command, with menu bar item.
Richard M. Stallman <rms@gnu.org>
parents:
4256
diff
changeset
|
249 (define-key ispell-menu-map [ispell-message] |
fe223c0faf71
(ispell-message): New command, with menu bar item.
Richard M. Stallman <rms@gnu.org>
parents:
4256
diff
changeset
|
250 '("Check Message" . ispell-message)) |
fe223c0faf71
(ispell-message): New command, with menu bar item.
Richard M. Stallman <rms@gnu.org>
parents:
4256
diff
changeset
|
251 |
8822
33a3f424c8c3
(ispell-menu-map): Order menu items by size: buffer > region > word.
Karl Heuer <kwzh@gnu.org>
parents:
8311
diff
changeset
|
252 (define-key ispell-menu-map [ispell-word] |
33a3f424c8c3
(ispell-menu-map): Order menu items by size: buffer > region > word.
Karl Heuer <kwzh@gnu.org>
parents:
8311
diff
changeset
|
253 '("Check Word" . ispell-word)) |
33a3f424c8c3
(ispell-menu-map): Order menu items by size: buffer > region > word.
Karl Heuer <kwzh@gnu.org>
parents:
8311
diff
changeset
|
254 |
4062
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
255 (define-key ispell-menu-map [ispell-region] |
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
256 '("Check Region" . ispell-region)) |
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
257 |
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
258 (define-key ispell-menu-map [ispell-buffer] |
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
259 '("Check Buffer" . ispell)) |
d7f5f18ddbc5
(ispell-menu-map): New keymap--both fn and var.
Richard M. Stallman <rms@gnu.org>
parents:
4043
diff
changeset
|
260 |
11713
5306e71f486c
All autoload cookies disabled.
Richard M. Stallman <rms@gnu.org>
parents:
8822
diff
changeset
|
261 ;;;autoload |
55 | 262 (defun ispell (&optional buf start end) |
671
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
263 "Run Ispell over current buffer's visited file. |
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
264 First the file is scanned for misspelled words, then Ispell |
55 | 265 enters a loop with the following commands for every misspelled word: |
266 | |
267 DIGIT Near miss selector. If the misspelled word is close to | |
268 some words in the dictionary, they are offered as near misses. | |
269 r Replace. Replace the word with a string you type. Each word | |
270 of your new string is also checked. | |
5293
346d921eaf3b
Don't imply private dictionary is always ispell.words.
Richard M. Stallman <rms@gnu.org>
parents:
4933
diff
changeset
|
271 i Insert. Insert this word in your private dictionary (by default, |
55 | 272 `$HOME/ispell.words'). |
273 a Accept. Accept this word for the rest of this editing session, | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3112
diff
changeset
|
274 but don't put it in your private dictionary. |
55 | 275 l Lookup. Look for a word in the dictionary by fast binary |
276 search, or search for a regular expression in the dictionary | |
277 using grep. | |
278 SPACE Accept the word this time, but complain if it is seen again. | |
214 | 279 q, \\[keyboard-quit] Leave the command loop. You can come back later with \\[ispell-next]." |
55 | 280 (interactive) |
281 (if (null start) | |
282 (setq start 0)) | |
283 (if (null end) | |
284 (setq end 0)) | |
285 | |
286 (if (null buf) | |
287 (setq buf (current-buffer))) | |
288 (setq buf (get-buffer buf)) | |
289 (if (null buf) | |
290 (error "Can't find buffer")) | |
2837
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
291 ;; Deactivate the mark, because we'll do it anyway if we change something, |
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
292 ;; and a region highlight while in the Ispell loop is distracting. |
4043
6228decc1353
(ispell): Call deactivate-mark instead of setting mark-active directly. Do
Roland McGrath <roland@gnu.org>
parents:
3722
diff
changeset
|
293 (deactivate-mark) |
55 | 294 (save-excursion |
295 (set-buffer buf) | |
296 (let ((filename buffer-file-name) | |
2837
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
297 (delete-temp nil)) |
55 | 298 (unwind-protect |
299 (progn | |
4889
8b896067d6fb
(ispell): If the buffer to spell has no associated file, or, the
Brian Fox <bfox@gnu.org>
parents:
4842
diff
changeset
|
300 (cond ((or (null filename) |
7030
9e51b51e8595
Pass operation to find-file-name-handler.
Karl Heuer <kwzh@gnu.org>
parents:
5400
diff
changeset
|
301 (find-file-name-handler buffer-file-name nil)) |
55 | 302 (setq filename (make-temp-name "/usr/tmp/ispell")) |
303 (setq delete-temp t) | |
304 (write-region (point-min) (point-max) filename)) | |
305 ((and (buffer-modified-p buf) | |
306 (y-or-n-p (format "Save file %s? " filename))) | |
307 (save-buffer))) | |
308 (message "Ispell scanning file...") | |
309 (if (and ispell-enable-tex-parser | |
310 (ispell-tex-buffer-p)) | |
311 (ispell-cmd ":tex") | |
312 (ispell-cmd ":generic")) | |
313 (ispell-cmd (format ":file %s %d %d" filename start end))) | |
2837
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
314 (if delete-temp |
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
315 (condition-case () |
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
316 (delete-file filename) |
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
317 (file-error nil))))) |
55 | 318 (message "Parsing ispell output ...") |
319 (ispell-flush-bad-words) | |
320 (let (pos bad-words) | |
321 (while (numberp (setq pos (ispell-next-message))) | |
322 ;;ispell may check the words on the line following the end | |
323 ;;of the region - therefore, don't record anything out of range | |
324 (if (or (= end 0) | |
325 (< pos end)) | |
326 (setq bad-words (cons (set-marker (make-marker) (+ pos 1)) | |
327 bad-words)))) | |
328 (setq bad-words (cons pos bad-words)) | |
329 (setq ispell-bad-words (nreverse bad-words)))) | |
330 (cond ((not (markerp (car ispell-bad-words))) | |
331 (setq ispell-bad-words nil) | |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
332 (message "No misspellings.") |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
333 t) |
55 | 334 (t |
335 (message "Ispell parsing done.") | |
336 (ispell-next)))) | |
337 | |
11713
5306e71f486c
All autoload cookies disabled.
Richard M. Stallman <rms@gnu.org>
parents:
8822
diff
changeset
|
338 ;;;autoload |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
339 (defalias 'ispell-buffer 'ispell) |
316 | 340 |
55 | 341 (defun ispell-next () |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
342 "Resume command loop for most recent Ispell command. |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
343 Return value is t unless exit is due to typing `q'." |
55 | 344 (interactive) |
2837
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
345 (setq ispell-window-configuration nil) |
4927 | 346 (prog1 |
347 (unwind-protect | |
348 (catch 'ispell-quit | |
349 ;; There used to be a save-excursion here, | |
350 ;; but that was annoying: it's better if point doesn't move | |
351 ;; when you type q. | |
352 (let (next) | |
353 (while (markerp (setq next (car ispell-bad-words))) | |
354 (switch-to-buffer (marker-buffer next)) | |
355 (push-mark) | |
356 (ispell-point next "at saved position.") | |
357 (setq ispell-bad-words (cdr ispell-bad-words)) | |
358 (set-marker next nil))) | |
359 t) | |
5400
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
360 (ispell-dehighlight) |
4927 | 361 (if ispell-window-configuration |
362 (set-window-configuration ispell-window-configuration)) | |
363 (cond ((null ispell-bad-words) | |
5384
ec02e2f72eae
(ispell-next): Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
5293
diff
changeset
|
364 (error "Ispell has not yet been run")) |
4927 | 365 ((markerp (car ispell-bad-words)) |
14347
f5f5fa38faa7
(start-ispell, ispell-next): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
366 (message "%s" |
f5f5fa38faa7
(start-ispell, ispell-next): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
367 (substitute-command-keys |
5384
ec02e2f72eae
(ispell-next): Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
5293
diff
changeset
|
368 "Type \\[ispell-next] to continue"))) |
4927 | 369 ((eq (car ispell-bad-words) nil) |
370 (setq ispell-bad-words nil) | |
5384
ec02e2f72eae
(ispell-next): Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
5293
diff
changeset
|
371 (message "No more misspellings (but checker was interrupted)")) |
4927 | 372 ((eq (car ispell-bad-words) t) |
373 (setq ispell-bad-words nil) | |
5384
ec02e2f72eae
(ispell-next): Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
5293
diff
changeset
|
374 (message "Ispell done")) |
4927 | 375 (t |
376 (setq ispell-bad-words nil) | |
377 (message "Bad ispell internal list")))) | |
378 (ispell-dump))) | |
55 | 379 |
11713
5306e71f486c
All autoload cookies disabled.
Richard M. Stallman <rms@gnu.org>
parents:
8822
diff
changeset
|
380 ;;;autoload |
671
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
381 (defun ispell-word (&optional resume) |
55 | 382 "Check the spelling of the word under the cursor. |
3623 | 383 See the command `ispell' for more information. |
671
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
384 With a prefix argument, resume handling of the previous Ispell command." |
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
385 (interactive "P") |
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
386 (if resume |
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
387 (ispell-next) |
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
388 (condition-case err |
8221
0b9e18f9b085
(ispell-word): Call ispell-dehighlight.
Richard M. Stallman <rms@gnu.org>
parents:
7841
diff
changeset
|
389 (unwind-protect |
0b9e18f9b085
(ispell-word): Call ispell-dehighlight.
Richard M. Stallman <rms@gnu.org>
parents:
7841
diff
changeset
|
390 (catch 'ispell-quit |
0b9e18f9b085
(ispell-word): Call ispell-dehighlight.
Richard M. Stallman <rms@gnu.org>
parents:
7841
diff
changeset
|
391 (save-window-excursion |
0b9e18f9b085
(ispell-word): Call ispell-dehighlight.
Richard M. Stallman <rms@gnu.org>
parents:
7841
diff
changeset
|
392 (ispell-point (point) "at point.")) |
0b9e18f9b085
(ispell-word): Call ispell-dehighlight.
Richard M. Stallman <rms@gnu.org>
parents:
7841
diff
changeset
|
393 (ispell-dump)) |
0b9e18f9b085
(ispell-word): Call ispell-dehighlight.
Richard M. Stallman <rms@gnu.org>
parents:
7841
diff
changeset
|
394 (ispell-dehighlight)) |
671
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
395 (ispell-startup-error |
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
396 (cond ((y-or-n-p "Problem starting ispell, use old-style spell instead? ") |
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
397 (load-library "spell") |
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
398 (define-key esc-map "$" 'spell-word) |
21d23fa6fa2a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
399 (spell-word))))))) |
5293
346d921eaf3b
Don't imply private dictionary is always ispell.words.
Richard M. Stallman <rms@gnu.org>
parents:
4933
diff
changeset
|
400 |
11713
5306e71f486c
All autoload cookies disabled.
Richard M. Stallman <rms@gnu.org>
parents:
8822
diff
changeset
|
401 ;;;autoload (define-key esc-map "$" 'ispell-word) |
55 | 402 |
11713
5306e71f486c
All autoload cookies disabled.
Richard M. Stallman <rms@gnu.org>
parents:
8822
diff
changeset
|
403 ;;;autoload |
55 | 404 (defun ispell-region (start &optional end) |
405 "Check the spelling for all of the words in the region." | |
406 (interactive "r") | |
407 (ispell (current-buffer) start end)) | |
408 | |
409 (defun ispell-letterp (c) | |
410 (and c | |
411 (or (and (>= c ?A) (<= c ?Z)) | |
412 (and (>= c ?a) (<= c ?z)) | |
413 (>= c 128)))) | |
414 | |
415 (defun ispell-letter-or-quotep (c) | |
416 (and c | |
417 (or (and (>= c ?A) (<= c ?Z)) | |
418 (and (>= c ?a) (<= c ?z)) | |
419 (= c ?') | |
420 (>= c 128)))) | |
421 | |
422 (defun ispell-find-word-start () | |
423 ;;backward to a letter | |
424 (if (not (ispell-letterp (char-after (point)))) | |
425 (while (and (not (bobp)) | |
426 (not (ispell-letterp (char-after (- (point) 1))))) | |
427 (backward-char))) | |
428 ;;backward to beginning of word | |
429 (while (ispell-letter-or-quotep (char-after (- (point) 1))) | |
430 (backward-char)) | |
431 (skip-chars-forward "'")) | |
432 | |
433 (defun ispell-find-word-end () | |
434 (while (ispell-letter-or-quotep (char-after (point))) | |
435 (forward-char)) | |
436 (skip-chars-backward "'")) | |
437 | |
438 (defun ispell-next-word () | |
439 (while (and (not (eobp)) | |
440 (not (ispell-letterp (char-after (point))))) | |
441 (forward-char))) | |
442 | |
443 ;if end is nil, then do one word at start | |
444 ;otherwise, do all words from the beginning of the word where | |
445 ;start points, to the end of the word where end points | |
446 (defun ispell-point (start message) | |
447 (let ((wend (make-marker)) | |
448 rescan | |
449 end) | |
2837
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
450 ;; There used to be a save-excursion here, |
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
451 ;; but that was annoying: it's better if point doesn't move |
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
452 ;; when you type q. |
55 | 453 (goto-char start) |
454 (ispell-find-word-start) ;find correct word start | |
455 (setq start (point-marker)) | |
456 (ispell-find-word-end) ;now find correct end | |
457 (setq end (point-marker)) | |
4256
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
458 ;; Do nothing if we don't find a word. |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
459 (if (< start end) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
460 (while (< start end) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
461 (goto-char start) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
462 (ispell-find-word-end) ;find end of current word |
55 | 463 ;could be before 'end' if |
464 ;user typed replacement | |
465 ;that is more than one word | |
4256
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
466 (set-marker wend (point)) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
467 (setq rescan nil) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
468 (setq word (buffer-substring start wend)) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
469 (cond ((ispell-still-bad word) |
2837
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
470 ;;; This just causes confusion. -- rms. |
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
471 ;;; (goto-char start) |
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
472 ;;; (sit-for 0) |
14347
f5f5fa38faa7
(start-ispell, ispell-next): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
473 (message "Ispell checking %s" word) |
4256
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
474 (ispell-cmd word) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
475 (let ((message (ispell-next-message))) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
476 (cond ((eq message t) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
477 (message "%s: ok" word)) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
478 ((or (null message) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
479 (consp message)) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
480 (setq rescan |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
481 (ispell-command-loop word start wend message))) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
482 (t |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
483 (error "unknown ispell response %s" message)))))) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
484 (cond ((null rescan) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
485 (goto-char wend) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
486 (ispell-next-word) |
aaf846efe4cb
(ispell-point): Do nothing if there's no word at START.
Richard M. Stallman <rms@gnu.org>
parents:
4105
diff
changeset
|
487 (set-marker start (point)))))) |
55 | 488 ;;clear the choices buffer; otherwise it's hard for the user to tell |
489 ;;when we get back to the command loop | |
490 (let ((buf (get-buffer "*ispell choices*"))) | |
491 (cond (buf | |
492 (set-buffer buf) | |
493 (erase-buffer)))) | |
494 (set-marker start nil) | |
495 (set-marker end nil) | |
2837
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
496 (set-marker wend nil))) |
55 | 497 |
498 (defun ispell-still-bad (word) | |
499 (let ((words ispell-recently-accepted) | |
500 (ret t) | |
501 (case-fold-search t)) | |
502 (while words | |
503 (cond ((eq (string-match (car words) word) 0) | |
504 (setq ret nil) | |
505 (setq words nil))) | |
506 (setq words (cdr words))) | |
507 ret)) | |
508 | |
509 (defun ispell-show-choices (word message first-line) | |
778 | 510 ;;if there is only one window on the frame, make the ispell |
55 | 511 ;;messages winow be small. otherwise just use the other window |
512 (let* ((selwin (selected-window)) | |
513 (resize (eq selwin (next-window))) | |
514 (buf (get-buffer-create "*ispell choices*")) | |
515 w) | |
2837
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
516 (or ispell-window-configuration |
00f822101e49
(ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
517 (setq ispell-window-configuration (current-window-configuration))) |
55 | 518 (setq w (display-buffer buf)) |
519 (buffer-disable-undo buf) | |
520 (if resize | |
521 (unwind-protect | |
522 (progn | |
523 (select-window w) | |
524 (enlarge-window (- 6 (window-height w)))) | |
525 (select-window selwin))) | |
526 (save-excursion | |
527 (set-buffer buf) | |
528 (bury-buffer buf) | |
529 (set-window-point w (point-min)) | |
530 (set-window-start w (point-min)) | |
531 (erase-buffer) | |
532 (insert first-line "\n") | |
533 (insert | |
534 "SPC skip; A accept; I insert; DIGIT select; R replace; \ | |
535 L lookup; Q quit\n") | |
536 (cond ((not (null message)) | |
537 (let ((i 0)) | |
538 (while (< i 3) | |
539 (let ((j 0)) | |
540 (while (< j 3) | |
541 (let* ((n (+ (* j 3) i)) | |
542 (choice (nth n message))) | |
543 (cond (choice | |
544 (let ((str (format "%d %s" n choice))) | |
545 (insert str) | |
546 (insert-char ? (- 20 (length str))))))) | |
547 (setq j (+ j 1)))) | |
548 (insert "\n") | |
549 (setq i (+ i 1))))))))) | |
550 | |
551 (defun ispell-command-loop (word start end message) | |
552 (let ((flag t) | |
553 (rescan nil) | |
554 first-line) | |
555 (if (null message) | |
556 (setq first-line (concat "No near misses for '" word "'")) | |
557 (setq first-line (concat "Near misses for '" word "'"))) | |
5400
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
558 (ispell-highlight start end) |
55 | 559 (while flag |
560 (ispell-show-choices word message first-line) | |
561 (message "Ispell command: ") | |
2888
e931a98b2f36
(ispell-command-loop): Make an undo boundary.
Richard M. Stallman <rms@gnu.org>
parents:
2837
diff
changeset
|
562 (undo-boundary) |
55 | 563 (let ((c (downcase (read-char))) |
564 replacement) | |
565 (cond ((and (>= c ?0) | |
566 (<= c ?9) | |
567 (setq replacement (nth (- c ?0) message))) | |
568 (ispell-replace start end replacement) | |
569 (setq flag nil)) | |
570 ((= c ?q) | |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
571 (throw 'ispell-quit nil)) |
4927 | 572 ((= c (nth 3 (current-input-mode))) |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
573 (keyboard-quit)) |
55 | 574 ((= c ? ) |
575 (setq flag nil)) | |
576 ((= c ?r) | |
577 (ispell-replace start end (read-string "Replacement: ")) | |
578 (setq rescan t) | |
579 (setq flag nil)) | |
580 ((= c ?i) | |
581 (ispell-insert word) | |
582 (setq flag nil)) | |
583 ((= c ?a) | |
584 (ispell-accept word) | |
585 (setq flag nil)) | |
586 ((= c ?l) | |
587 (let ((val (ispell-do-look word))) | |
588 (setq first-line (car val)) | |
589 (setq message (cdr val)))) | |
590 ((= c ??) | |
591 (message | |
592 "Type 'C-h d ispell' to the emacs main loop for more help") | |
593 (sit-for 2)) | |
594 (t | |
595 (message "Bad ispell command") | |
596 (sit-for 2))))) | |
597 rescan)) | |
598 | |
599 (defun ispell-do-look (bad-word) | |
600 (let (regex buf words) | |
601 (cond ((null ispell-have-new-look) | |
602 (setq regex (read-string "Lookup: "))) | |
603 (t | |
604 (setq regex (read-string "Lookup (regex): " "^")))) | |
605 (setq buf (get-buffer-create "*ispell look*")) | |
606 (save-excursion | |
607 (set-buffer buf) | |
608 (delete-region (point-min) (point-max)) | |
609 (if ispell-have-new-look | |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
610 (call-process ispell-look-command nil buf nil "-r" regex) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
611 (call-process ispell-look-command nil buf nil regex)) |
55 | 612 (goto-char (point-min)) |
613 (forward-line 10) | |
614 (delete-region (point) (point-max)) | |
615 (goto-char (point-min)) | |
616 (while (not (= (point-min) (point-max))) | |
617 (end-of-line) | |
618 (setq words (cons (buffer-substring (point-min) (point)) words)) | |
619 (forward-line) | |
620 (delete-region (point-min) (point))) | |
621 (kill-buffer buf) | |
622 (cons (format "Lookup '%s'" regex) | |
623 (reverse words))))) | |
624 | |
625 (defun ispell-replace (start end new) | |
626 (goto-char start) | |
627 (insert new) | |
628 (delete-region (point) end)) | |
629 | |
630 (defun reload-ispell () | |
3623 | 631 "Tell Ispell to re-read your private dictionary." |
55 | 632 (interactive) |
633 (ispell-cmd ":reload")) | |
634 | |
635 (defun batch-make-ispell () | |
636 (byte-compile-file "ispell.el") | |
637 (find-file "ispell.texinfo") | |
638 (let ((old-dir default-directory) | |
639 (default-directory "/tmp")) | |
640 (texinfo-format-buffer)) | |
641 (Info-validate) | |
642 (if (get-buffer " *problems in info file*") | |
643 (kill-emacs 1)) | |
644 (write-region (point-min) (point-max) "ispell.info")) | |
645 | |
21088 | 646 (defcustom ispell-highlight t |
647 "*Non-nil means to highlight ispell words." | |
648 :type 'boolean | |
649 :group 'ispell4) | |
5400
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
650 |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
651 (defvar ispell-overlay nil) |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
652 |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
653 (defun ispell-dehighlight () |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
654 (and ispell-overlay |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
655 (progn |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
656 (delete-overlay ispell-overlay) |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
657 (setq ispell-overlay nil)))) |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
658 |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
659 (defun ispell-highlight (start end) |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
660 (and ispell-highlight |
7565
edf32f56ba70
(ispell-highlight): Do nothing unless window-system.
Richard M. Stallman <rms@gnu.org>
parents:
7446
diff
changeset
|
661 window-system |
5400
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
662 (progn |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
663 (or ispell-overlay |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
664 (progn |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
665 (setq ispell-overlay (make-overlay start end)) |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
666 (overlay-put ispell-overlay 'face |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
667 (if (internal-find-face 'ispell) |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
668 'ispell 'region)))) |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
669 (move-overlay ispell-overlay start end (current-buffer))))) |
dd2c5504bcc1
(ispell-highlight, ispell-dehighlight): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
5384
diff
changeset
|
670 |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
671 ;;;; ispell-complete-word |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
672 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
673 ;;; Brief Description: |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
674 ;;; Complete word fragment at point using dictionary and replace with full |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
675 ;;; word. Expansion done in current buffer like lisp-complete-symbol. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
676 ;;; Completion of interior word fragments possible with prefix argument. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
677 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
678 ;;; Known Problem: |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
679 ;;; Does not use private dictionary because GNU `look' does not use it. It |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
680 ;;; would be nice if GNU `look' took standard input; this would allow gzip'ed |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
681 ;;; dictionaries to be used. GNU `look' also has a bug, see |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
682 ;;; `ispell-gnu-look-still-broken-p'. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
683 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
684 ;;; Motivation: |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
685 ;;; The `l', "regular expression look up", keymap option of ispell-word |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
686 ;;; (ispell-do-look) can only be run after finding a misspelled word. So |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
687 ;;; ispell-do-look can not be used to look for words starting with `cat' to |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
688 ;;; find `catechetical' since `cat' is a correctly spelled word. Furthermore, |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
689 ;;; ispell-do-look does not return the entire list returned by `look'. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
690 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
691 ;;; ispell-complete-word allows you to get a completion list from the system |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
692 ;;; dictionary and expand a word fragment at the current position in a buffer. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
693 ;;; These examples assume ispell-complete-word is bound to M-TAB as it is in |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
694 ;;; text-mode; the `Complete Word' and `Complete Interior Fragment' entries of |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
695 ;;; the "Spell" submenu under the "Edit" menu may also be used instead of |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
696 ;;; M-TAB and C-u M-TAB, respectively. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
697 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
698 ;;; EXAMPLE 1: The word `Saskatchewan' needs to be spelled. The user may |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
699 ;;; type `Sas' and hit M-TAB and a completion list will be built using the |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
700 ;;; shell command `look' and displayed in the *Completions* buffer: |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
701 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
702 ;;; Possible completions are: |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
703 ;;; sash sashay |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
704 ;;; sashayed sashed |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
705 ;;; sashes sashimi |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
706 ;;; Saskatchewan Saskatoon |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
707 ;;; sass sassafras |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
708 ;;; sassier sassing |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
709 ;;; sasswood sassy |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
710 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
711 ;;; By viewing this list the user will hopefully be motivated to insert the |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
712 ;;; letter `k' after the `sas'. When M-TAB is hit again the word `Saskat' |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
713 ;;; will be inserted in place of `sas' (note case) since this is a unique |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
714 ;;; substring completion. The narrowed completion list can be viewed with |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
715 ;;; another M-TAB |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
716 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
717 ;;; Possible completions are: |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
718 ;;; Saskatchewan Saskatoon |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
719 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
720 ;;; Inserting the letter `c' and hitting M-TAB will narrow the completion |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
721 ;;; possibilities to just `Saskatchewan' and this will be inserted in the |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
722 ;;; buffer. At any point the user may click the mouse on a completion to |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
723 ;;; select it. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
724 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
725 ;;; EXAMPLE 2: The user has typed `Sasaquane' and M-$ (ispell-word) gives no |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
726 ;;; "near-misses" in which case you back up to `Sas' and hit M-TAB and find |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
727 ;;; the correct word as above. The `Sas' will be replaced by `Saskatchewan' |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
728 ;;; and the remaining word fragment `aquane' can be deleted. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
729 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
730 ;;; EXAMPLE 3: If a version of `look' is used that supports regular |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
731 ;;; expressions, then `ispell-have-new-look' should be t (its default) and |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
732 ;;; interior word fragments may also be used for the search. The word |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
733 ;;; `pneumonia' needs to be spelled. The user can only remember the |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
734 ;;; interior fragment `mon' in which case `C-u M-TAB' on `mon' gives a list |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
735 ;;; of all words containing the interior word fragment `mon'. Typing `p' |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
736 ;;; and M-TAB will narrow this list to all the words starting with `p' and |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
737 ;;; containing `mon' from which `pneumonia' can be found as above. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
738 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
739 ;;; The user-defined variables are: |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
740 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
741 ;;; ispell-look-command |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
742 ;;; ispell-look-dictionary |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
743 ;;; ispell-gnu-look-still-broken-p |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
744 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
745 ;;; Algorithm (some similarity to lisp-complete-symbol): |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
746 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
747 ;;; * call-process on command ispell-look-command (default: "look") to find |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
748 ;;; words in ispell-look-dictionary matching `string' (or `regexp' if |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
749 ;;; ispell-have-new-look is t). Parse output and store results in |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
750 ;;; ispell-lookup-completions-alist. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
751 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
752 ;;; * Build completion list using try-completion and `string' |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
753 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
754 ;;; * Replace `string' in buffer with matched common substring completion. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
755 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
756 ;;; * Display completion list only if there is no matched common substring. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
757 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
758 ;;; * Rebuild ispell-lookup-completions-alist, on a next call, only when |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
759 ;;; beginning of word fragment has changed. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
760 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
761 ;;; * Interior fragments searches are performed similarly with the exception |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
762 ;;; that the entire fragment at point is initially removed from the buffer, |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
763 ;;; the STRING passed to try-completion and all-completions is just "" and |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
764 ;;; not the interior fragment; this allows all completions containing the |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
765 ;;; interior fragment to be shown. The location in the buffer is stored to |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
766 ;;; decide whether future completion narrowing of the current list should be |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
767 ;;; done or if a new list should be built. See interior fragment example |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
768 ;;; above. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
769 ;;; |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
770 ;;; * Robust searches are done using a `look' with -r (regular expression) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
771 ;;; switch if ispell-have-new-look is t. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
772 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
773 ;;;; User-defined variables. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
774 |
21088 | 775 (defcustom ispell-look-dictionary nil |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
776 "*If non-nil then spelling dictionary as string for `ispell-complete-word'. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
777 Overrides default dictionary file such as \"/usr/dict/words\" or GNU look's |
21088 | 778 \"${prefix}/lib/ispell/ispell.words\"" |
779 :type '(choice (const nil) file) | |
780 :group 'ispell4) | |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
781 |
21088 | 782 |
783 (defcustom ispell-gnu-look-still-broken-p nil | |
13994
1514fd54b2f5
(ispell-gnu-look-still-broken-p, ispell-message-text-end):
Karl Heuer <kwzh@gnu.org>
parents:
11713
diff
changeset
|
784 "*t if GNU look -r can give different results with and without trailing `.*'. |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
785 Example: `look -dfr \"^ya\" foo' returns nothing, while `look -dfr \"^ya.*\" foo' |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
786 returns `yacc', where `foo' is a dictionary file containing the three lines |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
787 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
788 y |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
789 y's |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
790 yacc |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
791 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
792 Both commands should return `yacc'. If `ispell-complete-word' erroneously |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
793 states that no completions exist for a string, then setting this variable to t |
21088 | 794 will help find those completions." |
795 :type 'boolean | |
796 :group 'ispell4) | |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
797 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
798 ;;;; Internal variables. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
799 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
800 ;;; Possible completions for last word fragment. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
801 (defvar ispell-lookup-completions-alist nil) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
802 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
803 ;;; Last word fragment processed by `ispell-complete-word'. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
804 (defvar ispell-lookup-last-word nil) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
805 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
806 ;;; Buffer local variables. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
807 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
808 ;;; Value of interior-frag in last call to `ispell-complete-word'. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
809 (defvar ispell-lookup-last-interior-p nil) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
810 (make-variable-buffer-local 'ispell-lookup-last-interior-p) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
811 (put 'ispell-lookup-last-interior-p 'permanent-local t) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
812 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
813 ;;; Buffer position in last call to `ispell-complete-word'. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
814 (defvar ispell-lookup-last-bow nil) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
815 (make-variable-buffer-local 'ispell-lookup-last-bow) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
816 (put 'ispell-lookup-last-bow 'permanent-local t) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
817 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
818 ;;;; Interactive functions. |
11713
5306e71f486c
All autoload cookies disabled.
Richard M. Stallman <rms@gnu.org>
parents:
8822
diff
changeset
|
819 ;;;autoload |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
820 (defun ispell-complete-word (&optional interior-frag) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
821 "Complete word using letters at point to word beginning using `look'. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
822 With optional argument INTERIOR-FRAG, word fragment at point is assumed to be |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
823 an interior word fragment in which case `ispell-have-new-look' should be t. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
824 See also `ispell-look-dictionary' and `ispell-gnu-look-still-broken-p'." |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
825 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
826 (interactive "P") |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
827 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
828 ;; `look' must support regexp expressions in order to perform an interior |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
829 ;; fragment search. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
830 (if (and interior-frag (not ispell-have-new-look)) |
5384
ec02e2f72eae
(ispell-next): Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
5293
diff
changeset
|
831 (error (concat "Sorry, `ispell-have-new-look' is nil. " |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
832 "You also will need GNU Ispell's `look'."))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
833 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
834 (let* ((completion-ignore-case t) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
835 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
836 ;; Get location of beginning of word fragment. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
837 (bow (save-excursion (skip-chars-backward "a-zA-Z'") (point))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
838 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
839 ;; Get the string to look up. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
840 (string (buffer-substring bow (point))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
841 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
842 ;; Get regexp for which we search and, if necessary, an interior word |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
843 ;; fragment. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
844 (regexp (if interior-frag |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
845 (concat "^.*" string ".*") |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
846 ;; If possible use fast binary search: no trailing `.*'. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
847 (concat "^" string |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
848 (if ispell-gnu-look-still-broken-p ".*")))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
849 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
850 ;; We want all completions for case of interior fragments so set |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
851 ;; prefix to an empty string. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
852 (prefix (if interior-frag "" string)) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
853 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
854 ;; Are we continuing from a previous interior fragment search? |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
855 ;; Check last value of interior-word and if the point has moved. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
856 (continuing-an-interior-frag-p |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
857 (and ispell-lookup-last-interior-p |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
858 (equal ispell-lookup-last-bow bow))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
859 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
860 ;; Are we starting a unique word fragment search? Always t for |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
861 ;; interior word fragment search. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
862 (new-unique-string-p |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
863 (or interior-frag (null ispell-lookup-last-word) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
864 (let ((case-fold-search t)) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
865 ;; Can we locate last word fragment as a substring of current |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
866 ;; word fragment? If the last word fragment is larger than |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
867 ;; the current string then we will have to rebuild the list |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
868 ;; later. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
869 (not (string-match |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
870 (concat "^" ispell-lookup-last-word) string))))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
871 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
872 completion) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
873 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
874 ;; Check for perfect completion already. That is, maybe the user has hit |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
875 ;; M-x ispell-complete-word one too many times? |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
876 (if (string-equal string "") |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
877 (if (string-equal (concat ispell-lookup-last-word " ") |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
878 (buffer-substring |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
879 (save-excursion (forward-word -1) (point)) (point))) |
5384
ec02e2f72eae
(ispell-next): Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
5293
diff
changeset
|
880 (error "Perfect match already") |
ec02e2f72eae
(ispell-next): Remove periods from messages.
Richard M. Stallman <rms@gnu.org>
parents:
5293
diff
changeset
|
881 (error "No word fragment at point"))) |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
882 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
883 ;; Create list of words from system dictionary starting with `string' if |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
884 ;; new string and not continuing from a previous interior fragment search. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
885 (if (and (not continuing-an-interior-frag-p) new-unique-string-p) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
886 (setq ispell-lookup-completions-alist |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
887 (ispell-lookup-build-list string regexp))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
888 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
889 ;; Check for a completion of `string' in the list and store `string' and |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
890 ;; other variables for the next call. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
891 (setq completion (try-completion prefix ispell-lookup-completions-alist) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
892 ispell-lookup-last-word string |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
893 ispell-lookup-last-interior-p interior-frag |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
894 ispell-lookup-last-bow bow) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
895 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
896 ;; Test the completion status. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
897 (cond |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
898 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
899 ;; * Guess is a perfect match. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
900 ((eq completion t) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
901 (insert " ") |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
902 (message "Perfect match.")) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
903 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
904 ;; * No possibilities. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
905 ((null completion) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
906 (message "Can't find completion for \"%s\"" string) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
907 (beep)) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
908 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
909 ;; * Replace string fragment with matched common substring completion. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
910 ((and (not (string-equal completion "")) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
911 ;; Fold case so a completion list is built when `string' and common |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
912 ;; substring differ only in case. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
913 (let ((case-fold-search t)) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
914 (not (string-match (concat "^" completion "$") string)))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
915 (search-backward string bow) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
916 (replace-match completion nil t) ; FIXEDCASE doesn't work? or LITERAL? |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
917 (message "Proposed unique substring. Repeat for completions list.")) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
918 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
919 ;; * String is a common substring completion already. Make list. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
920 (t |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
921 (message "Making completion list...") |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
922 (if (string-equal completion "") (delete-region bow (point))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
923 (let ((list (all-completions prefix ispell-lookup-completions-alist))) |
7841
f152f2b276c5
(ispell-complete-word): Likewise.
Richard M. Stallman <rms@gnu.org>
parents:
7565
diff
changeset
|
924 (with-output-to-temp-buffer "*Completions*" |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
925 (display-completion-list list))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
926 (message "Making completion list...done"))))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
927 |
11713
5306e71f486c
All autoload cookies disabled.
Richard M. Stallman <rms@gnu.org>
parents:
8822
diff
changeset
|
928 ;;;autoload |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
929 (defun ispell-complete-word-interior-frag () |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
930 "Runs `ispell-complete-word' with a non-nil INTERIOR-FRAG. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
931 A completion list is built for word fragment at point which is assumed to be |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
932 an interior word fragment. `ispell-have-new-look' should be t." |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
933 (interactive) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
934 (ispell-complete-word t)) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
935 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
936 ;;;; Internal Function. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
937 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
938 ;;; Build list of words using ispell-look-command from dictionary |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
939 ;;; ispell-look-dictionary (if this is a non-nil string). Look for words |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
940 ;;; starting with STRING if ispell-have-new-look is nil or look for REGEXP if |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
941 ;;; ispell-have-new-look is t. Returns result as an alist suitable for use by |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
942 ;;; try-completion, all-completions, and completing-read. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
943 (defun ispell-lookup-build-list (string regexp) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
944 (save-excursion |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
945 (message "Building list...") |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
946 (set-buffer (get-buffer-create " *ispell look*")) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
947 (erase-buffer) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
948 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
949 (if (stringp ispell-look-dictionary) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
950 (if ispell-have-new-look |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
951 (call-process ispell-look-command nil t nil "-fr" regexp |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
952 ispell-look-dictionary) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
953 (call-process ispell-look-command nil t nil "-f" string |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
954 ispell-look-dictionary)) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
955 (if ispell-have-new-look |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
956 (call-process ispell-look-command nil t nil "-fr" regexp) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
957 (call-process ispell-look-command nil t nil "-f" string))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
958 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
959 ;; Build list for try-completion and all-completions by storing each line |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
960 ;; of output starting from bottom of buffer and deleting upwards. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
961 (let (list) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
962 (goto-char (point-min)) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
963 (while (not (= (point-min) (point-max))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
964 (end-of-line) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
965 (setq list (cons (buffer-substring (point-min) (point)) list)) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
966 (forward-line) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
967 (delete-region (point-min) (point))) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
968 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
969 ;; Clean. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
970 (erase-buffer) |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
971 (message "Building list...done") |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
972 |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
973 ;; Make the list into an alist and return. |
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
974 (mapcar 'list (nreverse list))))) |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
975 |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
976 ;; Return regexp-quote of STRING if STRING is non-empty. |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
977 ;; Otherwise return an unmatchable regexp. |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
978 (defun ispell-non-empty-string (string) |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
979 (if (or (not string) (string-equal string "")) |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
980 "\\'\\`" ; An unmatchable string if string is null. |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
981 (regexp-quote string))) |
4895
7c2d90ff5849
(ispell-look-command): New user variable.
Richard M. Stallman <rms@gnu.org>
parents:
4889
diff
changeset
|
982 |
21088 | 983 (defcustom ispell-message-cite-regexp "^ \\|^\t" |
984 "*Regular expression to match lines cited from one message into another." | |
985 :type 'regexp | |
986 :group 'ispell4) | |
4842
ef5f87232112
(ispell-message-cite-regexp): Add definition.
Richard M. Stallman <rms@gnu.org>
parents:
4786
diff
changeset
|
987 |
21088 | 988 (defcustom ispell-message-text-end |
7446
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
989 (concat "^\\(" (mapconcat (function identity) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
990 '( |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
991 ;; Matches postscript files. |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
992 "%!PS-Adobe-2.0" |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
993 ;; Matches uuencoded text |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
994 "begin [0-9][0-9][0-9] .*\nM.*\nM.*\nM" |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
995 ;; Matches shell files (esp. auto-decoding) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
996 "#! /bin/sh" |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
997 ;; Matches difference listing |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
998 "diff -c .*\n\\*\\*\\* .*\n--- " |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
999 ;; Matches "--------------------- cut here" |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1000 "[-=]+\\s cut here") |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1001 "\\|") |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1002 "\\)") |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1003 "*End of text which will be checked in ispell-message. |
13994
1514fd54b2f5
(ispell-gnu-look-still-broken-p, ispell-message-text-end):
Karl Heuer <kwzh@gnu.org>
parents:
11713
diff
changeset
|
1004 If it is a string, limit at first occurrence of that regular expression. |
21088 | 1005 Otherwise, it must be a function which is called to get the limit." |
1006 :type '(choice string function) | |
1007 :group 'ispell4) | |
7446
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1008 |
21088 | 1009 (defcustom ispell-message-limit (* 100 80) |
1010 "*Ispell-message will check no more than this number of characters." | |
1011 :type 'integer | |
1012 :group 'ispell4) | |
7446
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1013 |
11713
5306e71f486c
All autoload cookies disabled.
Richard M. Stallman <rms@gnu.org>
parents:
8822
diff
changeset
|
1014 ;;;autoload |
4749
fe223c0faf71
(ispell-message): New command, with menu bar item.
Richard M. Stallman <rms@gnu.org>
parents:
4256
diff
changeset
|
1015 (defun ispell-message () |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1016 "Check the spelling of a mail message or news post. |
7446
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1017 Don't check spelling of message headers (except subject) or included messages. |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1018 |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1019 To spell-check whenever a message is sent, include this line in .emacs: |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1020 (setq news-inews-hook (setq mail-send-hook 'ispell-message)) |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1021 |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1022 Or you can bind the function to C-c i in gnus or mail with: |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1023 (setq mail-mode-hook (setq news-reply-mode-hook |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1024 (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))))" |
4749
fe223c0faf71
(ispell-message): New command, with menu bar item.
Richard M. Stallman <rms@gnu.org>
parents:
4256
diff
changeset
|
1025 (interactive) |
fe223c0faf71
(ispell-message): New command, with menu bar item.
Richard M. Stallman <rms@gnu.org>
parents:
4256
diff
changeset
|
1026 (save-excursion |
4929
2b5e416494d1
(ispell-message): If gnus, but no mail-yank-prefix,
Richard M. Stallman <rms@gnu.org>
parents:
4927
diff
changeset
|
1027 (let (non-internal-message |
2b5e416494d1
(ispell-message): If gnus, but no mail-yank-prefix,
Richard M. Stallman <rms@gnu.org>
parents:
4927
diff
changeset
|
1028 (old-case-fold-search case-fold-search) |
2b5e416494d1
(ispell-message): If gnus, but no mail-yank-prefix,
Richard M. Stallman <rms@gnu.org>
parents:
4927
diff
changeset
|
1029 (case-fold-search nil)) |
21872
0308bce52ae4
(ispell-message): Use rfc822-goto-eoh.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1030 |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1031 ;; Don't spell-check the headers. |
21872
0308bce52ae4
(ispell-message): Use rfc822-goto-eoh.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1032 (rfc822-goto-eoh) |
0308bce52ae4
(ispell-message): Use rfc822-goto-eoh.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1033 (forward-line 1) |
0308bce52ae4
(ispell-message): Use rfc822-goto-eoh.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1034 (setq non-internal-message (looking-at "")) |
0308bce52ae4
(ispell-message): Use rfc822-goto-eoh.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1035 |
7446
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1036 (let* ((cite-regexp ;Prefix of inserted text |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1037 (cond |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1038 ((featurep 'supercite) ; sc 3.0 |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1039 (concat "\\(" (sc-cite-regexp) "\\)" "\\|" |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1040 (ispell-non-empty-string sc-reference-tag-string))) |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1041 ((featurep 'sc) ; sc 2.3 |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1042 (concat "\\(" sc-cite-regexp "\\)" "\\|" |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1043 (ispell-non-empty-string sc-reference-tag-string))) |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1044 (non-internal-message ; Assume nn sent us this message. |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1045 (concat "In [a-zA-Z.]+ you write:" "\\|" |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1046 "In <[^,;&+=]+> [^,;&+=]+ writes:" "\\|" |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1047 " *> *")) |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1048 ((equal major-mode 'news-reply-mode) ;Gnus |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1049 (concat "In article <" "\\|" |
4929
2b5e416494d1
(ispell-message): If gnus, but no mail-yank-prefix,
Richard M. Stallman <rms@gnu.org>
parents:
4927
diff
changeset
|
1050 (if mail-yank-prefix |
2b5e416494d1
(ispell-message): If gnus, but no mail-yank-prefix,
Richard M. Stallman <rms@gnu.org>
parents:
4927
diff
changeset
|
1051 (ispell-non-empty-string mail-yank-prefix) |
2b5e416494d1
(ispell-message): If gnus, but no mail-yank-prefix,
Richard M. Stallman <rms@gnu.org>
parents:
4927
diff
changeset
|
1052 ispell-message-cite-regexp))) |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1053 ((boundp 'vm-included-text-prefix) ; VM mail message |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1054 (concat "[^,;&+=]+ writes:" "\\|" |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1055 (ispell-non-empty-string vm-included-text-prefix) |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1056 )) |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1057 ((boundp 'mh-ins-buf-prefix) ; mh mail message |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1058 (ispell-non-empty-string mh-ins-buf-prefix)) |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1059 (mail-yank-prefix ; vanilla mail message. |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1060 (ispell-non-empty-string mail-yank-prefix)) |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1061 (t ispell-message-cite-regexp))) |
7446
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1062 (continue t) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1063 (limit |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1064 (min |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1065 (+ (point-min) ispell-message-limit) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1066 (point-max) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1067 (save-excursion |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1068 (cond |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1069 ((not ispell-message-text-end) (point-max)) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1070 ((char-or-string-p ispell-message-text-end) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1071 (if (re-search-forward ispell-message-text-end nil 'end) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1072 (match-beginning 0) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1073 (point-max))) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1074 (t (funcall ispell-message-text-end)))))) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1075 (search-limit ; Search limit which won't stop in middle of citation |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1076 (+ limit (length cite-regexp))) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1077 ) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1078 ;; Check the subject |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1079 (save-excursion |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1080 (let ((case-fold-search t) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1081 (message-begin (point))) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1082 (goto-char (point-min)) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1083 ;; "\\s *" matches newline if subject is empty |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1084 (if (and (re-search-forward "^Subject:[\t ]*" message-begin t) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1085 (not (looking-at "re\\>"))) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1086 (setq continue |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1087 (ispell-region (- (point) 1) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1088 (progn |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1089 (end-of-line) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1090 (while (looking-at "\n[ \t]") |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1091 (end-of-line 2)) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1092 (point)))) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1093 ))) |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1094 |
7446
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1095 ;; Check the body. |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1096 (while (and (< (point) limit) continue) |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1097 ;; Skip across text cited from other messages. |
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1098 (while (and (looking-at (concat "^[ \t]*$\\|" cite-regexp)) |
7446
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1099 (< (point) limit)) |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1100 (forward-line 1)) |
7446
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1101 (if (< (point) limit) |
4929
2b5e416494d1
(ispell-message): If gnus, but no mail-yank-prefix,
Richard M. Stallman <rms@gnu.org>
parents:
4927
diff
changeset
|
1102 ;; Check the next batch of lines that *aren't* cited. |
4926
c639a86ac9f1
(ispell-message): Stop if ispell-region returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
4895
diff
changeset
|
1103 (let ((start (point))) |
7446
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1104 (if (re-search-forward |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1105 (concat "^\\(" cite-regexp "\\)") search-limit 'end) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1106 (beginning-of-line)) |
3b974ab09824
(ispell-message): Add `ispell-message-text-end' and
Richard M. Stallman <rms@gnu.org>
parents:
7030
diff
changeset
|
1107 (if (> (point) limit) (goto-char limit)) |
4929
2b5e416494d1
(ispell-message): If gnus, but no mail-yank-prefix,
Richard M. Stallman <rms@gnu.org>
parents:
4927
diff
changeset
|
1108 (let ((case-fold-search old-case-fold-search)) |
2b5e416494d1
(ispell-message): If gnus, but no mail-yank-prefix,
Richard M. Stallman <rms@gnu.org>
parents:
4927
diff
changeset
|
1109 (save-excursion |
2b5e416494d1
(ispell-message): If gnus, but no mail-yank-prefix,
Richard M. Stallman <rms@gnu.org>
parents:
4927
diff
changeset
|
1110 (setq continue (ispell-region (- start 1) (point)))))))))))) |
4749
fe223c0faf71
(ispell-message): New command, with menu bar item.
Richard M. Stallman <rms@gnu.org>
parents:
4256
diff
changeset
|
1111 |
3112 | 1112 (provide 'ispell) |
1113 | |
21088 | 1114 ;;; ispell4.el ends here |