annotate lisp/textmodes/=ispell4.el @ 1444:559d2f2119aa

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