annotate lisp/textmodes/=ispell4.el @ 19520:6496595d79b8

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