Mercurial > emacs
annotate lisp/textmodes/flyspell.el @ 25216:40dc181e545b
Initial revision
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 10 Aug 1999 13:33:49 +0000 |
parents | 59585a4135a6 |
children | d40d47971e6b |
rev | line source |
---|---|
22611 | 1 ;;; flyspell.el --- On-the-fly spell checker |
2 | |
3 ;; Copyright (C) 1998 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Manuel Serrano <Manuel.Serrano@unice.fr> | |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
6 ;; Keywords: convenience |
22611 | 7 |
8 ;;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; commentary: | |
26 ;; | |
27 ;; Flyspell is a minor Emacs mode performing on-the-fly spelling | |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
28 ;; checking. |
22611 | 29 ;; |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
30 ;; To enable Flyspell minor mode, type Meta-x flyspell-mode. |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
31 ;; This applies only to the current buffer. |
22611 | 32 ;; |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
33 ;; Note: consider setting the variable ispell-parser to `tex' to |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
34 ;; avoid TeX command checking; use `(setq ispell-parser 'tex)' |
22611 | 35 ;; _before_ entering flyspell. |
36 ;; | |
37 ;; Some user variables control the behavior of flyspell. They are | |
38 ;; those defined under the `User variables' comment. | |
39 ;; | |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
40 ;; Note: as suggested by Yaron M. Minsky, if you use flyspell when |
22611 | 41 ;; sending mails, you should add the following: |
42 ;; (add-hook 'mail-send-hook 'flyspell-mode-off) | |
43 | |
44 ;;; Code: | |
45 (require 'ispell) | |
46 | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
47 ;*---------------------------------------------------------------------*/ |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
48 ;* Group ... */ |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
49 ;*---------------------------------------------------------------------*/ |
22611 | 50 (defgroup flyspell nil |
51 "Spellchecking on the fly." | |
52 :tag "FlySpell" | |
53 :prefix "flyspell-" | |
22648
3b7f1e026beb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
22612
diff
changeset
|
54 :group 'processes |
3b7f1e026beb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
22612
diff
changeset
|
55 :version "20.3") |
22611 | 56 |
57 ;*---------------------------------------------------------------------*/ | |
58 ;* User variables ... */ | |
59 ;*---------------------------------------------------------------------*/ | |
60 (defcustom flyspell-highlight-flag t | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
61 "*How Flyspell should indicate misspelled words. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
62 Non-nil means use highlight, nil means use minibuffer messages." |
22611 | 63 :group 'flyspell |
64 :type 'boolean) | |
65 | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
66 (defcustom flyspell-mark-duplications-flag t |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
67 "*Non-nil means Flyspell reports a repeated word as an error." |
22611 | 68 :group 'flyspell |
69 :type 'boolean) | |
70 | |
71 (defcustom flyspell-sort-corrections t | |
72 "*Non-nil means, sort the corrections alphabetically before popping them." | |
73 :group 'flyspell | |
74 :type 'boolean) | |
75 | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
76 (defcustom flyspell-duplicate-distance 10000 |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
77 "*The maximum distance for finding duplicates of unrecognized words. |
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
78 This applies to the feature that when a word is not found in the dictionary, |
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
79 if the same spelling occurs elsewhere in the buffer, |
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
80 Flyspell uses a different face (`flyspell-duplicate-face') to highlight it. |
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
81 This variable specifies how far to search to find such a duplicate. |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
82 -1 means no limit (search the whole buffer). |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
83 0 means do not search for duplicate unrecognized spellings." |
22611 | 84 :group 'flyspell |
85 :type 'number) | |
86 | |
87 (defcustom flyspell-delay 3 | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
88 "*The number of seconds to wait before checking, after a \"delayed\" command." |
22611 | 89 :group 'flyspell |
90 :type 'number) | |
91 | |
92 (defcustom flyspell-persistent-highlight t | |
22946
cfde96067373
(flyspell-persistent-highlight): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
22891
diff
changeset
|
93 "*Non-nil means misspelled words remain highlighted until corrected. |
cfde96067373
(flyspell-persistent-highlight): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
22891
diff
changeset
|
94 If this variable is nil, only the most recently detected misspelled word |
cfde96067373
(flyspell-persistent-highlight): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
22891
diff
changeset
|
95 is highlighted." |
22611 | 96 :group 'flyspell |
97 :type 'boolean) | |
98 | |
99 (defcustom flyspell-highlight-properties t | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
100 "*Non-nil means highlight incorrect words even if a property exists for this word." |
22611 | 101 :group 'flyspell |
102 :type 'boolean) | |
103 | |
104 (defcustom flyspell-default-delayed-commands | |
105 '(self-insert-command | |
106 delete-backward-char | |
107 delete-char) | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
108 "The standard list of delayed commands for Flyspell. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
109 See `flyspell-delayed-commands'." |
22611 | 110 :group 'flyspell |
111 :type '(repeat (symbol))) | |
112 | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
113 (defcustom flyspell-delayed-commands nil |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
114 "List of commands that are \"delayed\" for Flyspell mode. |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
115 After these commands, Flyspell checking is delayed for a short time, |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
116 whose length is specified by `flyspell-delay'." |
22611 | 117 :group 'flyspell |
118 :type '(repeat (symbol))) | |
119 | |
120 (defcustom flyspell-issue-welcome-flag t | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
121 "*Non-nil means that Flyspell should display a welcome message when started." |
22611 | 122 :group 'flyspell |
123 :type 'boolean) | |
124 | |
125 (defcustom flyspell-consider-dash-as-word-delimiter-flag nil | |
126 "*Non-nil means that the `-' char is considered as a word delimiter." | |
127 :group 'flyspell | |
128 :type 'boolean) | |
129 | |
130 (defcustom flyspell-incorrect-hook nil | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
131 "*List of functions to be called when incorrect words are encountered. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
132 Each function is given two arguments: the beginning and the end |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
133 of the incorrect region." |
22611 | 134 :group 'flyspell) |
135 | |
23179
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
136 (defcustom flyspell-multi-language-p nil |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
137 "*Non-nil means that Flyspell can be used with multiple languages. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
138 This mode works by starting a separate Ispell process for each buffer, |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
139 so that each buffer can use its own language." |
22611 | 140 :group 'flyspell |
141 :type 'boolean) | |
142 | |
143 ;*---------------------------------------------------------------------*/ | |
144 ;* Mode specific options */ | |
145 ;* ------------------------------------------------------------- */ | |
146 ;* Mode specific options enable users to disable flyspell on */ | |
147 ;* certain word depending of the emacs mode. For instance, when */ | |
148 ;* using flyspell with mail-mode add the following expression */ | |
149 ;* in your .emacs file: */ | |
150 ;* (add-hook 'mail-mode */ | |
151 ;* '(lambda () (setq flyspell-generic-check-word-p */ | |
152 ;* 'mail-mode-flyspell-verify))) */ | |
153 ;*---------------------------------------------------------------------*/ | |
154 (defvar flyspell-generic-check-word-p nil | |
155 "Function providing per-mode customization over which words are flyspelled. | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
156 Returns t to continue checking, nil otherwise. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
157 Flyspell mode sets this variable to whatever is the `flyspell-mode-predicate' |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
158 property of the major mode name.") |
22611 | 159 (make-variable-buffer-local 'flyspell-generic-check-word-p) |
160 | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
161 (put 'mail-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify) |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
162 (put 'message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify) |
22611 | 163 (defun mail-mode-flyspell-verify () |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
164 "This function is used for `flyspell-generic-check-word-p' in Mail mode." |
22611 | 165 (save-excursion |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
166 (or (progn |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
167 (beginning-of-line) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
168 (looking-at "Subject:")) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
169 (not (or (re-search-forward mail-header-separator nil t) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
170 (re-search-backward message-signature-separator nil t) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
171 (progn |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
172 (beginning-of-line) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
173 (looking-at "[>}|]"))))))) |
22611 | 174 |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
175 (put 'texinfo-mode 'flyspell-mode-predicate 'texinfo-mode-flyspell-verify) |
22611 | 176 (defun texinfo-mode-flyspell-verify () |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
177 "This function is used for `flyspell-generic-check-word-p' in Texinfo mode." |
22611 | 178 (save-excursion |
179 (forward-word -1) | |
180 (not (looking-at "@")))) | |
181 | |
182 ;*---------------------------------------------------------------------*/ | |
183 ;* Overlay compatibility */ | |
184 ;*---------------------------------------------------------------------*/ | |
185 (autoload 'make-overlay "overlay" "" t) | |
186 (autoload 'move-overlay "overlay" "" t) | |
187 (autoload 'overlayp "overlay" "" t) | |
188 (autoload 'overlay-properties "overlay" "" t) | |
189 (autoload 'overlays-in "overlay" "" t) | |
190 (autoload 'delete-overlay "overlay" "" t) | |
191 (autoload 'overlays-at "overlay" "" t) | |
192 (autoload 'overlay-put "overlay" "" t) | |
193 (autoload 'overlay-get "overlay" "" t) | |
194 | |
195 ;*---------------------------------------------------------------------*/ | |
196 ;* Which emacs are we currently running */ | |
197 ;*---------------------------------------------------------------------*/ | |
198 (defvar flyspell-emacs | |
199 (cond | |
200 ((string-match "XEmacs" emacs-version) | |
201 'xemacs) | |
202 (t | |
203 'emacs)) | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
204 "The type of Emacs we are currently running.") |
22611 | 205 |
23943
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
206 (defvar flyspell-use-local-map |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
207 (or (eq flyspell-emacs 'xemacs) |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
208 (not (string< emacs-version "20")))) |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
209 |
22611 | 210 ;*---------------------------------------------------------------------*/ |
211 ;* The minor mode declaration. */ | |
212 ;*---------------------------------------------------------------------*/ | |
213 (defvar flyspell-mode nil) | |
214 (make-variable-buffer-local 'flyspell-mode) | |
215 | |
216 (defvar flyspell-mode-map (make-sparse-keymap)) | |
217 (defvar flyspell-mouse-map (make-sparse-keymap)) | |
218 | |
219 (or (assoc 'flyspell-mode minor-mode-alist) | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
220 (setq minor-mode-alist |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
221 (cons '(flyspell-mode " Fly") minor-mode-alist))) |
22611 | 222 |
23943
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
223 ;; mouse or local-map bindings |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
224 (cond |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
225 ((eq flyspell-emacs 'xemacs) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
226 (define-key flyspell-mouse-map [(button2)] |
23943
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
227 (function flyspell-correct-word/mouse-keymap)) |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
228 (define-key flyspell-mouse-map "\M-\t" 'flyspell-auto-correct-word)) |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
229 (flyspell-use-local-map |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
230 (define-key flyspell-mouse-map [(mouse-2)] |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
231 (function flyspell-correct-word/mouse-keymap)) |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
232 (define-key flyspell-mouse-map "\M-\t" 'flyspell-auto-correct-word)) |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
233 (t |
23943
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
234 (or (assoc 'flyspell-mode minor-mode-map-alist) |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
235 (setq minor-mode-map-alist |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
236 (cons (cons 'flyspell-mode flyspell-mode-map) |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
237 minor-mode-map-alist))) |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
238 (define-key flyspell-mode-map "\M-\t" 'flyspell-auto-correct-word) |
22611 | 239 (define-key flyspell-mode-map [(mouse-2)] |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
240 (function flyspell-correct-word/local-keymap)))) |
22611 | 241 |
242 ;; the name of the overlay property that defines the keymap | |
243 (defvar flyspell-overlay-keymap-property-name | |
244 (if (string-match "19.*XEmacs" emacs-version) | |
245 'keymap | |
246 'local-map)) | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
247 |
22611 | 248 ;*---------------------------------------------------------------------*/ |
249 ;* Highlighting */ | |
250 ;*---------------------------------------------------------------------*/ | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
251 (defface flyspell-incorrect-face |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
252 '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
253 (t (:bold t))) |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
254 "Face used for marking a misspelled word in Flyspell." |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
255 :group 'flyspell) |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
256 |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
257 (defface flyspell-duplicate-face |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
258 '((((class color)) (:foreground "Gold3" :bold t :underline t)) |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
259 (t (:bold t))) |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
260 "Face used for marking a misspelled word that appears twice in the buffer. |
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
261 See also `flyspell-duplicate-distance'." |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
262 :group 'flyspell) |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
263 |
22611 | 264 (defvar flyspell-overlay nil) |
265 | |
266 ;*---------------------------------------------------------------------*/ | |
267 ;* flyspell-mode ... */ | |
268 ;*---------------------------------------------------------------------*/ | |
269 ;;;###autoload | |
270 (defun flyspell-mode (&optional arg) | |
271 "Minor mode performing on-the-fly spelling checking. | |
272 Ispell is automatically spawned on background for each entered words. | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
273 The default flyspell behavior is to highlight incorrect words. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
274 With no argument, this command toggles Flyspell mode. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
275 With a prefix argument ARG, turn Flyspell minor mode on iff ARG is positive. |
22611 | 276 |
277 Bindings: | |
278 \\[ispell-word]: correct words (using Ispell). | |
279 \\[flyspell-auto-correct-word]: automatically correct word. | |
280 \\[flyspell-correct-word] (or mouse-2): popup correct words. | |
281 | |
282 Hooks: | |
23234 | 283 flyspell-mode-hook is run after flyspell is entered. |
22611 | 284 |
285 Remark: | |
286 `flyspell-mode' uses `ispell-mode'. Thus all Ispell options are | |
287 valid. For instance, a personal dictionary can be used by | |
288 invoking `ispell-change-dictionary'. | |
289 | |
290 Consider using the `ispell-parser' to check your text. For instance | |
291 consider adding: | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
292 \(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex)))) |
22611 | 293 in your .emacs file. |
294 | |
295 flyspell-region checks all words inside a region. | |
296 | |
297 flyspell-buffer checks the whole buffer." | |
298 (interactive "P") | |
23179
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
299 (let ((old-flyspell-mode flyspell-mode)) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
300 ;; Mark the mode as on or off. |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
301 (setq flyspell-mode (not (or (and (null arg) flyspell-mode) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
302 (<= (prefix-numeric-value arg) 0)))) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
303 ;; Do the real work. |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
304 (unless (eq flyspell-mode old-flyspell-mode) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
305 (if flyspell-mode |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
306 (flyspell-mode-on) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
307 (flyspell-mode-off)) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
308 ;; Force modeline redisplay. |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
309 (set-buffer-modified-p (buffer-modified-p))))) |
22611 | 310 |
311 ;*---------------------------------------------------------------------*/ | |
312 ;* flyspell-mode-on ... */ | |
313 ;*---------------------------------------------------------------------*/ | |
314 (defun flyspell-mode-on () | |
23234 | 315 "Turn Flyspell mode on. Do not use this; use `flyspell-mode' instead." |
22611 | 316 (setq ispell-highlight-face 'flyspell-incorrect-face) |
317 ;; ispell initialization | |
318 (if flyspell-multi-language-p | |
319 (progn | |
320 (make-variable-buffer-local 'ispell-dictionary) | |
321 (make-variable-buffer-local 'ispell-process) | |
322 (make-variable-buffer-local 'ispell-filter) | |
323 (make-variable-buffer-local 'ispell-filter-continue) | |
324 (make-variable-buffer-local 'ispell-process-directory) | |
23234 | 325 (make-variable-buffer-local 'ispell-parser) |
326 (put 'ispell-dictionary 'permanent-local t) | |
327 (put 'ispell-process 'permanent-local t) | |
328 (put 'ispell-filter 'permanent-local t) | |
329 (put 'ispell-filter-continue 'permanent-local t) | |
330 (put 'ispell-process-directory 'permanent-local t) | |
331 (put 'ispell-parser 'permanent-local t))) | |
23788
764497f1c6a0
(flyspell-check-word-p): Don't delay inside a kbd macro.
Richard M. Stallman <rms@gnu.org>
parents:
23234
diff
changeset
|
332 ;; We put the `flyspell-delayed' property on some commands. |
22611 | 333 (flyspell-delay-commands) |
334 ;; we bound flyspell action to post-command hook | |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
335 (make-local-hook 'post-command-hook) |
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
336 (add-hook 'post-command-hook (function flyspell-post-command-hook) t t) |
22611 | 337 ;; we bound flyspell action to pre-command hook |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
338 (make-local-hook 'pre-command-hook) |
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
339 (add-hook 'pre-command-hook (function flyspell-pre-command-hook) t t) |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
340 |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
341 ;; Set flyspell-generic-check-word-p based on the major mode. |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
342 (let ((mode-predicate (get major-mode 'flyspell-mode-predicate))) |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
343 (if mode-predicate |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
344 (setq flyspell-generic-check-word-p mode-predicate))) |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
345 |
22611 | 346 ;; the welcome message |
347 (if flyspell-issue-welcome-flag | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
348 (let ((binding (where-is-internal 'flyspell-auto-correct-word |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
349 nil 'non-ascii))) |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
350 (message |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
351 (if binding |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
352 (format "Welcome to flyspell. Use %s or Mouse-2 to correct words." |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
353 (key-description binding)) |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
354 "Welcome to flyspell. Use Mouse-2 to correct words.")))) |
22611 | 355 ;; we have to kill the flyspell process when the buffer is deleted. |
356 ;; (thanks to Jeff Miller and Roland Rosenfeld who sent me this | |
357 ;; improvement). | |
358 (add-hook 'kill-buffer-hook | |
359 '(lambda () | |
23233
b31869394e03
(flyspell-mode-on): fix kill-buffer-hook
Karl Heuer <kwzh@gnu.org>
parents:
23179
diff
changeset
|
360 (if (and flyspell-multi-language-p ispell-process) |
b31869394e03
(flyspell-mode-on): fix kill-buffer-hook
Karl Heuer <kwzh@gnu.org>
parents:
23179
diff
changeset
|
361 (ispell-kill-ispell t)))) |
24458 | 362 (make-local-hook 'change-major-mode-hook) |
363 (add-hook 'change-major-mode-hook 'flyspell-mode-off) | |
22611 | 364 ;; we end with the flyspell hooks |
365 (run-hooks 'flyspell-mode-hook)) | |
366 | |
367 ;*---------------------------------------------------------------------*/ | |
368 ;* flyspell-delay-commands ... */ | |
369 ;*---------------------------------------------------------------------*/ | |
370 (defun flyspell-delay-commands () | |
23234 | 371 "Install the standard set of Flyspell delayed commands." |
22611 | 372 (mapcar 'flyspell-delay-command flyspell-default-delayed-commands) |
373 (mapcar 'flyspell-delay-command flyspell-delayed-commands)) | |
374 | |
375 ;*---------------------------------------------------------------------*/ | |
376 ;* flyspell-delay-command ... */ | |
377 ;*---------------------------------------------------------------------*/ | |
378 (defun flyspell-delay-command (command) | |
23234 | 379 "Set COMMAND to be delayed, for Flyspell. |
22611 | 380 When flyspell `post-command-hook' is invoked because a delayed command |
381 as been used the current word is not immediatly checked. | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
382 It will be checked only after `flyspell-delay' seconds." |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
383 (interactive "SDelay Flyspell after Command: ") |
22611 | 384 (put command 'flyspell-delayed t)) |
385 | |
386 ;*---------------------------------------------------------------------*/ | |
387 ;* flyspell-ignore-commands ... */ | |
388 ;*---------------------------------------------------------------------*/ | |
389 (defun flyspell-ignore-commands () | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
390 "This is an obsolete function, use `flyspell-delay-commands' instead." |
22611 | 391 (flyspell-delay-commands)) |
392 | |
393 ;*---------------------------------------------------------------------*/ | |
394 ;* flyspell-ignore-command ... */ | |
395 ;*---------------------------------------------------------------------*/ | |
396 (defun flyspell-ignore-command (command) | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
397 "This is an obsolete function, use `flyspell-delay-command' instead. |
22611 | 398 COMMAND is the name of the command to be delayed." |
399 (flyspell-delay-command command)) | |
400 | |
401 (make-obsolete 'flyspell-ignore-commands 'flyspell-delay-commands) | |
402 (make-obsolete 'flyspell-ignore-command 'flyspell-delay-command) | |
403 | |
404 ;*---------------------------------------------------------------------*/ | |
405 ;* flyspell-word-cache ... */ | |
406 ;*---------------------------------------------------------------------*/ | |
407 (defvar flyspell-word-cache-start nil) | |
408 (defvar flyspell-word-cache-end nil) | |
409 (defvar flyspell-word-cache-word nil) | |
410 (make-variable-buffer-local 'flyspell-word-cache-start) | |
411 (make-variable-buffer-local 'flyspell-word-cache-end) | |
412 (make-variable-buffer-local 'flyspell-word-cache-word) | |
413 | |
414 ;*---------------------------------------------------------------------*/ | |
415 ;* The flyspell pre-hook, store the current position. In the */ | |
416 ;* post command hook, we will check, if the word at this position */ | |
417 ;* has to be spell checked. */ | |
418 ;*---------------------------------------------------------------------*/ | |
419 (defvar flyspell-pre-buffer nil) | |
420 (defvar flyspell-pre-point nil) | |
421 | |
422 ;*---------------------------------------------------------------------*/ | |
423 ;* flyspell-pre-command-hook ... */ | |
424 ;*---------------------------------------------------------------------*/ | |
425 (defun flyspell-pre-command-hook () | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
426 "Save the current buffer and point for Flyspell's post-command hook." |
22611 | 427 (interactive) |
428 (setq flyspell-pre-buffer (current-buffer)) | |
429 (setq flyspell-pre-point (point))) | |
430 | |
431 ;*---------------------------------------------------------------------*/ | |
432 ;* flyspell-mode-off ... */ | |
433 ;*---------------------------------------------------------------------*/ | |
23234 | 434 ;;;###autoload |
22611 | 435 (defun flyspell-mode-off () |
23234 | 436 "Turn Flyspell mode off." |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
437 ;; If we have an Ispell process for each buffer, |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
438 ;; kill the one for this buffer. |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
439 (if flyspell-multi-language-p |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
440 (ispell-kill-ispell t)) |
22611 | 441 ;; we remove the hooks |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
442 (remove-hook 'post-command-hook (function flyspell-post-command-hook) t) |
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
443 (remove-hook 'pre-command-hook (function flyspell-pre-command-hook) t) |
22611 | 444 ;; we remove all the flyspell hilightings |
445 (flyspell-delete-all-overlays) | |
446 ;; we have to erase pre cache variables | |
447 (setq flyspell-pre-buffer nil) | |
448 (setq flyspell-pre-point nil) | |
449 ;; we mark the mode as killed | |
450 (setq flyspell-mode nil)) | |
451 | |
452 ;*---------------------------------------------------------------------*/ | |
453 ;* flyspell-check-word-p ... */ | |
454 ;*---------------------------------------------------------------------*/ | |
455 (defun flyspell-check-word-p () | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
456 "Return t when the word at `point' has to be checked. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
457 The answer depends of several criteria. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
458 Mostly we check word delimiters." |
22611 | 459 (cond |
460 ((<= (- (point-max) 1) (point-min)) | |
461 ;; the buffer is not filled enough | |
462 nil) | |
463 ((not (and (symbolp this-command) (get this-command 'flyspell-delayed))) | |
464 ;; the current command is not delayed, that | |
465 ;; is that we must check the word now | |
466 t) | |
467 ((and (> (point) (point-min)) | |
468 (save-excursion | |
469 (backward-char 1) | |
470 (and (looking-at (flyspell-get-not-casechars)) | |
471 (or flyspell-consider-dash-as-word-delimiter-flag | |
472 (not (looking-at "\\-")))))) | |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
473 ;; yes because we have reached or typed a word delimiter. |
22611 | 474 t) |
475 ((not (integerp flyspell-delay)) | |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
476 ;; yes because the user had set up a no-delay configuration. |
22611 | 477 t) |
23788
764497f1c6a0
(flyspell-check-word-p): Don't delay inside a kbd macro.
Richard M. Stallman <rms@gnu.org>
parents:
23234
diff
changeset
|
478 (executing-kbd-macro |
764497f1c6a0
(flyspell-check-word-p): Don't delay inside a kbd macro.
Richard M. Stallman <rms@gnu.org>
parents:
23234
diff
changeset
|
479 ;; Don't delay inside a keyboard macro. |
764497f1c6a0
(flyspell-check-word-p): Don't delay inside a kbd macro.
Richard M. Stallman <rms@gnu.org>
parents:
23234
diff
changeset
|
480 t) |
22611 | 481 (t |
482 (if (fboundp 'about-xemacs) | |
483 (sit-for flyspell-delay nil) | |
484 (sit-for flyspell-delay 0 nil))))) | |
485 | |
486 ;*---------------------------------------------------------------------*/ | |
487 ;* flyspell-check-pre-word-p ... */ | |
488 ;*---------------------------------------------------------------------*/ | |
489 (defun flyspell-check-pre-word-p () | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
490 "Return non-nil if we should to check the word before point. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
491 More precisely, it applies to the word that was before point |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
492 before the current command." |
22611 | 493 (cond |
494 ((or (not (numberp flyspell-pre-point)) | |
495 (not (bufferp flyspell-pre-buffer)) | |
496 (not (buffer-live-p flyspell-pre-buffer))) | |
497 nil) | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
498 ((or (and (= flyspell-pre-point (- (point) 1)) |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
499 (eq (char-syntax (char-after flyspell-pre-point)) ?w)) |
22611 | 500 (= flyspell-pre-point (point)) |
501 (= flyspell-pre-point (+ (point) 1))) | |
502 nil) | |
503 ((not (eq (current-buffer) flyspell-pre-buffer)) | |
504 t) | |
505 ((not (and (numberp flyspell-word-cache-start) | |
506 (numberp flyspell-word-cache-end))) | |
507 t) | |
508 (t | |
509 (or (< flyspell-pre-point flyspell-word-cache-start) | |
510 (> flyspell-pre-point flyspell-word-cache-end))))) | |
511 | |
512 ;*---------------------------------------------------------------------*/ | |
513 ;* flyspell-post-command-hook ... */ | |
514 ;*---------------------------------------------------------------------*/ | |
515 (defun flyspell-post-command-hook () | |
516 "The `post-command-hook' used by flyspell to check a word in-the-fly." | |
517 (interactive) | |
518 (if (flyspell-check-word-p) | |
519 (flyspell-word)) | |
520 (if (flyspell-check-pre-word-p) | |
521 (save-excursion | |
522 (set-buffer flyspell-pre-buffer) | |
523 (save-excursion | |
524 (goto-char flyspell-pre-point) | |
525 (flyspell-word))))) | |
526 | |
527 ;*---------------------------------------------------------------------*/ | |
528 ;* flyspell-word ... */ | |
529 ;*---------------------------------------------------------------------*/ | |
530 (defun flyspell-word (&optional following) | |
531 "Spell check a word." | |
532 (interactive (list current-prefix-arg)) | |
533 (if (interactive-p) | |
534 (setq following ispell-following-word)) | |
535 (save-excursion | |
536 (ispell-accept-buffer-local-defs) ; use the correct dictionary | |
537 (let ((cursor-location (point)) ; retain cursor location | |
538 (word (flyspell-get-word following)) | |
539 start end poss) | |
540 (if (or (eq word nil) | |
541 (and (fboundp flyspell-generic-check-word-p) | |
542 (not (funcall flyspell-generic-check-word-p)))) | |
543 t | |
544 (progn | |
545 ;; destructure return word info list. | |
546 (setq start (car (cdr word)) | |
547 end (car (cdr (cdr word))) | |
548 word (car word)) | |
549 ;; before checking in the directory, we check for doublons. | |
550 (cond | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
551 ((and flyspell-mark-duplications-flag |
22611 | 552 (save-excursion |
553 (goto-char start) | |
554 (word-search-backward word | |
555 (- start | |
556 (+ 1 (- end start))) | |
557 t))) | |
558 ;; yes, this is a doublon | |
559 (flyspell-highlight-incorrect-region start end)) | |
560 ((and (eq flyspell-word-cache-start start) | |
561 (eq flyspell-word-cache-end end) | |
562 (string-equal flyspell-word-cache-word word)) | |
563 ;; this word had been already checked, we skip | |
564 nil) | |
565 ((and (eq ispell-parser 'tex) | |
566 (flyspell-tex-command-p word)) | |
567 ;; this is a correct word (because a tex command) | |
568 (flyspell-unhighlight-at start) | |
569 (if (> end start) | |
570 (flyspell-unhighlight-at (- end 1))) | |
571 t) | |
572 (t | |
573 ;; we setup the cache | |
574 (setq flyspell-word-cache-start start) | |
575 (setq flyspell-word-cache-end end) | |
576 (setq flyspell-word-cache-word word) | |
577 ;; now check spelling of word. | |
578 (process-send-string ispell-process "%\n") | |
579 ;; put in verbose mode | |
580 (process-send-string ispell-process | |
581 (concat "^" word "\n")) | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
582 ;; we mark the ispell process so it can be killed |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
583 ;; when emacs is exited without query |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
584 (if (fboundp 'process-kill-without-query) |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
585 (process-kill-without-query ispell-process)) |
22611 | 586 ;; wait until ispell has processed word |
587 (while (progn | |
588 (accept-process-output ispell-process) | |
589 (not (string= "" (car ispell-filter))))) | |
590 ;; (process-send-string ispell-process "!\n") | |
591 ;; back to terse mode. | |
592 (setq ispell-filter (cdr ispell-filter)) | |
593 (if (listp ispell-filter) | |
594 (setq poss (ispell-parse-output (car ispell-filter)))) | |
595 (cond ((eq poss t) | |
596 ;; correct | |
597 (flyspell-unhighlight-at start) | |
598 (if (> end start) | |
599 (flyspell-unhighlight-at (- end 1))) | |
600 t) | |
601 ((and (stringp poss) flyspell-highlight-flag) | |
602 ;; correct | |
603 (flyspell-unhighlight-at start) | |
604 (if (> end start) | |
605 (flyspell-unhighlight-at (- end 1))) | |
606 t) | |
607 ((null poss) | |
608 (flyspell-unhighlight-at start) | |
609 (if (> end start) | |
610 (flyspell-unhighlight-at (- end 1))) | |
611 (message "Error in ispell process")) | |
612 ((or (and (< flyspell-duplicate-distance 0) | |
613 (or (save-excursion | |
614 (goto-char start) | |
615 (word-search-backward word | |
616 (point-min) | |
617 t)) | |
618 (save-excursion | |
619 (goto-char end) | |
620 (word-search-forward word | |
621 (point-max) | |
622 t)))) | |
623 (and (> flyspell-duplicate-distance 0) | |
624 (or (save-excursion | |
625 (goto-char start) | |
626 (word-search-backward | |
627 word | |
628 (- start | |
629 flyspell-duplicate-distance) | |
630 t)) | |
631 (save-excursion | |
632 (goto-char end) | |
633 (word-search-forward | |
634 word | |
635 (+ end | |
636 flyspell-duplicate-distance) | |
637 t))))) | |
638 (if flyspell-highlight-flag | |
639 (flyspell-highlight-duplicate-region start end) | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
640 (message (format "duplicate `%s'" word)))) |
22611 | 641 (t |
642 ;; incorrect highlight the location | |
643 (if flyspell-highlight-flag | |
644 (flyspell-highlight-incorrect-region start end) | |
645 (message (format "mispelling `%s'" word))))) | |
646 (goto-char cursor-location) ; return to original location | |
647 (if ispell-quit (setq ispell-quit nil))))))))) | |
648 | |
649 ;*---------------------------------------------------------------------*/ | |
650 ;* flyspell-tex-command-p ... */ | |
651 ;*---------------------------------------------------------------------*/ | |
652 (defun flyspell-tex-command-p (word) | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
653 "Return t if WORD is a TeX command." |
22611 | 654 (eq (aref word 0) ?\\)) |
655 | |
656 ;*---------------------------------------------------------------------*/ | |
657 ;* flyspell-casechars-cache ... */ | |
658 ;*---------------------------------------------------------------------*/ | |
659 (defvar flyspell-casechars-cache nil) | |
660 (defvar flyspell-ispell-casechars-cache nil) | |
661 (make-variable-buffer-local 'flyspell-casechars-cache) | |
662 (make-variable-buffer-local 'flyspell-ispell-casechars-cache) | |
663 | |
664 ;*---------------------------------------------------------------------*/ | |
665 ;* flyspell-get-casechars ... */ | |
666 ;*---------------------------------------------------------------------*/ | |
667 (defun flyspell-get-casechars () | |
668 "This function builds a string that is the regexp of word chars. | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
669 In order to avoid one useless string construction, |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
670 this function changes the last char of the `ispell-casechars' string." |
22611 | 671 (let ((ispell-casechars (ispell-get-casechars))) |
672 (cond | |
673 ((eq ispell-casechars flyspell-ispell-casechars-cache) | |
674 flyspell-casechars-cache) | |
675 ((not (eq ispell-parser 'tex)) | |
676 (setq flyspell-ispell-casechars-cache ispell-casechars) | |
677 (setq flyspell-casechars-cache | |
678 (concat (substring ispell-casechars | |
679 0 | |
680 (- (length ispell-casechars) 1)) | |
681 "{}]")) | |
682 flyspell-casechars-cache) | |
683 (t | |
684 (setq flyspell-ispell-casechars-cache ispell-casechars) | |
685 (setq flyspell-casechars-cache ispell-casechars) | |
686 flyspell-casechars-cache)))) | |
687 | |
688 ;*---------------------------------------------------------------------*/ | |
689 ;* flyspell-get-not-casechars-cache ... */ | |
690 ;*---------------------------------------------------------------------*/ | |
691 (defvar flyspell-not-casechars-cache nil) | |
692 (defvar flyspell-ispell-not-casechars-cache nil) | |
693 (make-variable-buffer-local 'flyspell-not-casechars-cache) | |
694 (make-variable-buffer-local 'flyspell-ispell-not-casechars-cache) | |
695 | |
696 ;*---------------------------------------------------------------------*/ | |
697 ;* flyspell-get-not-casechars ... */ | |
698 ;*---------------------------------------------------------------------*/ | |
699 (defun flyspell-get-not-casechars () | |
700 "This function builds a string that is the regexp of non-word chars." | |
701 (let ((ispell-not-casechars (ispell-get-not-casechars))) | |
702 (cond | |
703 ((eq ispell-not-casechars flyspell-ispell-not-casechars-cache) | |
704 flyspell-not-casechars-cache) | |
705 ((not (eq ispell-parser 'tex)) | |
706 (setq flyspell-ispell-not-casechars-cache ispell-not-casechars) | |
707 (setq flyspell-not-casechars-cache | |
708 (concat (substring ispell-not-casechars | |
709 0 | |
710 (- (length ispell-not-casechars) 1)) | |
711 "{}]")) | |
712 flyspell-not-casechars-cache) | |
713 (t | |
714 (setq flyspell-ispell-not-casechars-cache ispell-not-casechars) | |
715 (setq flyspell-not-casechars-cache ispell-not-casechars) | |
716 flyspell-not-casechars-cache)))) | |
717 | |
718 ;*---------------------------------------------------------------------*/ | |
719 ;* flyspell-get-word ... */ | |
720 ;*---------------------------------------------------------------------*/ | |
721 (defun flyspell-get-word (following) | |
722 "Return the word for spell-checking according to Ispell syntax. | |
723 If optional argument FOLLOWING is non-nil or if `ispell-following-word' | |
724 is non-nil when called interactively, then the following word | |
725 \(rather than preceding\) is checked when the cursor is not over a word. | |
726 Optional second argument contains otherchars that can be included in word | |
727 many times. | |
728 | |
729 Word syntax described by `ispell-dictionary-alist' (which see)." | |
730 (let* ((flyspell-casechars (flyspell-get-casechars)) | |
731 (flyspell-not-casechars (flyspell-get-not-casechars)) | |
732 (ispell-otherchars (ispell-get-otherchars)) | |
733 (ispell-many-otherchars-p (ispell-get-many-otherchars-p)) | |
24943
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
734 (word-regexp (if (not (string= "" ispell-otherchars)) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
735 (concat |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
736 flyspell-casechars |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
737 "+\\(" |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
738 ispell-otherchars |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
739 "?" |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
740 flyspell-casechars |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
741 "+\\)" |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
742 (if ispell-many-otherchars-p |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
743 "*" "?")) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
744 (concat flyspell-casechars "+"))) |
22611 | 745 (tex-prelude "[\\\\{]") |
746 (tex-regexp (if (eq ispell-parser 'tex) | |
747 (concat tex-prelude "?" word-regexp "}?") | |
748 word-regexp)) | |
749 | |
750 did-it-once | |
751 start end word) | |
752 ;; find the word | |
753 (if (not (or (looking-at flyspell-casechars) | |
754 (and (eq ispell-parser 'tex) | |
755 (looking-at tex-prelude)))) | |
756 (if following | |
757 (re-search-forward flyspell-casechars (point-max) t) | |
758 (re-search-backward flyspell-casechars (point-min) t))) | |
759 ;; move to front of word | |
760 (re-search-backward flyspell-not-casechars (point-min) 'start) | |
24943
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
761 (if (not (string= "" ispell-otherchars)) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
762 (let ((pos nil)) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
763 (while (and (looking-at ispell-otherchars) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
764 (not (bobp)) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
765 (or (not did-it-once) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
766 ispell-many-otherchars-p) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
767 (not (eq pos (point)))) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
768 (setq pos (point)) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
769 (setq did-it-once t) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
770 (backward-char 1) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
771 (if (looking-at flyspell-casechars) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
772 (re-search-backward flyspell-not-casechars (point-min) 'move) |
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
773 (backward-char -1))))) |
22611 | 774 ;; Now mark the word and save to string. |
775 (if (eq (re-search-forward tex-regexp (point-max) t) nil) | |
776 nil | |
777 (progn | |
778 (setq start (match-beginning 0) | |
779 end (point) | |
780 word (buffer-substring start end)) | |
781 (list word start end))))) | |
782 | |
783 ;*---------------------------------------------------------------------*/ | |
784 ;* flyspell-region ... */ | |
785 ;*---------------------------------------------------------------------*/ | |
786 (defun flyspell-region (beg end) | |
787 "Flyspell text between BEG and END." | |
788 (interactive "r") | |
789 (save-excursion | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
790 (if (> beg end) |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
791 (let ((old beg)) |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
792 (setq beg end) |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
793 (setq end old))) |
22611 | 794 (goto-char beg) |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
795 (let ((count 0)) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
796 (while (< (point) end) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
797 (if (= count 100) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
798 (progn |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
799 (message "Spell Checking...%d%%" |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
800 (* 100 (/ (float (- (point) beg)) (- end beg)))) |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
801 (setq count 0)) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
802 (setq count (+ 1 count))) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
803 (flyspell-word) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
804 (let ((cur (point))) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
805 (forward-word 1) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
806 (if (and (< (point) end) (> (point) (+ cur 1))) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
807 (backward-char 1))))) |
22611 | 808 (backward-char 1) |
809 (message "Spell Checking...done") | |
810 (flyspell-word))) | |
811 | |
812 ;*---------------------------------------------------------------------*/ | |
813 ;* flyspell-buffer ... */ | |
814 ;*---------------------------------------------------------------------*/ | |
815 (defun flyspell-buffer () | |
816 "Flyspell whole buffer." | |
817 (interactive) | |
818 (flyspell-region (point-min) (point-max))) | |
819 | |
820 ;*---------------------------------------------------------------------*/ | |
821 ;* flyspell-overlay-p ... */ | |
822 ;*---------------------------------------------------------------------*/ | |
823 (defun flyspell-overlay-p (o) | |
824 "A predicate that return true iff O is an overlay used by flyspell." | |
825 (and (overlayp o) (overlay-get o 'flyspell-overlay))) | |
826 | |
827 ;*---------------------------------------------------------------------*/ | |
828 ;* flyspell-delete-all-overlays ... */ | |
829 ;* ------------------------------------------------------------- */ | |
830 ;* Remove all the overlays introduced by flyspell. */ | |
831 ;*---------------------------------------------------------------------*/ | |
832 (defun flyspell-delete-all-overlays () | |
833 "Delete all the overlays used by flyspell." | |
834 (let ((l (overlays-in (point-min) (point-max)))) | |
835 (while (consp l) | |
836 (progn | |
837 (if (flyspell-overlay-p (car l)) | |
838 (delete-overlay (car l))) | |
839 (setq l (cdr l)))))) | |
840 | |
841 ;*---------------------------------------------------------------------*/ | |
842 ;* flyspell-unhighlight-at ... */ | |
843 ;*---------------------------------------------------------------------*/ | |
844 (defun flyspell-unhighlight-at (pos) | |
845 "Remove the flyspell overlay that are located at POS." | |
846 (if flyspell-persistent-highlight | |
847 (let ((overlays (overlays-at pos))) | |
848 (while (consp overlays) | |
849 (if (flyspell-overlay-p (car overlays)) | |
850 (delete-overlay (car overlays))) | |
851 (setq overlays (cdr overlays)))) | |
852 (delete-overlay flyspell-overlay))) | |
853 | |
854 ;*---------------------------------------------------------------------*/ | |
855 ;* flyspell-properties-at-p ... */ | |
856 ;* ------------------------------------------------------------- */ | |
857 ;* Is there an highlight properties at position pos? */ | |
858 ;*---------------------------------------------------------------------*/ | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
859 (defun flyspell-properties-at-p (pos) |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
860 "Return t if there is a text property at POS, not counting `local-map'. |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
861 If variable `flyspell-highlight-properties' is set to nil, |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
862 text with properties are not checked. This function is used to discover |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
863 if the character at POS has any other property." |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
864 (let ((prop (text-properties-at pos)) |
22611 | 865 (keep t)) |
866 (while (and keep (consp prop)) | |
867 (if (and (eq (car prop) 'local-map) (consp (cdr prop))) | |
868 (setq prop (cdr (cdr prop))) | |
869 (setq keep nil))) | |
870 (consp prop))) | |
871 | |
872 ;*---------------------------------------------------------------------*/ | |
873 ;* make-flyspell-overlay ... */ | |
874 ;*---------------------------------------------------------------------*/ | |
875 (defun make-flyspell-overlay (beg end face mouse-face) | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
876 "Allocate an overlay to highlight an incorrect word. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
877 BEG and END specify the range in the buffer of that word. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
878 FACE and MOUSE-FACE specify the `face' and `mouse-face' properties |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
879 for the overlay." |
24076
6236e60302e2
(make-flyspell-overlay): fix front stickiness.
Richard M. Stallman <rms@gnu.org>
parents:
23943
diff
changeset
|
880 (let ((flyspell-overlay (make-overlay beg end nil t nil))) |
22611 | 881 (overlay-put flyspell-overlay 'face face) |
882 (overlay-put flyspell-overlay 'mouse-face mouse-face) | |
883 (overlay-put flyspell-overlay 'flyspell-overlay t) | |
23943
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
884 (if flyspell-use-local-map |
22611 | 885 (overlay-put flyspell-overlay |
886 flyspell-overlay-keymap-property-name | |
887 flyspell-mouse-map)))) | |
888 | |
889 ;*---------------------------------------------------------------------*/ | |
890 ;* flyspell-highlight-incorrect-region ... */ | |
891 ;*---------------------------------------------------------------------*/ | |
892 (defun flyspell-highlight-incorrect-region (beg end) | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
893 "Set up an overlay on a misspelled word, in the buffer from BEG to END." |
22611 | 894 (run-hook-with-args 'flyspell-incorrect-hook beg end) |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
895 (if (or flyspell-highlight-properties (not (flyspell-properties-at-p beg))) |
22611 | 896 (progn |
897 ;; we cleanup current overlay at the same position | |
898 (if (and (not flyspell-persistent-highlight) | |
899 (overlayp flyspell-overlay)) | |
900 (delete-overlay flyspell-overlay) | |
901 (let ((overlays (overlays-at beg))) | |
902 (while (consp overlays) | |
903 (if (flyspell-overlay-p (car overlays)) | |
904 (delete-overlay (car overlays))) | |
905 (setq overlays (cdr overlays))))) | |
906 ;; now we can use a new overlay | |
907 (setq flyspell-overlay | |
908 (make-flyspell-overlay beg end | |
909 'flyspell-incorrect-face 'highlight))))) | |
910 | |
911 ;*---------------------------------------------------------------------*/ | |
912 ;* flyspell-highlight-duplicate-region ... */ | |
913 ;*---------------------------------------------------------------------*/ | |
914 (defun flyspell-highlight-duplicate-region (beg end) | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
915 "Set up an overlay on a duplicated word, in the buffer from BEG to END." |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
916 (if (or flyspell-highlight-properties (not (flyspell-properties-at-p beg))) |
22611 | 917 (progn |
918 ;; we cleanup current overlay at the same position | |
919 (if (and (not flyspell-persistent-highlight) | |
920 (overlayp flyspell-overlay)) | |
921 (delete-overlay flyspell-overlay) | |
922 (let ((overlays (overlays-at beg))) | |
923 (while (consp overlays) | |
924 (if (flyspell-overlay-p (car overlays)) | |
925 (delete-overlay (car overlays))) | |
926 (setq overlays (cdr overlays))))) | |
927 ;; now we can use a new overlay | |
928 (setq flyspell-overlay | |
929 (make-flyspell-overlay beg end | |
930 'flyspell-duplicate-face 'highlight))))) | |
931 | |
932 ;*---------------------------------------------------------------------*/ | |
933 ;* flyspell-auto-correct-cache ... */ | |
934 ;*---------------------------------------------------------------------*/ | |
935 (defvar flyspell-auto-correct-pos nil) | |
936 (defvar flyspell-auto-correct-region nil) | |
937 (defvar flyspell-auto-correct-ring nil) | |
938 | |
939 ;*---------------------------------------------------------------------*/ | |
940 ;* flyspell-auto-correct-word ... */ | |
941 ;*---------------------------------------------------------------------*/ | |
942 (defun flyspell-auto-correct-word (pos) | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
943 "Correct the word at POS. |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
944 This command proposes various successive corrections for the word at POS. |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
945 The variable `flyspell-auto-correct-binding' specifies the key to bind |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
946 to this command." |
22611 | 947 (interactive "d") |
948 ;; use the correct dictionary | |
949 (ispell-accept-buffer-local-defs) | |
950 (if (eq flyspell-auto-correct-pos pos) | |
951 ;; we have already been using the function at the same location | |
952 (progn | |
953 (save-excursion | |
954 (let ((start (car flyspell-auto-correct-region)) | |
955 (len (cdr flyspell-auto-correct-region))) | |
956 (delete-region start (+ start len)) | |
957 (setq flyspell-auto-correct-ring (cdr flyspell-auto-correct-ring)) | |
958 (let* ((word (car flyspell-auto-correct-ring)) | |
959 (len (length word))) | |
960 (rplacd flyspell-auto-correct-region len) | |
961 (goto-char start) | |
962 (insert word)))) | |
963 (setq flyspell-auto-correct-pos (point))) | |
964 ;; retain cursor location | |
965 (let ((cursor-location pos) | |
966 (word (flyspell-get-word nil)) | |
967 start end poss) | |
968 ;; destructure return word info list. | |
969 (setq start (car (cdr word)) | |
970 end (car (cdr (cdr word))) | |
971 word (car word)) | |
972 ;; now check spelling of word. | |
973 (process-send-string ispell-process "%\n") ;put in verbose mode | |
974 (process-send-string ispell-process (concat "^" word "\n")) | |
975 ;; wait until ispell has processed word | |
976 (while (progn | |
977 (accept-process-output ispell-process) | |
978 (not (string= "" (car ispell-filter))))) | |
979 (setq ispell-filter (cdr ispell-filter)) | |
980 (if (listp ispell-filter) | |
981 (setq poss (ispell-parse-output (car ispell-filter)))) | |
982 (cond ((or (eq poss t) (stringp poss)) | |
983 ;; don't correct word | |
984 t) | |
985 ((null poss) | |
986 ;; ispell error | |
987 (error "Ispell: error in Ispell process")) | |
988 (t | |
989 ;; the word is incorrect, we have to propose a replacement | |
990 (let ((replacements (if flyspell-sort-corrections | |
991 (sort (car (cdr (cdr poss))) 'string<) | |
992 (car (cdr (cdr poss)))))) | |
993 (if (consp replacements) | |
994 (progn | |
995 (let ((replace (car replacements))) | |
996 (setq word replace) | |
997 (setq cursor-location (+ (- (length word) (- end start)) | |
998 cursor-location)) | |
999 (if (not (equal word (car poss))) | |
1000 (progn | |
1001 ;; the save the current replacements | |
1002 (setq flyspell-auto-correct-pos cursor-location) | |
1003 (setq flyspell-auto-correct-region | |
1004 (cons start (length word))) | |
1005 (let ((l replacements)) | |
1006 (while (consp (cdr l)) | |
1007 (setq l (cdr l))) | |
1008 (rplacd l (cons (car poss) replacements))) | |
1009 (setq flyspell-auto-correct-ring | |
1010 (cdr replacements)) | |
1011 (delete-region start end) | |
1012 (insert word))))))))) | |
1013 ;; return to original location | |
1014 (goto-char cursor-location) | |
1015 (ispell-pdict-save t)))) | |
1016 | |
1017 ;*---------------------------------------------------------------------*/ | |
1018 ;* flyspell-correct-word ... */ | |
1019 ;*---------------------------------------------------------------------*/ | |
1020 (defun flyspell-correct-word (event) | |
1021 "Check spelling of word under or before the cursor. | |
1022 If the word is not found in dictionary, display possible corrections | |
1023 in a popup menu allowing you to choose one. | |
1024 | |
1025 Word syntax described by `ispell-dictionary-alist' (which see). | |
1026 | |
1027 This will check or reload the dictionary. Use \\[ispell-change-dictionary] | |
1028 or \\[ispell-region] to update the Ispell process." | |
1029 (interactive "e") | |
23943
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
1030 (if flyspell-use-local-map |
22611 | 1031 (flyspell-correct-word/mouse-keymap event) |
23943
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
1032 (flyspell-correct-word/local-keymap event))) |
22611 | 1033 |
1034 ;*---------------------------------------------------------------------*/ | |
1035 ;* flyspell-correct-word/local-keymap ... */ | |
1036 ;*---------------------------------------------------------------------*/ | |
1037 (defun flyspell-correct-word/local-keymap (event) | |
1038 "emacs 19.xx seems to be buggous. Overlay keymap does not seems | |
1039 to work correctly with local map. That is, if a key is not | |
1040 defined for the overlay keymap, the current local map, is not | |
1041 checked. The binding is resolved with the global map. The | |
1042 consequence is that we can not use overlay map with flyspell." | |
1043 (interactive "e") | |
1044 (save-window-excursion | |
1045 (let ((save (point))) | |
1046 (mouse-set-point event) | |
1047 ;; we look for a flyspell overlay here | |
1048 (let ((overlays (overlays-at (point))) | |
1049 (overlay nil)) | |
1050 (while (consp overlays) | |
1051 (if (flyspell-overlay-p (car overlays)) | |
1052 (progn | |
1053 (setq overlay (car overlays)) | |
1054 (setq overlays nil)) | |
1055 (setq overlays (cdr overlays)))) | |
1056 ;; we return to the correct location | |
1057 (goto-char save) | |
1058 ;; we check to see if button2 has been used overlay a | |
1059 ;; flyspell overlay | |
1060 (if overlay | |
1061 ;; yes, so we use the flyspell function | |
1062 (flyspell-correct-word/mouse-keymap event) | |
1063 ;; no so we have to use the non flyspell binding | |
1064 (let ((flyspell-mode nil)) | |
1065 (if (key-binding (this-command-keys)) | |
1066 (command-execute (key-binding (this-command-keys)))))))))) | |
1067 | |
1068 ;*---------------------------------------------------------------------*/ | |
1069 ;* flyspell-correct-word ... */ | |
1070 ;*---------------------------------------------------------------------*/ | |
1071 (defun flyspell-correct-word/mouse-keymap (event) | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
1072 "Pop up a menu of possible corrections for a misspelled word. |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
1073 The word checked is the word at the mouse position." |
22611 | 1074 (interactive "e") |
1075 ;; use the correct dictionary | |
1076 (ispell-accept-buffer-local-defs) | |
1077 ;; retain cursor location (I don't know why but save-excursion here fails). | |
1078 (let ((save (point))) | |
1079 (mouse-set-point event) | |
1080 (let ((cursor-location (point)) | |
1081 (word (flyspell-get-word nil)) | |
1082 start end poss replace) | |
1083 ;; destructure return word info list. | |
1084 (setq start (car (cdr word)) | |
1085 end (car (cdr (cdr word))) | |
1086 word (car word)) | |
1087 ;; now check spelling of word. | |
1088 (process-send-string ispell-process "%\n") ;put in verbose mode | |
1089 (process-send-string ispell-process (concat "^" word "\n")) | |
1090 ;; wait until ispell has processed word | |
1091 (while (progn | |
1092 (accept-process-output ispell-process) | |
1093 (not (string= "" (car ispell-filter))))) | |
1094 (setq ispell-filter (cdr ispell-filter)) | |
1095 (if (listp ispell-filter) | |
1096 (setq poss (ispell-parse-output (car ispell-filter)))) | |
1097 (cond ((or (eq poss t) (stringp poss)) | |
1098 ;; don't correct word | |
1099 t) | |
1100 ((null poss) | |
1101 ;; ispell error | |
1102 (error "Ispell: error in Ispell process")) | |
1103 ((string-match "GNU" (emacs-version)) | |
1104 ;; the word is incorrect, we have to propose a replacement | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
1105 (setq replace (flyspell-emacs-popup event poss word)) |
22611 | 1106 (cond ((eq replace 'ignore) |
1107 nil) | |
1108 ((eq replace 'save) | |
1109 (process-send-string ispell-process (concat "*" word "\n")) | |
1110 (flyspell-unhighlight-at cursor-location) | |
1111 (setq ispell-pdict-modified-p '(t))) | |
1112 ((or (eq replace 'buffer) (eq replace 'session)) | |
1113 (process-send-string ispell-process (concat "@" word "\n")) | |
1114 (if (null ispell-pdict-modified-p) | |
1115 (setq ispell-pdict-modified-p | |
1116 (list ispell-pdict-modified-p))) | |
1117 (flyspell-unhighlight-at cursor-location) | |
1118 (if (eq replace 'buffer) | |
1119 (ispell-add-per-file-word-list word))) | |
1120 (replace | |
1121 (setq word (if (atom replace) replace (car replace)) | |
1122 cursor-location (+ (- (length word) (- end start)) | |
1123 cursor-location)) | |
1124 (if (not (equal word (car poss))) | |
1125 (progn | |
1126 (delete-region start end) | |
1127 (insert word)))))) | |
1128 ((string-match "XEmacs" (emacs-version)) | |
1129 (flyspell-xemacs-popup | |
1130 event poss word cursor-location start end))) | |
1131 (ispell-pdict-save t)) | |
1132 (if (< save (point-max)) | |
1133 (goto-char save) | |
1134 (goto-char (point-max))))) | |
1135 | |
1136 ;*---------------------------------------------------------------------*/ | |
1137 ;* flyspell-xemacs-correct ... */ | |
1138 ;*---------------------------------------------------------------------*/ | |
1139 (defun flyspell-xemacs-correct (replace poss word cursor-location start end) | |
1140 "The xemacs popup menu callback." | |
1141 (cond ((eq replace 'ignore) | |
1142 nil) | |
1143 ((eq replace 'save) | |
1144 (process-send-string ispell-process (concat "*" word "\n")) | |
1145 (flyspell-unhighlight-at cursor-location) | |
1146 (setq ispell-pdict-modified-p '(t))) | |
1147 ((or (eq replace 'buffer) (eq replace 'session)) | |
1148 (process-send-string ispell-process (concat "@" word "\n")) | |
1149 (flyspell-unhighlight-at cursor-location) | |
1150 (if (null ispell-pdict-modified-p) | |
1151 (setq ispell-pdict-modified-p | |
1152 (list ispell-pdict-modified-p))) | |
1153 (if (eq replace 'buffer) | |
1154 (ispell-add-per-file-word-list word))) | |
1155 (replace | |
1156 (setq word (if (atom replace) replace (car replace)) | |
1157 cursor-location (+ (- (length word) (- end start)) | |
1158 cursor-location)) | |
1159 (if (not (equal word (car poss))) | |
1160 (save-excursion | |
1161 (delete-region start end) | |
1162 (goto-char start) | |
1163 (insert word)))))) | |
1164 | |
1165 ;*---------------------------------------------------------------------*/ | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
1166 ;* flyspell-emacs-popup ... */ |
22611 | 1167 ;*---------------------------------------------------------------------*/ |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
1168 (defun flyspell-emacs-popup (event poss word) |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
1169 "The Emacs popup menu." |
22611 | 1170 (if (not event) |
1171 (let* ((mouse-pos (mouse-position)) | |
1172 (mouse-pos (if (nth 1 mouse-pos) | |
1173 mouse-pos | |
1174 (set-mouse-position (car mouse-pos) | |
1175 (/ (frame-width) 2) 2) | |
1176 (unfocus-frame) | |
1177 (mouse-position)))) | |
1178 (setq event (list (list (car (cdr mouse-pos)) | |
1179 (1+ (cdr (cdr mouse-pos)))) | |
1180 (car mouse-pos))))) | |
1181 (let* ((corrects (if flyspell-sort-corrections | |
1182 (sort (car (cdr (cdr poss))) 'string<) | |
1183 (car (cdr (cdr poss))))) | |
1184 (cor-menu (if (consp corrects) | |
1185 (mapcar (lambda (correct) | |
1186 (list correct correct)) | |
1187 corrects) | |
1188 '())) | |
1189 (affix (car (cdr (cdr (cdr poss))))) | |
1190 (base-menu (let ((save (if (consp affix) | |
1191 (list | |
1192 (list (concat "Save affix: " (car affix)) | |
1193 'save) | |
1194 '("Accept (session)" accept) | |
1195 '("Accept (buffer)" buffer)) | |
1196 '(("Save word" save) | |
1197 ("Accept (session)" session) | |
1198 ("Accept (buffer)" buffer))))) | |
1199 (if (consp cor-menu) | |
1200 (append cor-menu (cons "" save)) | |
1201 save))) | |
1202 (menu (cons "flyspell correction menu" base-menu))) | |
1203 (car (x-popup-menu event | |
1204 (list (format "%s [%s]" word (or ispell-local-dictionary | |
1205 ispell-dictionary)) | |
1206 menu))))) | |
1207 | |
1208 ;*---------------------------------------------------------------------*/ | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
1209 ;* flyspell-xemacs-popup ... */ |
22611 | 1210 ;*---------------------------------------------------------------------*/ |
1211 (defun flyspell-xemacs-popup (event poss word cursor-location start end) | |
1212 "The xemacs popup menu." | |
1213 (let* ((corrects (if flyspell-sort-corrections | |
1214 (sort (car (cdr (cdr poss))) 'string<) | |
1215 (car (cdr (cdr poss))))) | |
1216 (cor-menu (if (consp corrects) | |
1217 (mapcar (lambda (correct) | |
1218 (vector correct | |
1219 (list 'flyspell-xemacs-correct | |
1220 correct | |
1221 (list 'quote poss) | |
1222 word | |
1223 cursor-location | |
1224 start | |
1225 end) | |
1226 t)) | |
1227 corrects) | |
1228 '())) | |
1229 (affix (car (cdr (cdr (cdr poss))))) | |
1230 (menu (let ((save (if (consp affix) | |
1231 (vector | |
1232 (concat "Save affix: " (car affix)) | |
1233 (list 'flyspell-xemacs-correct | |
1234 ''save | |
1235 (list 'quote poss) | |
1236 word | |
1237 cursor-location | |
1238 start | |
1239 end) | |
1240 t) | |
1241 (vector | |
1242 "Save word" | |
1243 (list 'flyspell-xemacs-correct | |
1244 ''save | |
1245 (list 'quote poss) | |
1246 word | |
1247 cursor-location | |
1248 start | |
1249 end) | |
1250 t))) | |
1251 (session (vector "Accept (session)" | |
1252 (list 'flyspell-xemacs-correct | |
1253 ''session | |
1254 (list 'quote poss) | |
1255 word | |
1256 cursor-location | |
1257 start | |
1258 end) | |
1259 t)) | |
1260 (buffer (vector "Accept (buffer)" | |
1261 (list 'flyspell-xemacs-correct | |
1262 ''buffer | |
1263 (list 'quote poss) | |
1264 word | |
1265 cursor-location | |
1266 start | |
1267 end) | |
1268 t))) | |
1269 (if (consp cor-menu) | |
1270 (append cor-menu (list "-" save session buffer)) | |
1271 (list save session buffer))))) | |
1272 (popup-menu (cons (format "%s [%s]" word (or ispell-local-dictionary | |
1273 ispell-dictionary)) | |
1274 menu)))) | |
1275 | |
1276 (provide 'flyspell) | |
1277 | |
1278 ;;; flyspell.el ends here |