annotate lisp/textmodes/=ispell4.el @ 3711:5acf09035d16

(shut_down_emacs): New arg STUFF. Stuff input here. (Fkill_emacs, fatal_error_signal): Pass new arg. (main) [GETPGRP_NO_ARG]: Really pass no arg to getpgrp.
author Richard M. Stallman <rms@gnu.org>
date Sun, 13 Jun 1993 02:06:51 +0000
parents 739ba36097c9
children c9938769a6b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 317
diff changeset
1 ;;; ispell.el --- this is the GNU EMACS interface to GNU ISPELL version 3.
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 317
diff changeset
2
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 792
diff changeset
3 ;;Copyright (C) 1990, 1991 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
671
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
7 ;;This file is part of GNU Emacs.
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;;
671
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
9 ;;GNU Emacs is free software; you can redistribute it and/or modify
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;;it under the terms of the GNU General Public License as published by
317
18554fcbc0b6 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 316
diff changeset
11 ;;the Free Software Foundation; either version 2, or (at your option)
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;;any later version.
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;;
671
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
14 ;;GNU Emacs is distributed in the hope that it will be useful,
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;;but WITHOUT ANY WARRANTY; without even the implied warranty of
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;;GNU General Public License for more details.
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;;
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;;You should have received a copy of the GNU General Public License
671
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
20 ;;along with GNU Emacs; see the file COPYING. If not, write to
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;;the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
23 ;;; Commentary:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
24
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
25 ;; 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
26 ;; spelling checker.
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2247
diff changeset
27
792
45d748a65f24 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
28 ;;; Code:
45d748a65f24 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
29
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 (defvar ispell-have-new-look t
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
31 "Non-nil means use the `-r' option when running `look'.")
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 (defvar ispell-enable-tex-parser nil
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
34 "Non-nil enables experimental TeX parser in Ispell for TeX-mode buffers.")
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
35
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
36 (defvar ispell-process nil "The process running Ispell")
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
37 (defvar ispell-next-message nil
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
38 "An integer: where in `*ispell*' buffer to find next message from Ispell.")
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
40 (defvar ispell-command "ispell"
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
41 "Command for running Ispell.")
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
42 (defvar ispell-command-options nil
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
43 "*String (or list of strings) to pass to Ispell as command arguments.
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
44 You can use this to specify the name of your private dictionary.
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
45 The -S option is always passed to Ispell as the last parameter,
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
46 and need not be mentioned here.")
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;Each marker in this list points to the start of a word that
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;ispell thought was bad last time it did the :file command.
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;Notice that if the user accepts or inserts a word into his
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;private dictionary, then some "good" words will be on the list.
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;We would like to deal with this by looking up the words again just before
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;presenting them to the user, but that is too slow on machines
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;without the select system call. Therefore, see the variable
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;ispell-recently-accepted.
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (defvar ispell-bad-words nil
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
57 "A list of markers reflecting the output of the Ispell `:file' command.")
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;list of words that the user has accepted, but that might still
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;be on the bad-words list
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (defvar ispell-recently-accepted nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
2837
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
63 ;; 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
64 ;; This is the window config from before then.
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
65 (defvar ispell-window-configuration)
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
66
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;t when :dump command needed
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (defvar ispell-dump-needed nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (defun ispell-flush-bad-words ()
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (while ispell-bad-words
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (if (markerp (car ispell-bad-words))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (set-marker (car ispell-bad-words) nil))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (setq ispell-bad-words (cdr ispell-bad-words)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (setq ispell-recently-accepted nil))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (defun kill-ispell ()
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
78 "Kill the Ispell process.
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3112
diff changeset
79 Any changes in your private dictionary
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 that have not already been dumped will be lost."
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (interactive)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (if ispell-process
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (delete-process ispell-process))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (setq ispell-process nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (ispell-flush-bad-words))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (put 'ispell-startup-error 'error-conditions
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 '(ispell-startup-error error))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (put 'ispell-startup-error 'error-message
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 "Problem starting ispell - see buffer *ispell*")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
92 ;; Start an ispell subprocess; check the version; and display the greeting.
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
93
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (defun start-ispell ()
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (message "Starting ispell ...")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (let ((buf (get-buffer "*ispell*")))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (if buf
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (kill-buffer buf)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (condition-case err
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
100 (setq ispell-process
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
101 (apply 'start-process "ispell" "*ispell*" ispell-command
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
102 (append (if (listp ispell-command-options)
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
103 ispell-command-options
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
104 (list ispell-command-options))
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
105 '("-S"))))
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (file-error (signal 'ispell-startup-error nil)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (process-kill-without-query ispell-process)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (buffer-disable-undo (process-buffer ispell-process))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (accept-process-output ispell-process)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (let (last-char)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (save-excursion
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (set-buffer (process-buffer ispell-process))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (bury-buffer (current-buffer))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (setq last-char (- (point-max) 1))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (while (not (eq (char-after last-char) ?=))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (cond ((not (eq (process-status ispell-process) 'run))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (kill-ispell)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (signal 'ispell-startup-error nil)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (accept-process-output ispell-process)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (setq last-char (- (point-max) 1)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (goto-char (point-min))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (let ((greeting (read (current-buffer))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (if (not (= (car greeting) 1))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (error "Bad ispell version: wanted 1, got %d" (car greeting)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (message (car (cdr greeting))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (delete-region (point-min) last-char))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
128 ;; Make sure ispell is ready for a command.
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
129 ;; Leaves buffer set to *ispell*, point at '='.
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
130
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (defun ispell-sync (intr)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (if (or (null ispell-process)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (not (eq (process-status ispell-process) 'run)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (start-ispell))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (if intr
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (interrupt-process ispell-process))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (let (last-char)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (set-buffer (process-buffer ispell-process))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (bury-buffer (current-buffer))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (setq last-char (- (point-max) 1))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (while (not (eq (char-after last-char) ?=))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (accept-process-output ispell-process)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (setq last-char (- (point-max) 1)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (goto-char last-char)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
146 ;; Send a command to ispell. Choices are:
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
147 ;;
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
148 ;; WORD Check spelling of WORD. Result is
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
149 ;;
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
150 ;; nil not found
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
151 ;; t spelled ok
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
152 ;; list of strings near misses
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
153 ;;
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
154 ;; :file FILENAME scan the named file, and print the file offsets of
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
155 ;; any misspelled words
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
156 ;;
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
157 ;; :insert WORD put word in private dictionary
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
158 ;;
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
159 ;; :accept WORD don't complain about word any more this session
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
160 ;;
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
161 ;; :dump write out the current private dictionary, if necessary.
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
162 ;;
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
163 ;; :reload reread `~/ispell.words'
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
164 ;;
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
165 ;; :tex
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
166 ;; :troff
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
167 ;; :generic set type of parser to use when scanning whole files
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
169 (defun ispell-cmd (&rest strings)
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (save-excursion
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (ispell-sync t)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (set-buffer (process-buffer ispell-process))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (bury-buffer (current-buffer))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (erase-buffer)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (setq ispell-next-message (point-min))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (while strings
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (process-send-string ispell-process (car strings))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (setq strings (cdr strings)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (process-send-string ispell-process "\n")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (accept-process-output ispell-process)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (ispell-sync nil)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (defun ispell-dump ()
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (cond (ispell-dump-needed
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (setq ispell-dump-needed nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (ispell-cmd ":dump"))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (defun ispell-insert (word)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (ispell-cmd ":insert " word)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (if ispell-bad-words
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (setq ispell-recently-accepted (cons word ispell-recently-accepted)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (setq ispell-dump-needed t))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (defun ispell-accept (word)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (ispell-cmd ":accept " word)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (if ispell-bad-words
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (setq ispell-recently-accepted (cons word ispell-recently-accepted))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
199 ;; Return the next message sent by the Ispell subprocess.
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (defun ispell-next-message ()
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (save-excursion
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (set-buffer (process-buffer ispell-process))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (bury-buffer (current-buffer))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (save-restriction
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (goto-char ispell-next-message)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (narrow-to-region (point)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (progn (forward-sexp 1) (point)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (setq ispell-next-message (point))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (goto-char (point-min))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (read (current-buffer)))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (defun ispell-tex-buffer-p ()
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (memq major-mode '(plain-TeX-mode LaTeX-mode)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 214
diff changeset
216 ;;;###autoload
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (defun ispell (&optional buf start end)
671
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
218 "Run Ispell over current buffer's visited file.
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
219 First the file is scanned for misspelled words, then Ispell
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 enters a loop with the following commands for every misspelled word:
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 DIGIT Near miss selector. If the misspelled word is close to
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 some words in the dictionary, they are offered as near misses.
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 r Replace. Replace the word with a string you type. Each word
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 of your new string is also checked.
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3112
diff changeset
226 i Insert. Insert this word in your private dictionary (kept in
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 `$HOME/ispell.words').
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 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
229 but don't put it in your private dictionary.
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 l Lookup. Look for a word in the dictionary by fast binary
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 search, or search for a regular expression in the dictionary
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 using grep.
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 SPACE Accept the word this time, but complain if it is seen again.
214
a1430f8459e5 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 55
diff changeset
234 q, \\[keyboard-quit] Leave the command loop. You can come back later with \\[ispell-next]."
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (interactive)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (if (null start)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (setq start 0))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (if (null end)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (setq end 0))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (if (null buf)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (setq buf (current-buffer)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (setq buf (get-buffer buf))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (if (null buf)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (error "Can't find buffer"))
2837
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
246 ;; 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
247 ;; and a region highlight while in the Ispell loop is distracting.
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
248 (if transient-mark-mode
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
249 (progn
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
250 (setq mark-active nil)
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
251 (run-hooks 'deactivate-mark-hook)))
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (save-excursion
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (set-buffer buf)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (let ((filename buffer-file-name)
2837
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
255 (delete-temp nil))
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (unwind-protect
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (progn
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (cond ((null filename)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (setq filename (make-temp-name "/usr/tmp/ispell"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (setq delete-temp t)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (write-region (point-min) (point-max) filename))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 ((and (buffer-modified-p buf)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (y-or-n-p (format "Save file %s? " filename)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (save-buffer)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (message "Ispell scanning file...")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (if (and ispell-enable-tex-parser
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (ispell-tex-buffer-p))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (ispell-cmd ":tex")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (ispell-cmd ":generic"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (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
271 (if delete-temp
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
272 (condition-case ()
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
273 (delete-file filename)
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
274 (file-error nil)))))
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (message "Parsing ispell output ...")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (ispell-flush-bad-words)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (let (pos bad-words)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (while (numberp (setq pos (ispell-next-message)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 ;;ispell may check the words on the line following the end
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 ;;of the region - therefore, don't record anything out of range
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (if (or (= end 0)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (< pos end))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (setq bad-words (cons (set-marker (make-marker) (+ pos 1))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 bad-words))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (setq bad-words (cons pos bad-words))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (setq ispell-bad-words (nreverse bad-words))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (cond ((not (markerp (car ispell-bad-words)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (setq ispell-bad-words nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (message "No misspellings."))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (t
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (message "Ispell parsing done.")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (ispell-next))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293
316
ba0e7d5a44ad *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 256
diff changeset
294 ;;;###autoload
2571
b65cf676a09b All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
295 (defalias 'ispell-buffer 'ispell)
316
ba0e7d5a44ad *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 256
diff changeset
296
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (defun ispell-next ()
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
298 "Resume command loop for most recent Ispell command."
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (interactive)
2837
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
300 (setq ispell-window-configuration nil)
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (unwind-protect
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (catch 'quit
2837
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
303 ;; 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
304 ;; 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
305 ;; when you type q.
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
306 (let (next)
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
307 (while (markerp (setq next (car ispell-bad-words)))
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
308 (switch-to-buffer (marker-buffer next))
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
309 (push-mark)
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
310 (ispell-point next "at saved position.")
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
311 (setq ispell-bad-words (cdr ispell-bad-words))
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
312 (set-marker next nil))))
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
313 (if ispell-window-configuration
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
314 (set-window-configuration ispell-window-configuration))
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (cond ((null ispell-bad-words)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (error "Ispell has not yet been run."))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 ((markerp (car ispell-bad-words))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (message (substitute-command-keys
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 "Type \\[ispell-next] to continue.")))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 ((eq (car ispell-bad-words) nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (setq ispell-bad-words nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (message "No more misspellings (but checker was interrupted.)"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 ((eq (car ispell-bad-words) t)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (setq ispell-bad-words nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (message "Ispell done."))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (t
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (setq ispell-bad-words nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (message "Bad ispell internal list"))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (ispell-dump))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 214
diff changeset
331 ;;;###autoload
671
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
332 (defun ispell-word (&optional resume)
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 "Check the spelling of the word under the cursor.
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
334 See the command `ispell' for more information.
671
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
335 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
336 (interactive "P")
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
337 (if resume
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
338 (ispell-next)
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
339 (condition-case err
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
340 (catch 'quit
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
341 (save-window-excursion
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
342 (ispell-point (point) "at point."))
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
343 (ispell-dump))
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
344 (ispell-startup-error
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
345 (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
346 (load-library "spell")
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
347 (define-key esc-map "$" 'spell-word)
21d23fa6fa2a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
348 (spell-word)))))))
316
ba0e7d5a44ad *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 256
diff changeset
349 ;;;###autoload
ba0e7d5a44ad *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 256
diff changeset
350 (define-key esc-map "$" 'ispell-word)
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 214
diff changeset
352 ;;;###autoload
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (defun ispell-region (start &optional end)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 "Check the spelling for all of the words in the region."
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (interactive "r")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (ispell (current-buffer) start end))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (defun ispell-letterp (c)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 (and c
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (or (and (>= c ?A) (<= c ?Z))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (and (>= c ?a) (<= c ?z))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (>= c 128))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (defun ispell-letter-or-quotep (c)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (and c
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (or (and (>= c ?A) (<= c ?Z))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (and (>= c ?a) (<= c ?z))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (= c ?')
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (>= c 128))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (defun ispell-find-word-start ()
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 ;;backward to a letter
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (if (not (ispell-letterp (char-after (point))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (while (and (not (bobp))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (not (ispell-letterp (char-after (- (point) 1)))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (backward-char)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 ;;backward to beginning of word
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (while (ispell-letter-or-quotep (char-after (- (point) 1)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (backward-char))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (skip-chars-forward "'"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (defun ispell-find-word-end ()
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (while (ispell-letter-or-quotep (char-after (point)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (forward-char))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (skip-chars-backward "'"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (defun ispell-next-word ()
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (while (and (not (eobp))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (not (ispell-letterp (char-after (point)))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (forward-char)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 ;if end is nil, then do one word at start
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 ;otherwise, do all words from the beginning of the word where
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 ;start points, to the end of the word where end points
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (defun ispell-point (start message)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (let ((wend (make-marker))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 rescan
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 end)
2837
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
399 ;; 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
400 ;; 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
401 ;; when you type q.
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (goto-char start)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (ispell-find-word-start) ;find correct word start
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (setq start (point-marker))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (ispell-find-word-end) ;now find correct end
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (setq end (point-marker))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (if (>= start end)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (error "No word %s" message))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (while (< start end)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (goto-char start)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (ispell-find-word-end) ;find end of current word
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 ;could be before 'end' if
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 ;user typed replacement
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 ;that is more than one word
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (set-marker wend (point))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (setq rescan nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (setq word (buffer-substring start wend))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (cond ((ispell-still-bad word)
2837
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
419 ;;; This just causes confusion. -- rms.
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
420 ;;; (goto-char start)
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
421 ;;; (sit-for 0)
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (message (format "Ispell checking %s" word))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (ispell-cmd word)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (let ((message (ispell-next-message)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (cond ((eq message t)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (message "%s: ok" word))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 ((or (null message)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (consp message))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (setq rescan
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (ispell-command-loop word start wend message)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (t
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (error "unknown ispell response %s" message))))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (cond ((null rescan)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (goto-char wend)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (ispell-next-word)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (set-marker start (point)))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 ;;clear the choices buffer; otherwise it's hard for the user to tell
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 ;;when we get back to the command loop
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (let ((buf (get-buffer "*ispell choices*")))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (cond (buf
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (set-buffer buf)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (erase-buffer))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (set-marker start nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (set-marker end nil)
2837
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
445 (set-marker wend nil)))
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (defun ispell-still-bad (word)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (let ((words ispell-recently-accepted)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (ret t)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (case-fold-search t))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 (while words
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 (cond ((eq (string-match (car words) word) 0)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 (setq ret nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (setq words nil)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 (setq words (cdr words)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 ret))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (defun ispell-show-choices (word message first-line)
778
cd00bdacc17b *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 671
diff changeset
459 ;;if there is only one window on the frame, make the ispell
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 ;;messages winow be small. otherwise just use the other window
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (let* ((selwin (selected-window))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 (resize (eq selwin (next-window)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (buf (get-buffer-create "*ispell choices*"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 w)
2837
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
465 (or ispell-window-configuration
00f822101e49 (ispell): Deactivate mark before the Ispell run.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
466 (setq ispell-window-configuration (current-window-configuration)))
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (setq w (display-buffer buf))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 (buffer-disable-undo buf)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (if resize
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (unwind-protect
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (progn
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (select-window w)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (enlarge-window (- 6 (window-height w))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (select-window selwin)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (save-excursion
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (set-buffer buf)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (bury-buffer buf)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (set-window-point w (point-min))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (set-window-start w (point-min))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (erase-buffer)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (insert first-line "\n")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (insert
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 "SPC skip; A accept; I insert; DIGIT select; R replace; \
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 L lookup; Q quit\n")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (cond ((not (null message))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (let ((i 0))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (while (< i 3)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (let ((j 0))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (while (< j 3)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (let* ((n (+ (* j 3) i))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (choice (nth n message)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (cond (choice
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (let ((str (format "%d %s" n choice)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (insert str)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (insert-char ? (- 20 (length str)))))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (setq j (+ j 1))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (insert "\n")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (setq i (+ i 1)))))))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (defun ispell-command-loop (word start end message)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (let ((flag t)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (rescan nil)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 first-line)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (if (null message)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (setq first-line (concat "No near misses for '" word "'"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 (setq first-line (concat "Near misses for '" word "'")))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (while flag
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (ispell-show-choices word message first-line)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (message "Ispell command: ")
2888
e931a98b2f36 (ispell-command-loop): Make an undo boundary.
Richard M. Stallman <rms@gnu.org>
parents: 2837
diff changeset
510 (undo-boundary)
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (let ((c (downcase (read-char)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 replacement)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (cond ((and (>= c ?0)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (<= c ?9)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (setq replacement (nth (- c ?0) message)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (ispell-replace start end replacement)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (setq flag nil))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 ((= c ?q)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (throw 'quit nil))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 ((= c ? )
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (setq flag nil))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 ((= c ?r)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 (ispell-replace start end (read-string "Replacement: "))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 (setq rescan t)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 (setq flag nil))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 ((= c ?i)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 (ispell-insert word)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (setq flag nil))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 ((= c ?a)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 (ispell-accept word)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (setq flag nil))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 ((= c ?l)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 (let ((val (ispell-do-look word)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 (setq first-line (car val))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 (setq message (cdr val))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 ((= c ??)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 (message
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 "Type 'C-h d ispell' to the emacs main loop for more help")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (sit-for 2))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (t
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 (message "Bad ispell command")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 (sit-for 2)))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 rescan))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (defun ispell-do-look (bad-word)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (let (regex buf words)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 (cond ((null ispell-have-new-look)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 (setq regex (read-string "Lookup: ")))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (t
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (setq regex (read-string "Lookup (regex): " "^"))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (setq buf (get-buffer-create "*ispell look*"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (save-excursion
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (set-buffer buf)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (delete-region (point-min) (point-max))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 (if ispell-have-new-look
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (call-process "look" nil buf nil "-r" regex)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (call-process "look" nil buf nil regex))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 (goto-char (point-min))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (forward-line 10)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (delete-region (point) (point-max))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (goto-char (point-min))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (while (not (= (point-min) (point-max)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (end-of-line)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (setq words (cons (buffer-substring (point-min) (point)) words))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (forward-line)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (delete-region (point-min) (point)))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (kill-buffer buf)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 (cons (format "Lookup '%s'" regex)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (reverse words)))))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 (defun ispell-replace (start end new)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (goto-char start)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (insert new)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 (delete-region (point) end))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 (defun reload-ispell ()
3623
739ba36097c9 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
577 "Tell Ispell to re-read your private dictionary."
55
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (interactive)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (ispell-cmd ":reload"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (defun batch-make-ispell ()
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (byte-compile-file "ispell.el")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (find-file "ispell.texinfo")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (let ((old-dir default-directory)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (default-directory "/tmp"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 (texinfo-format-buffer))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (Info-validate)
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (if (get-buffer " *problems in info file*")
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 (kill-emacs 1))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 (write-region (point-min) (point-max) "ispell.info"))
5652ba2db1a7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591
3112
6b8a9fb0537c Provide `ispell'.
Richard M. Stallman <rms@gnu.org>
parents: 2888
diff changeset
592 (provide 'ispell)
6b8a9fb0537c Provide `ispell'.
Richard M. Stallman <rms@gnu.org>
parents: 2888
diff changeset
593
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 317
diff changeset
594 ;;; ispell.el ends here