Mercurial > emacs
annotate lisp/textmodes/flyspell.el @ 43813:7c1c9baea70f
(enum event_kind): Added save_session_event.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Sun, 10 Mar 2002 16:15:48 +0000 |
parents | e3bdc12b3e47 |
children | fe852d8d5495 |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37008
diff
changeset
|
1 ;;; flyspell.el --- on-the-fly spell checker |
22611 | 2 |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
3 ;; Copyright (C) 1998, 2000, 2001, 2002 Free Software Foundation, Inc. |
22611 | 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 |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37008
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
22611 | 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 | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
25 ;;; Commentary: |
22611 | 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. |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
29 ;; |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
30 ;; To enable Flyspell minor mode, type M-x flyspell-mode. |
22891
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. |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
32 ;; |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
33 ;; To enable Flyspell in text representing computer programs, type |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
34 ;; M-x flyspell-prog-mode. |
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
35 ;; In that mode only text inside comments is checked. |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
36 ;; |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
37 ;; Note: consider setting the variable ispell-parser to `tex' to |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
38 ;; avoid TeX command checking; use `(setq ispell-parser 'tex)'. |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
39 ;; |
22611 | 40 ;; Some user variables control the behavior of flyspell. They are |
41 ;; those defined under the `User variables' comment. | |
42 | |
43 ;;; Code: | |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
44 |
22611 | 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 |
37008 | 51 "Spell checking on the fly." |
22611 | 52 :tag "FlySpell" |
53 :prefix "flyspell-" | |
43383
d21a74d23497
2002-02-17 Per Abrahamsen <abraham@dina.kvl.dk>
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
43148
diff
changeset
|
54 :group 'ispell |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
55 :group 'processes) |
22611 | 56 |
57 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
58 ;* User configuration ... */ |
22611 | 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 | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
71 (defcustom flyspell-sort-corrections nil |
22611 | 72 "*Non-nil means, sort the corrections alphabetically before popping them." |
73 :group 'flyspell | |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
74 :version "21.1" |
22611 | 75 :type 'boolean) |
76 | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
77 (defcustom flyspell-duplicate-distance -1 |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
78 "*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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 -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
|
84 0 means do not search for duplicate unrecognized spellings." |
22611 | 85 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
86 :version "21.1" |
22611 | 87 :type 'number) |
88 | |
89 (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
|
90 "*The number of seconds to wait before checking, after a \"delayed\" command." |
22611 | 91 :group 'flyspell |
92 :type 'number) | |
93 | |
94 (defcustom flyspell-persistent-highlight t | |
22946
cfde96067373
(flyspell-persistent-highlight): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
22891
diff
changeset
|
95 "*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
|
96 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
|
97 is highlighted." |
22611 | 98 :group 'flyspell |
99 :type 'boolean) | |
100 | |
101 (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
|
102 "*Non-nil means highlight incorrect words even if a property exists for this word." |
22611 | 103 :group 'flyspell |
104 :type 'boolean) | |
105 | |
106 (defcustom flyspell-default-delayed-commands | |
107 '(self-insert-command | |
108 delete-backward-char | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
109 backward-or-forward-delete-char |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
110 delete-char |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
111 scrollbar-vertical-drag) |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
112 "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
|
113 See `flyspell-delayed-commands'." |
22611 | 114 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
115 :version "21.1" |
22611 | 116 :type '(repeat (symbol))) |
117 | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
118 (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
|
119 "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
|
120 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
|
121 whose length is specified by `flyspell-delay'." |
22611 | 122 :group 'flyspell |
123 :type '(repeat (symbol))) | |
124 | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
125 (defcustom flyspell-default-deplacement-commands |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
126 '(next-line |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
127 previous-line |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
128 scroll-up |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
129 scroll-down) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
130 "The standard list of deplacement commands for Flyspell. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
131 See `flyspell-deplacement-commands'." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
132 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
133 :version "21.1" |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
134 :type '(repeat (symbol))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
135 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
136 (defcustom flyspell-deplacement-commands nil |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
137 "List of commands that are \"deplacement\" for Flyspell mode. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
138 After these commands, Flyspell checking is performed only if the previous |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
139 command was not the very same command." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
140 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
141 :version "21.1" |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
142 :type '(repeat (symbol))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
143 |
22611 | 144 (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
|
145 "*Non-nil means that Flyspell should display a welcome message when started." |
22611 | 146 :group 'flyspell |
147 :type 'boolean) | |
148 | |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
149 (defcustom flyspell-issue-message-flag t |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
150 "*Non-nil means that Flyspell emits messages when checking words." |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
151 :group 'flyspell |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
152 :type 'boolean) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
153 |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
154 (defcustom flyspell-incorrect-hook nil |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
155 "*List of functions to be called when incorrect words are encountered. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
156 Each function is given three arguments: the beginning and the end |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
157 of the incorrect region. The third is either the symbol 'doublon' or the list |
37008 | 158 of possible corrections as returned by 'ispell-parse-output'. |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
159 |
37008 | 160 If any of the functions return non-Nil, the word is not highlighted as |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
161 incorrect." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
162 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
163 :version "21.1" |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
164 :type 'hook) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
165 |
40933
29830f44be6a
(flyspell-default-dictionary): Allow nil as value, and make nil the default.
Richard M. Stallman <rms@gnu.org>
parents:
40898
diff
changeset
|
166 (defcustom flyspell-default-dictionary nil |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
167 "A string that is the name of the default dictionary. |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
168 This is passed to the `ispell-change-dictionary' when flyspell is started. |
40933
29830f44be6a
(flyspell-default-dictionary): Allow nil as value, and make nil the default.
Richard M. Stallman <rms@gnu.org>
parents:
40898
diff
changeset
|
169 If the variable `ispell-local-dictionary' or `ispell-dictionary' is non-nil |
29830f44be6a
(flyspell-default-dictionary): Allow nil as value, and make nil the default.
Richard M. Stallman <rms@gnu.org>
parents:
40898
diff
changeset
|
170 when flyspell is started, the value of that variable is used instead |
29830f44be6a
(flyspell-default-dictionary): Allow nil as value, and make nil the default.
Richard M. Stallman <rms@gnu.org>
parents:
40898
diff
changeset
|
171 of `flyspell-default-dictionary' to select the default dictionary. |
29830f44be6a
(flyspell-default-dictionary): Allow nil as value, and make nil the default.
Richard M. Stallman <rms@gnu.org>
parents:
40898
diff
changeset
|
172 Otherwise, if `flyspell-default-dictionary' is nil, it means to use |
29830f44be6a
(flyspell-default-dictionary): Allow nil as value, and make nil the default.
Richard M. Stallman <rms@gnu.org>
parents:
40898
diff
changeset
|
173 Ispell's ultimate default dictionary." |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
174 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
175 :version "21.1" |
40942
52f0b9d1d57b
(flyspell-default-dictionary): Fix previous change.
Pavel Janík <Pavel@Janik.cz>
parents:
40938
diff
changeset
|
176 :type '(choice string (const :tag "Default" nil))) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
177 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
178 (defcustom flyspell-tex-command-regexp |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
179 "\\(\\(begin\\|end\\)[ \t]*{\\|\\(cite[a-z*]*\\|label\\|ref\\|eqref\\|usepackage\\|documentclass\\)[ \t]*\\(\\[[^]]*\\]\\)?{[^{}]*\\)" |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
180 "A string that is the regular expression that matches TeX commands." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
181 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
182 :version "21.1" |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
183 :type 'string) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
184 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
185 (defcustom flyspell-check-tex-math-command nil |
37008 | 186 "*Non nil means check even inside TeX math environment. |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
187 TeX math environments are discovered by the TEXMATHP that implemented |
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
188 inside the texmathp.el Emacs package. That package may be found at: |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
189 http://strw.leidenuniv.nl/~dominik/Tools" |
22611 | 190 :group 'flyspell |
191 :type 'boolean) | |
192 | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
193 (defcustom flyspell-dictionaries-that-consider-dash-as-word-delimiter |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
194 '("francais" "deutsch8" "norsk") |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
195 "List of dictionary names that consider `-' as word delimiter." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
196 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
197 :version "21.1" |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
198 :type '(repeat (string))) |
22611 | 199 |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
200 (defcustom flyspell-abbrev-p |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
201 t |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
202 "*If true, add correction to abbreviation table." |
22611 | 203 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
204 :version "21.1" |
22611 | 205 :type 'boolean) |
206 | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
207 (defcustom flyspell-use-global-abbrev-table-p |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
208 nil |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
209 "*If true, prefer global abbrev table to local abbrev table." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
210 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
211 :version "21.1" |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
212 :type 'boolean) |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
213 |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
214 ;;;###autoload |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
215 (defcustom flyspell-mode-line-string " Fly" |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
216 "*String displayed on the modeline when flyspell is active. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
217 Set this to nil if you don't want a modeline indicator." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
218 :group 'flyspell |
42622
2c67c90f9b6d
(flyspell-mode-line-string): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents:
42456
diff
changeset
|
219 :type '(choice string (const :tag "None" nil))) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
220 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
221 (defcustom flyspell-large-region 1000 |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
222 "*The threshold that determines if a region is small. |
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
223 The `flyspell-region' function is invoked if the region is small, the |
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
224 word are checked one after the other using regular flyspell check |
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
225 means. If the region is large, a new Ispell process is spawned to get |
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
226 speed." |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
227 :group 'flyspell |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
228 :version "21.1" |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
229 :type 'number) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
230 |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
231 (defcustom flyspell-insert-function (function insert) |
43148
b3cf1a561428
(flyspell-insert-function): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents:
43064
diff
changeset
|
232 "*Function for inserting word by flyspell upon correction." |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
233 :group 'flyspell |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
234 :type 'function) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
235 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
236 (defcustom flyspell-before-incorrect-word-string nil |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
237 "String used to indicate an incorrect word starting." |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
238 :group 'flyspell |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
239 :type '(choice string (const nil))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
240 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
241 (defcustom flyspell-after-incorrect-word-string nil |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
242 "String used to indicate an incorrect word ending." |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
243 :group 'flyspell |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
244 :type '(choice string (const nil))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
245 |
22611 | 246 ;*---------------------------------------------------------------------*/ |
247 ;* Mode specific options */ | |
248 ;* ------------------------------------------------------------- */ | |
249 ;* Mode specific options enable users to disable flyspell on */ | |
250 ;* certain word depending of the emacs mode. For instance, when */ | |
251 ;* using flyspell with mail-mode add the following expression */ | |
252 ;* in your .emacs file: */ | |
253 ;* (add-hook 'mail-mode */ | |
254 ;* '(lambda () (setq flyspell-generic-check-word-p */ | |
255 ;* 'mail-mode-flyspell-verify))) */ | |
256 ;*---------------------------------------------------------------------*/ | |
257 (defvar flyspell-generic-check-word-p nil | |
258 "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
|
259 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
|
260 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
|
261 property of the major mode name.") |
22611 | 262 (make-variable-buffer-local 'flyspell-generic-check-word-p) |
263 | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
264 ;*--- mail mode -------------------------------------------------------*/ |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
265 (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
|
266 (put 'message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify) |
22611 | 267 (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
|
268 "This function is used for `flyspell-generic-check-word-p' in Mail mode." |
34925
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
269 (let ((in-headers (save-excursion |
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
270 (re-search-forward mail-header-separator nil t))) |
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
271 (in-signature (save-excursion |
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
272 (re-search-backward message-signature-separator nil t)))) |
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
273 (cond (in-headers |
35338
3ee28dccba1d
(mail-mode-flyspell-verify): Check in
Gerd Moellmann <gerd@gnu.org>
parents:
34925
diff
changeset
|
274 (and (save-excursion (beginning-of-line) |
3ee28dccba1d
(mail-mode-flyspell-verify): Check in
Gerd Moellmann <gerd@gnu.org>
parents:
34925
diff
changeset
|
275 (looking-at "^Subject:")) |
3ee28dccba1d
(mail-mode-flyspell-verify): Check in
Gerd Moellmann <gerd@gnu.org>
parents:
34925
diff
changeset
|
276 (> (point) (match-end 0)))) |
34925
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
277 (in-signature |
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
278 nil) |
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
279 (t |
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
280 (save-excursion |
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
281 (beginning-of-line) |
6043184119bc
(mail-mode-flyspell-verify): Spell-check
Gerd Moellmann <gerd@gnu.org>
parents:
33787
diff
changeset
|
282 (not (looking-at "[>}|]\\To:"))))))) |
22611 | 283 |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
284 ;*--- texinfo mode ----------------------------------------------------*/ |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
285 (put 'texinfo-mode 'flyspell-mode-predicate 'texinfo-mode-flyspell-verify) |
22611 | 286 (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
|
287 "This function is used for `flyspell-generic-check-word-p' in Texinfo mode." |
22611 | 288 (save-excursion |
289 (forward-word -1) | |
290 (not (looking-at "@")))) | |
291 | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
292 ;*--- tex mode --------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
293 (put 'tex-mode 'flyspell-mode-predicate 'tex-mode-flyspell-verify) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
294 (defun tex-mode-flyspell-verify () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
295 "This function is used for `flyspell-generic-check-word-p' in LaTeX mode." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
296 (and |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
297 (not (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
298 (re-search-backward "^[ \t]*%%%[ \t]+Local" (point-min) t))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
299 (not (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
300 (let ((this (point-marker)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
301 (e (progn (end-of-line) (point-marker)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
302 (beginning-of-line) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
303 (if (re-search-forward "\\\\\\(cite\\|label\\|ref\\){[^}]*}" e t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
304 (and (>= this (match-beginning 0)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
305 (<= this (match-end 0)) ))))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
306 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
307 ;*--- sgml mode -------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
308 (put 'sgml-mode 'flyspell-mode-predicate 'sgml-mode-flyspell-verify) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
309 (put 'html-mode 'flyspell-mode-predicate 'sgml-mode-flyspell-verify) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
310 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
311 (defun sgml-mode-flyspell-verify () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
312 "This function is used for `flyspell-generic-check-word-p' in SGML mode." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
313 (not (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
314 (let ((this (point-marker)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
315 (s (progn (beginning-of-line) (point-marker))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
316 (e (progn (end-of-line) (point-marker)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
317 (or (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
318 (goto-char this) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
319 (and (re-search-forward "[^<]*>" e t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
320 (= (match-beginning 0) this))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
321 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
322 (goto-char this) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
323 (and (re-search-backward "<[^>]*" s t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
324 (= (match-end 0) this))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
325 (and (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
326 (goto-char this) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
327 (and (re-search-forward "[^&]*;" e t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
328 (= (match-beginning 0) this))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
329 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
330 (goto-char this) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
331 (and (re-search-backward "&[^;]*" s t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
332 (= (match-end 0) this))))))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
333 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
334 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
335 ;* Programming mode */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
336 ;*---------------------------------------------------------------------*/ |
33787
d16b29f737a7
(flyspell-prog-text-faces): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33426
diff
changeset
|
337 (defvar flyspell-prog-text-faces |
d16b29f737a7
(flyspell-prog-text-faces): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33426
diff
changeset
|
338 '(font-lock-string-face font-lock-comment-face font-lock-doc-face) |
d16b29f737a7
(flyspell-prog-text-faces): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33426
diff
changeset
|
339 "Faces corresponding to text in programming-mode buffers.") |
d16b29f737a7
(flyspell-prog-text-faces): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33426
diff
changeset
|
340 |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
341 (defun flyspell-generic-progmode-verify () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
342 "Used for `flyspell-generic-check-word-p' in programming modes." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
343 (let ((f (get-text-property (point) 'face))) |
33787
d16b29f737a7
(flyspell-prog-text-faces): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33426
diff
changeset
|
344 (memq f flyspell-prog-text-faces))) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
345 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
346 ;;;###autoload |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
347 (defun flyspell-prog-mode () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
348 "Turn on `flyspell-mode' for comments and strings." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
349 (interactive) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
350 (setq flyspell-generic-check-word-p 'flyspell-generic-progmode-verify) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
351 (flyspell-mode 1)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
352 |
22611 | 353 ;*---------------------------------------------------------------------*/ |
354 ;* Overlay compatibility */ | |
355 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
356 (autoload 'make-overlay "overlay" "Overlay compatibility kit." t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
357 (autoload 'overlayp "overlay" "Overlay compatibility kit." t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
358 (autoload 'overlays-in "overlay" "Overlay compatibility kit." t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
359 (autoload 'delete-overlay "overlay" "Overlay compatibility kit." t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
360 (autoload 'overlays-at "overlay" "Overlay compatibility kit." t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
361 (autoload 'overlay-put "overlay" "Overlay compatibility kit." t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
362 (autoload 'overlay-get "overlay" "Overlay compatibility kit." t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
363 (autoload 'previous-overlay-change "overlay" "Overlay compatibility kit." t) |
22611 | 364 |
365 ;*---------------------------------------------------------------------*/ | |
366 ;* Which emacs are we currently running */ | |
367 ;*---------------------------------------------------------------------*/ | |
368 (defvar flyspell-emacs | |
369 (cond | |
370 ((string-match "XEmacs" emacs-version) | |
371 'xemacs) | |
372 (t | |
373 'emacs)) | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
374 "The type of Emacs we are currently running.") |
22611 | 375 |
23943
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
376 (defvar flyspell-use-local-map |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
377 (or (eq flyspell-emacs 'xemacs) |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
378 (not (string< emacs-version "20")))) |
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
379 |
22611 | 380 ;*---------------------------------------------------------------------*/ |
381 ;* The minor mode declaration. */ | |
382 ;*---------------------------------------------------------------------*/ | |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
383 (eval-when-compile (defvar flyspell-local-mouse-map)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
384 |
43444
e3bdc12b3e47
(flyspell-mode): Autoload the variable since it is used in the menu bar.
Sam Steingold <sds@gnu.org>
parents:
43383
diff
changeset
|
385 ;;;###autoload |
22611 | 386 (defvar flyspell-mode nil) |
387 (make-variable-buffer-local 'flyspell-mode) | |
388 | |
27787
d40d47971e6b
(flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents:
24943
diff
changeset
|
389 (defvar flyspell-mouse-map |
d40d47971e6b
(flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents:
24943
diff
changeset
|
390 (let ((map (make-sparse-keymap))) |
d40d47971e6b
(flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents:
24943
diff
changeset
|
391 (cond |
d40d47971e6b
(flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents:
24943
diff
changeset
|
392 ((eq flyspell-emacs 'xemacs) |
40898
a69946fb84de
(flyspell-correct-word/local-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
40858
diff
changeset
|
393 (define-key map [(button2)] #'flyspell-correct-word) |
30470
6f18c5924d2e
(flyspell-mouse-map): Use `map' instead
Gerd Moellmann <gerd@gnu.org>
parents:
30428
diff
changeset
|
394 (define-key map "\M-\t" #'flyspell-auto-correct-word)) |
27787
d40d47971e6b
(flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents:
24943
diff
changeset
|
395 (flyspell-use-local-map |
40898
a69946fb84de
(flyspell-correct-word/local-keymap): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
40858
diff
changeset
|
396 (define-key map [(mouse-2)] #'flyspell-correct-word) |
27787
d40d47971e6b
(flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents:
24943
diff
changeset
|
397 (define-key map "\M-\t" #'flyspell-auto-correct-word))) |
d40d47971e6b
(flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents:
24943
diff
changeset
|
398 map)) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
399 |
42346
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
400 ;;;###autoload |
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
401 (defvar flyspell-mode-map (make-sparse-keymap)) |
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
402 |
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
403 ;; mouse, keyboard bindings and misc definition |
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
404 (when (or (assoc 'flyspell-mode minor-mode-map-alist) |
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
405 (setq minor-mode-map-alist |
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
406 (cons (cons 'flyspell-mode flyspell-mode-map) |
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
407 minor-mode-map-alist))) |
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
408 (define-key flyspell-mode-map "\M-\t" 'flyspell-auto-correct-word)) |
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
409 |
22611 | 410 ;; the name of the overlay property that defines the keymap |
40858
0517a2e0f908
Use the keymap property instead of local-map, and don't use a minor-mode map.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
411 (defvar flyspell-overlay-keymap-property-name 'keymap) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
412 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
413 ;; dash character machinery |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
414 (defvar flyspell-consider-dash-as-word-delimiter-flag nil |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
415 "*Non-nil means that the `-' char is considered as a word delimiter.") |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
416 (make-variable-buffer-local 'flyspell-consider-dash-as-word-delimiter-flag) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
417 (defvar flyspell-dash-dictionary nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
418 (make-variable-buffer-local 'flyspell-dash-dictionary) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
419 (defvar flyspell-dash-local-dictionary nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
420 (make-variable-buffer-local 'flyspell-dash-local-dictionary) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
421 |
22611 | 422 ;*---------------------------------------------------------------------*/ |
423 ;* Highlighting */ | |
424 ;*---------------------------------------------------------------------*/ | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
425 (defface flyspell-incorrect-face |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
426 (if (eq flyspell-emacs 'xemacs) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
427 '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
428 (t (:bold t))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
429 '((((class color)) (:foreground "OrangeRed" :weight bold :underline t)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
430 (t (:weight bold)))) |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
431 "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
|
432 :group 'flyspell) |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
433 |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
434 (defface flyspell-duplicate-face |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
435 (if (eq flyspell-emacs 'xemacs) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
436 '((((class color)) (:foreground "Gold3" :bold t :underline t)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
437 (t (:bold t))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
438 '((((class color)) (:foreground "Gold3" :weight bold :underline t)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
439 (t (:weight bold)))) |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
440 "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
|
441 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
|
442 :group 'flyspell) |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
443 |
22611 | 444 (defvar flyspell-overlay nil) |
445 | |
446 ;*---------------------------------------------------------------------*/ | |
447 ;* flyspell-mode ... */ | |
448 ;*---------------------------------------------------------------------*/ | |
449 ;;;###autoload | |
450 (defun flyspell-mode (&optional arg) | |
451 "Minor mode performing on-the-fly spelling checking. | |
452 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
|
453 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
|
454 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
|
455 With a prefix argument ARG, turn Flyspell minor mode on iff ARG is positive. |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
456 |
22611 | 457 Bindings: |
458 \\[ispell-word]: correct words (using Ispell). | |
459 \\[flyspell-auto-correct-word]: automatically correct word. | |
460 \\[flyspell-correct-word] (or mouse-2): popup correct words. | |
461 | |
462 Hooks: | |
40858
0517a2e0f908
Use the keymap property instead of local-map, and don't use a minor-mode map.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
463 This runs `flyspell-mode-hook' after flyspell is entered. |
22611 | 464 |
465 Remark: | |
466 `flyspell-mode' uses `ispell-mode'. Thus all Ispell options are | |
467 valid. For instance, a personal dictionary can be used by | |
468 invoking `ispell-change-dictionary'. | |
469 | |
470 Consider using the `ispell-parser' to check your text. For instance | |
471 consider adding: | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
472 \(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex)))) |
22611 | 473 in your .emacs file. |
474 | |
40858
0517a2e0f908
Use the keymap property instead of local-map, and don't use a minor-mode map.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
475 \\[flyspell-region] checks all words inside a region. |
0517a2e0f908
Use the keymap property instead of local-map, and don't use a minor-mode map.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
476 \\[flyspell-buffer] checks the whole buffer." |
22611 | 477 (interactive "P") |
23179
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
478 (let ((old-flyspell-mode flyspell-mode)) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
479 ;; Mark the mode as on or off. |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
480 (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
|
481 (<= (prefix-numeric-value arg) 0)))) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
482 ;; Do the real work. |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
483 (unless (eq flyspell-mode old-flyspell-mode) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
484 (if flyspell-mode |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
485 (flyspell-mode-on) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
486 (flyspell-mode-off)) |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
487 ;; Force modeline redisplay. |
72461ea3cfc8
(flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents:
22963
diff
changeset
|
488 (set-buffer-modified-p (buffer-modified-p))))) |
22611 | 489 |
490 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
491 ;* Autoloading */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
492 ;*---------------------------------------------------------------------*/ |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
493 ;;;###autoload |
40858
0517a2e0f908
Use the keymap property instead of local-map, and don't use a minor-mode map.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
494 (add-minor-mode 'flyspell-mode |
0517a2e0f908
Use the keymap property instead of local-map, and don't use a minor-mode map.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
495 'flyspell-mode-line-string |
42346
76e044b68878
(flyspell-mode-map): New keymap, defined as before 2001-11-09.
Richard M. Stallman <rms@gnu.org>
parents:
40942
diff
changeset
|
496 flyspell-mode-map |
40858
0517a2e0f908
Use the keymap property instead of local-map, and don't use a minor-mode map.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
497 nil |
0517a2e0f908
Use the keymap property instead of local-map, and don't use a minor-mode map.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
498 'flyspell-mode) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
499 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
500 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
501 ;* flyspell-buffers ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
502 ;* ------------------------------------------------------------- */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
503 ;* For remembering buffers running flyspell */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
504 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
505 (defvar flyspell-buffers nil) |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
506 |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
507 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
508 ;* flyspell-minibuffer-p ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
509 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
510 (defun flyspell-minibuffer-p (buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
511 "Is BUFFER a minibuffer?" |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
512 (let ((ws (get-buffer-window-list buffer t))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
513 (and (consp ws) (window-minibuffer-p (car ws))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
514 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
515 ;*---------------------------------------------------------------------*/ |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
516 ;* flyspell-version ... */ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
517 ;*---------------------------------------------------------------------*/ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
518 ;;;###autoload |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
519 (defun flyspell-version () |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
520 "The flyspell version" |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
521 (interactive) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
522 "1.6h") |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
523 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
524 ;*---------------------------------------------------------------------*/ |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
525 ;* flyspell-accept-buffer-local-defs ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
526 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
527 (defun flyspell-accept-buffer-local-defs () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
528 (ispell-accept-buffer-local-defs) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
529 (if (not (and (eq flyspell-dash-dictionary ispell-dictionary) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
530 (eq flyspell-dash-local-dictionary ispell-local-dictionary))) |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
531 ;; the dictionary has changed |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
532 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
533 (setq flyspell-dash-dictionary ispell-dictionary) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
534 (setq flyspell-dash-local-dictionary ispell-local-dictionary) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
535 (if (member (or ispell-local-dictionary ispell-dictionary) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
536 flyspell-dictionaries-that-consider-dash-as-word-delimiter) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
537 (setq flyspell-consider-dash-as-word-delimiter-flag t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
538 (setq flyspell-consider-dash-as-word-delimiter-flag nil))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
539 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
540 ;*---------------------------------------------------------------------*/ |
22611 | 541 ;* flyspell-mode-on ... */ |
542 ;*---------------------------------------------------------------------*/ | |
543 (defun flyspell-mode-on () | |
23234 | 544 "Turn Flyspell mode on. Do not use this; use `flyspell-mode' instead." |
22611 | 545 (setq ispell-highlight-face 'flyspell-incorrect-face) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
546 ;; local dictionaries setup |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
547 (ispell-change-dictionary |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
548 (or ispell-local-dictionary ispell-dictionary flyspell-default-dictionary)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
549 ;; we have to force ispell to accept the local definition or |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
550 ;; otherwise it could be too late, the local dictionary may |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
551 ;; be forgotten! |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
552 (flyspell-accept-buffer-local-defs) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
553 ;; we put the `flyspel-delayed' property on some commands |
22611 | 554 (flyspell-delay-commands) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
555 ;; we put the `flyspel-deplacement' property on some commands |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
556 (flyspell-deplacement-commands) |
22611 | 557 ;; 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
|
558 (add-hook 'post-command-hook (function flyspell-post-command-hook) t t) |
22611 | 559 ;; 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
|
560 (add-hook 'pre-command-hook (function flyspell-pre-command-hook) t t) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
561 ;; we bound flyspell action to after-change hook |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
562 (make-local-variable 'after-change-functions) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
563 (setq after-change-functions |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
564 (cons 'flyspell-after-change-function after-change-functions)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
565 ;; 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
|
566 (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
|
567 (if mode-predicate |
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
568 (setq flyspell-generic-check-word-p mode-predicate))) |
22611 | 569 ;; the welcome message |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
570 (if (and flyspell-issue-message-flag |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
571 flyspell-issue-welcome-flag |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
572 (interactive-p)) |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
573 (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
|
574 nil 'non-ascii))) |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
575 (message |
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
576 (if binding |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
577 (format "Welcome to flyspell. Use %s or Mouse-2 to correct words." |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
578 (key-description binding)) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
579 "Welcome to flyspell. Use Mouse-2 to correct words.")))) |
22611 | 580 ;; we end with the flyspell hooks |
581 (run-hooks 'flyspell-mode-hook)) | |
582 | |
583 ;*---------------------------------------------------------------------*/ | |
584 ;* flyspell-delay-commands ... */ | |
585 ;*---------------------------------------------------------------------*/ | |
586 (defun flyspell-delay-commands () | |
23234 | 587 "Install the standard set of Flyspell delayed commands." |
22611 | 588 (mapcar 'flyspell-delay-command flyspell-default-delayed-commands) |
589 (mapcar 'flyspell-delay-command flyspell-delayed-commands)) | |
590 | |
591 ;*---------------------------------------------------------------------*/ | |
592 ;* flyspell-delay-command ... */ | |
593 ;*---------------------------------------------------------------------*/ | |
594 (defun flyspell-delay-command (command) | |
23234 | 595 "Set COMMAND to be delayed, for Flyspell. |
22611 | 596 When flyspell `post-command-hook' is invoked because a delayed command |
37008 | 597 as been used the current word is not immediately checked. |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
598 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
|
599 (interactive "SDelay Flyspell after Command: ") |
22611 | 600 (put command 'flyspell-delayed t)) |
601 | |
602 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
603 ;* flyspell-deplacement-commands ... */ |
22611 | 604 ;*---------------------------------------------------------------------*/ |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
605 (defun flyspell-deplacement-commands () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
606 "Install the standard set of Flyspell deplacement commands." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
607 (mapcar 'flyspell-deplacement-command flyspell-default-deplacement-commands) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
608 (mapcar 'flyspell-deplacement-command flyspell-deplacement-commands)) |
22611 | 609 |
610 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
611 ;* flyspell-deplacement-command ... */ |
22611 | 612 ;*---------------------------------------------------------------------*/ |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
613 (defun flyspell-deplacement-command (command) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
614 "Set COMMAND that implement cursor movements, for Flyspell. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
615 When flyspell `post-command-hook' is invoked because of a deplacement command |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
616 as been used the current word is checked only if the previous command was |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
617 not the very same deplacement command." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
618 (interactive "SDeplacement Flyspell after Command: ") |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
619 (put command 'flyspell-deplacement t)) |
22611 | 620 |
621 ;*---------------------------------------------------------------------*/ | |
622 ;* flyspell-word-cache ... */ | |
623 ;*---------------------------------------------------------------------*/ | |
624 (defvar flyspell-word-cache-start nil) | |
625 (defvar flyspell-word-cache-end nil) | |
626 (defvar flyspell-word-cache-word nil) | |
627 (make-variable-buffer-local 'flyspell-word-cache-start) | |
628 (make-variable-buffer-local 'flyspell-word-cache-end) | |
629 (make-variable-buffer-local 'flyspell-word-cache-word) | |
630 | |
631 ;*---------------------------------------------------------------------*/ | |
632 ;* The flyspell pre-hook, store the current position. In the */ | |
633 ;* post command hook, we will check, if the word at this position */ | |
634 ;* has to be spell checked. */ | |
635 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
636 (defvar flyspell-pre-buffer nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
637 (defvar flyspell-pre-point nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
638 (defvar flyspell-pre-column nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
639 (defvar flyspell-pre-pre-buffer nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
640 (defvar flyspell-pre-pre-point nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
641 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
642 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
643 ;* flyspell-previous-command ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
644 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
645 (defvar flyspell-previous-command nil |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
646 "The last interactive command checked by Flyspell.") |
22611 | 647 |
648 ;*---------------------------------------------------------------------*/ | |
649 ;* flyspell-pre-command-hook ... */ | |
650 ;*---------------------------------------------------------------------*/ | |
651 (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
|
652 "Save the current buffer and point for Flyspell's post-command hook." |
22611 | 653 (interactive) |
654 (setq flyspell-pre-buffer (current-buffer)) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
655 (setq flyspell-pre-point (point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
656 (setq flyspell-pre-column (current-column))) |
22611 | 657 |
658 ;*---------------------------------------------------------------------*/ | |
659 ;* flyspell-mode-off ... */ | |
660 ;*---------------------------------------------------------------------*/ | |
23234 | 661 ;;;###autoload |
22611 | 662 (defun flyspell-mode-off () |
23234 | 663 "Turn Flyspell mode off." |
22611 | 664 ;; we remove the hooks |
22962
f4509374e88e
(flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents:
22946
diff
changeset
|
665 (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
|
666 (remove-hook 'pre-command-hook (function flyspell-pre-command-hook) t) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
667 (setq after-change-functions (delq 'flyspell-after-change-function |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
668 after-change-functions)) |
22611 | 669 ;; we remove all the flyspell hilightings |
670 (flyspell-delete-all-overlays) | |
671 ;; we have to erase pre cache variables | |
672 (setq flyspell-pre-buffer nil) | |
673 (setq flyspell-pre-point nil) | |
674 ;; we mark the mode as killed | |
675 (setq flyspell-mode nil)) | |
676 | |
677 ;*---------------------------------------------------------------------*/ | |
678 ;* flyspell-check-pre-word-p ... */ | |
679 ;*---------------------------------------------------------------------*/ | |
680 (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
|
681 "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
|
682 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
|
683 before the current command." |
22611 | 684 (cond |
685 ((or (not (numberp flyspell-pre-point)) | |
686 (not (bufferp flyspell-pre-buffer)) | |
687 (not (buffer-live-p flyspell-pre-buffer))) | |
688 nil) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
689 ((and (eq flyspell-pre-pre-point flyspell-pre-point) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
690 (eq flyspell-pre-pre-buffer flyspell-pre-buffer)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
691 nil) |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
692 ((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
|
693 (eq (char-syntax (char-after flyspell-pre-point)) ?w)) |
22611 | 694 (= flyspell-pre-point (point)) |
695 (= flyspell-pre-point (+ (point) 1))) | |
696 nil) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
697 ((and (symbolp this-command) |
42684
0dd547dafa5e
(flyspell-check-pre-word-p): Prevent delaying when executing keyboard
Pavel Janík <Pavel@Janik.cz>
parents:
42622
diff
changeset
|
698 (not executing-kbd-macro) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
699 (or (get this-command 'flyspell-delayed) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
700 (and (get this-command 'flyspell-deplacement) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
701 (eq flyspell-previous-command this-command))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
702 (or (= (current-column) 0) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
703 (= (current-column) flyspell-pre-column) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
704 (eq (char-syntax (char-after flyspell-pre-point)) ?w))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
705 nil) |
22611 | 706 ((not (eq (current-buffer) flyspell-pre-buffer)) |
707 t) | |
708 ((not (and (numberp flyspell-word-cache-start) | |
709 (numberp flyspell-word-cache-end))) | |
710 t) | |
711 (t | |
712 (or (< flyspell-pre-point flyspell-word-cache-start) | |
713 (> flyspell-pre-point flyspell-word-cache-end))))) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
714 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
715 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
716 ;* The flyspell after-change-hook, store the change position. In */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
717 ;* the post command hook, we will check, if the word at this */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
718 ;* position has to be spell checked. */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
719 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
720 (defvar flyspell-changes nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
721 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
722 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
723 ;* flyspell-after-change-function ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
724 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
725 (defun flyspell-after-change-function (start stop len) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
726 "Save the current buffer and point for Flyspell's post-command hook." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
727 (interactive) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
728 (setq flyspell-changes (cons (cons start stop) flyspell-changes))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
729 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
730 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
731 ;* flyspell-check-changed-word-p ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
732 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
733 (defun flyspell-check-changed-word-p (start stop) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
734 "Return t when the changed word has to be checked. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
735 The answer depends of several criteria. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
736 Mostly we check word delimiters." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
737 (cond |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
738 ((and (eq (char-after start) ?\n) (> stop start)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
739 t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
740 ((not (numberp flyspell-pre-point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
741 t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
742 ((and (>= flyspell-pre-point start) (<= flyspell-pre-point stop)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
743 nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
744 ((let ((pos (point))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
745 (or (>= pos start) (<= pos stop) (= pos (1+ stop)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
746 nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
747 (t |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
748 t))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
749 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
750 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
751 ;* flyspell-check-word-p ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
752 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
753 (defun flyspell-check-word-p () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
754 "Return t when the word at `point' has to be checked. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
755 The answer depends of several criteria. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
756 Mostly we check word delimiters." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
757 (cond |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
758 ((<= (- (point-max) 1) (point-min)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
759 ;; the buffer is not filled enough |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
760 nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
761 ((and (and (> (current-column) 0) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
762 (not (eq (current-column) flyspell-pre-column))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
763 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
764 (backward-char 1) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
765 (and (looking-at (flyspell-get-not-casechars)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
766 (or flyspell-consider-dash-as-word-delimiter-flag |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
767 (not (looking-at "\\-")))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
768 ;; yes because we have reached or typed a word delimiter. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
769 t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
770 ((symbolp this-command) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
771 (cond |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
772 ((get this-command 'flyspell-deplacement) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
773 (not (eq flyspell-previous-command this-command))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
774 ((get this-command 'flyspell-delayed) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
775 ;; the current command is not delayed, that |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
776 ;; is that we must check the word now |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
777 (if (fboundp 'about-xemacs) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
778 (sit-for flyspell-delay nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
779 (sit-for flyspell-delay 0 nil))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
780 (t t))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
781 (t t))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
782 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
783 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
784 ;* flyspell-debug-signal-no-check ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
785 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
786 (defun flyspell-debug-signal-no-check (msg obj) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
787 (setq debug-on-error t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
788 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
789 (let ((buffer (get-buffer-create "*flyspell-debug*"))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
790 (set-buffer buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
791 (erase-buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
792 (insert "NO-CHECK:\n") |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
793 (insert (format " %S : %S\n" msg obj))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
794 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
795 ;*---------------------------------------------------------------------*/ |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
796 ;* flyspell-debug-signal-pre-word-checked ... */ |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
797 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
798 (defun flyspell-debug-signal-pre-word-checked () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
799 (setq debug-on-error t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
800 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
801 (let ((buffer (get-buffer-create "*flyspell-debug*"))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
802 (set-buffer buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
803 (insert "PRE-WORD:\n") |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
804 (insert (format " pre-point : %S\n" flyspell-pre-point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
805 (insert (format " pre-buffer : %S\n" flyspell-pre-buffer)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
806 (insert (format " cache-start: %S\n" flyspell-word-cache-start)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
807 (insert (format " cache-end : %S\n" flyspell-word-cache-end)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
808 (goto-char (point-max))))) |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
809 |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
810 ;*---------------------------------------------------------------------*/ |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
811 ;* flyspell-debug-signal-word-checked ... */ |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
812 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
813 (defun flyspell-debug-signal-word-checked () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
814 (setq debug-on-error t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
815 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
816 (let ((oldbuf (current-buffer)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
817 (buffer (get-buffer-create "*flyspell-debug*")) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
818 (point (point))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
819 (set-buffer buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
820 (insert "WORD:\n") |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
821 (insert (format " this-cmd : %S\n" this-command)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
822 (insert (format " delayed : %S\n" (and (symbolp this-command) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
823 (get this-command 'flyspell-delayed)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
824 (insert (format " point : %S\n" point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
825 (insert (format " prev-char : [%c] %S\n" |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
826 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
827 (set-buffer oldbuf) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
828 (let ((c (if (> (point) (point-min)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
829 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
830 (backward-char 1) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
831 (char-after (point))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
832 ? ))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
833 (set-buffer buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
834 c)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
835 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
836 (set-buffer oldbuf) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
837 (let ((c (if (> (point) (point-min)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
838 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
839 (backward-char 1) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
840 (and (and (looking-at (flyspell-get-not-casechars)) 1) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
841 (and (or flyspell-consider-dash-as-word-delimiter-flag |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
842 (not (looking-at "\\-"))) 2)))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
843 (set-buffer buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
844 c)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
845 (insert (format " because : %S\n" |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
846 (cond |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
847 ((not (and (symbolp this-command) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
848 (get this-command 'flyspell-delayed))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
849 ;; the current command is not delayed, that |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
850 ;; is that we must check the word now |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
851 'not-delayed) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
852 ((progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
853 (set-buffer oldbuf) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
854 (let ((c (if (> (point) (point-min)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
855 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
856 (backward-char 1) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
857 (and (looking-at (flyspell-get-not-casechars)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
858 (or flyspell-consider-dash-as-word-delimiter-flag |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
859 (not (looking-at "\\-")))))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
860 (set-buffer buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
861 c)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
862 ;; yes because we have reached or typed a word delimiter. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
863 'separator) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
864 ((not (integerp flyspell-delay)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
865 ;; yes because the user had set up a no-delay configuration. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
866 'no-delay) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
867 (t |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
868 'sit-for)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
869 (goto-char (point-max))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
870 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
871 ;*---------------------------------------------------------------------*/ |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
872 ;* flyspell-debug-signal-changed-checked ... */ |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
873 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
874 (defun flyspell-debug-signal-changed-checked () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
875 (setq debug-on-error t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
876 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
877 (let ((buffer (get-buffer-create "*flyspell-debug*")) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
878 (point (point))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
879 (set-buffer buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
880 (insert "CHANGED WORD:\n") |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
881 (insert (format " point : %S\n" point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
882 (goto-char (point-max))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
883 |
22611 | 884 ;*---------------------------------------------------------------------*/ |
885 ;* flyspell-post-command-hook ... */ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
886 ;* ------------------------------------------------------------- */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
887 ;* It is possible that we check several words: */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
888 ;* 1- the current word is checked if the predicate */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
889 ;* FLYSPELL-CHECK-WORD-P is true */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
890 ;* 2- the word that used to be the current word before the */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
891 ;* THIS-COMMAND is checked if: */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
892 ;* a- the previous word is different from the current word */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
893 ;* b- the previous word as not just been checked by the */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
894 ;* previous FLYSPELL-POST-COMMAND-HOOK */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
895 ;* 3- the words changed by the THIS-COMMAND that are neither the */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
896 ;* previous word nor the current word */ |
22611 | 897 ;*---------------------------------------------------------------------*/ |
898 (defun flyspell-post-command-hook () | |
899 "The `post-command-hook' used by flyspell to check a word in-the-fly." | |
900 (interactive) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
901 (let ((command this-command)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
902 (if (flyspell-check-pre-word-p) |
22611 | 903 (save-excursion |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
904 '(flyspell-debug-signal-pre-word-checked) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
905 (set-buffer flyspell-pre-buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
906 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
907 (goto-char flyspell-pre-point) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
908 (flyspell-word)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
909 (if (flyspell-check-word-p) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
910 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
911 '(flyspell-debug-signal-word-checked) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
912 (flyspell-word) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
913 ;; we remember which word we have just checked. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
914 ;; this will be used next time we will check a word |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
915 ;; to compare the next current word with the word |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
916 ;; that as been registered in the pre-command-hook |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
917 ;; that is these variables are used within the predicate |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
918 ;; FLYSPELL-CHECK-PRE-WORD-P |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
919 (setq flyspell-pre-pre-buffer (current-buffer)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
920 (setq flyspell-pre-pre-point (point))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
921 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
922 (setq flyspell-pre-pre-buffer nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
923 (setq flyspell-pre-pre-point nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
924 ;; when a word is not checked because of a delayed command |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
925 ;; we do not disable the ispell cache. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
926 (if (and (symbolp this-command) (get this-command 'flyspell-delayed)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
927 (setq flyspell-word-cache-end -1)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
928 (while (consp flyspell-changes) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
929 (let ((start (car (car flyspell-changes))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
930 (stop (cdr (car flyspell-changes)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
931 (if (flyspell-check-changed-word-p start stop) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
932 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
933 '(flyspell-debug-signal-changed-checked) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
934 (goto-char start) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
935 (flyspell-word))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
936 (setq flyspell-changes (cdr flyspell-changes)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
937 (setq flyspell-previous-command command))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
938 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
939 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
940 ;* flyspell-notify-misspell ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
941 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
942 (defun flyspell-notify-misspell (start end word poss) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
943 (let ((replacements (if (stringp poss) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
944 poss |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
945 (if flyspell-sort-corrections |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
946 (sort (car (cdr (cdr poss))) 'string<) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
947 (car (cdr (cdr poss))))))) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
948 (if flyspell-issue-message-flag |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
949 (message (format "mispelling `%s' %S" word replacements))))) |
22611 | 950 |
951 ;*---------------------------------------------------------------------*/ | |
952 ;* flyspell-word ... */ | |
953 ;*---------------------------------------------------------------------*/ | |
954 (defun flyspell-word (&optional following) | |
955 "Spell check a word." | |
956 (interactive (list current-prefix-arg)) | |
957 (if (interactive-p) | |
958 (setq following ispell-following-word)) | |
959 (save-excursion | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
960 ;; use the correct dictionary |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
961 (flyspell-accept-buffer-local-defs) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
962 (let* ((cursor-location (point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
963 (flyspell-word (flyspell-get-word following)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
964 start end poss word) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
965 (if (or (eq flyspell-word nil) |
22611 | 966 (and (fboundp flyspell-generic-check-word-p) |
967 (not (funcall flyspell-generic-check-word-p)))) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
968 '() |
22611 | 969 (progn |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
970 ;; destructure return flyspell-word info list. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
971 (setq start (car (cdr flyspell-word)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
972 end (car (cdr (cdr flyspell-word))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
973 word (car flyspell-word)) |
22611 | 974 ;; before checking in the directory, we check for doublons. |
975 (cond | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
976 ((and (or (not (eq ispell-parser 'tex)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
977 (not (eq (char-after start) ?\\))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
978 flyspell-mark-duplications-flag |
22611 | 979 (save-excursion |
980 (goto-char start) | |
981 (word-search-backward word | |
982 (- start | |
983 (+ 1 (- end start))) | |
984 t))) | |
985 ;; yes, this is a doublon | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
986 (flyspell-highlight-incorrect-region start end 'doublon)) |
22611 | 987 ((and (eq flyspell-word-cache-start start) |
988 (eq flyspell-word-cache-end end) | |
989 (string-equal flyspell-word-cache-word word)) | |
990 ;; this word had been already checked, we skip | |
991 nil) | |
992 ((and (eq ispell-parser 'tex) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
993 (flyspell-tex-command-p flyspell-word)) |
22611 | 994 ;; this is a correct word (because a tex command) |
995 (flyspell-unhighlight-at start) | |
996 (if (> end start) | |
997 (flyspell-unhighlight-at (- end 1))) | |
998 t) | |
999 (t | |
1000 ;; we setup the cache | |
1001 (setq flyspell-word-cache-start start) | |
1002 (setq flyspell-word-cache-end end) | |
1003 (setq flyspell-word-cache-word word) | |
1004 ;; now check spelling of word. | |
1005 (process-send-string ispell-process "%\n") | |
1006 ;; put in verbose mode | |
1007 (process-send-string ispell-process | |
1008 (concat "^" word "\n")) | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
1009 ;; 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
|
1010 ;; 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
|
1011 (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
|
1012 (process-kill-without-query ispell-process)) |
22611 | 1013 ;; wait until ispell has processed word |
1014 (while (progn | |
1015 (accept-process-output ispell-process) | |
1016 (not (string= "" (car ispell-filter))))) | |
1017 ;; (process-send-string ispell-process "!\n") | |
1018 ;; back to terse mode. | |
1019 (setq ispell-filter (cdr ispell-filter)) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1020 (if (consp ispell-filter) |
22611 | 1021 (setq poss (ispell-parse-output (car ispell-filter)))) |
1022 (cond ((eq poss t) | |
1023 ;; correct | |
1024 (flyspell-unhighlight-at start) | |
1025 (if (> end start) | |
1026 (flyspell-unhighlight-at (- end 1))) | |
1027 t) | |
1028 ((and (stringp poss) flyspell-highlight-flag) | |
1029 ;; correct | |
1030 (flyspell-unhighlight-at start) | |
1031 (if (> end start) | |
1032 (flyspell-unhighlight-at (- end 1))) | |
1033 t) | |
1034 ((null poss) | |
1035 (flyspell-unhighlight-at start) | |
1036 (if (> end start) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1037 (flyspell-unhighlight-at (- end 1)))) |
22611 | 1038 ((or (and (< flyspell-duplicate-distance 0) |
1039 (or (save-excursion | |
1040 (goto-char start) | |
1041 (word-search-backward word | |
1042 (point-min) | |
1043 t)) | |
1044 (save-excursion | |
1045 (goto-char end) | |
1046 (word-search-forward word | |
1047 (point-max) | |
1048 t)))) | |
1049 (and (> flyspell-duplicate-distance 0) | |
1050 (or (save-excursion | |
1051 (goto-char start) | |
1052 (word-search-backward | |
1053 word | |
1054 (- start | |
1055 flyspell-duplicate-distance) | |
1056 t)) | |
1057 (save-excursion | |
1058 (goto-char end) | |
1059 (word-search-forward | |
1060 word | |
1061 (+ end | |
1062 flyspell-duplicate-distance) | |
1063 t))))) | |
1064 (if flyspell-highlight-flag | |
1065 (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
|
1066 (message (format "duplicate `%s'" word)))) |
22611 | 1067 (t |
1068 ;; incorrect highlight the location | |
1069 (if flyspell-highlight-flag | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1070 (flyspell-highlight-incorrect-region start end poss) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1071 (flyspell-notify-misspell start end word poss)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1072 ;; return to original location |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
1073 (goto-char cursor-location) |
22611 | 1074 (if ispell-quit (setq ispell-quit nil))))))))) |
1075 | |
1076 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1077 ;* flyspell-tex-math-initialized ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1078 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1079 (defvar flyspell-tex-math-initialized nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1080 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1081 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1082 ;* flyspell-math-tex-command-p ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1083 ;* ------------------------------------------------------------- */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1084 ;* This function uses the texmathp package to check if (point) */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1085 ;* is within a tex command. In order to avoid using */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1086 ;* condition-case each time we use the variable */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1087 ;* flyspell-tex-math-initialized to make a special case the first */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1088 ;* time that function is called. */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1089 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1090 (defun flyspell-math-tex-command-p () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1091 (cond |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1092 (flyspell-check-tex-math-command |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1093 nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1094 ((eq flyspell-tex-math-initialized t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1095 (texmathp)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1096 ((eq flyspell-tex-math-initialized 'error) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1097 nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1098 (t |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1099 (setq flyspell-tex-math-initialized t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1100 (condition-case nil |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1101 (texmathp) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1102 (error (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1103 (setq flyspell-tex-math-initialized 'error) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1104 nil)))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1105 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1106 ;*---------------------------------------------------------------------*/ |
22611 | 1107 ;* flyspell-tex-command-p ... */ |
1108 ;*---------------------------------------------------------------------*/ | |
1109 (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
|
1110 "Return t if WORD is a TeX command." |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1111 (or (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1112 (let ((b (car (cdr word)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1113 (and (re-search-backward "\\\\" (- (point) 100) t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1114 (or (= (match-end 0) b) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1115 (and (goto-char (match-end 0)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1116 (looking-at flyspell-tex-command-regexp) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1117 (>= (match-end 0) b)))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1118 (flyspell-math-tex-command-p))) |
22611 | 1119 |
1120 ;*---------------------------------------------------------------------*/ | |
1121 ;* flyspell-casechars-cache ... */ | |
1122 ;*---------------------------------------------------------------------*/ | |
1123 (defvar flyspell-casechars-cache nil) | |
1124 (defvar flyspell-ispell-casechars-cache nil) | |
1125 (make-variable-buffer-local 'flyspell-casechars-cache) | |
1126 (make-variable-buffer-local 'flyspell-ispell-casechars-cache) | |
1127 | |
1128 ;*---------------------------------------------------------------------*/ | |
1129 ;* flyspell-get-casechars ... */ | |
1130 ;*---------------------------------------------------------------------*/ | |
1131 (defun flyspell-get-casechars () | |
1132 "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
|
1133 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
|
1134 this function changes the last char of the `ispell-casechars' string." |
22611 | 1135 (let ((ispell-casechars (ispell-get-casechars))) |
1136 (cond | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1137 ((eq ispell-parser 'tex) |
22611 | 1138 (setq flyspell-ispell-casechars-cache ispell-casechars) |
1139 (setq flyspell-casechars-cache | |
1140 (concat (substring ispell-casechars | |
1141 0 | |
1142 (- (length ispell-casechars) 1)) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1143 "]")) |
22611 | 1144 flyspell-casechars-cache) |
1145 (t | |
1146 (setq flyspell-ispell-casechars-cache ispell-casechars) | |
1147 (setq flyspell-casechars-cache ispell-casechars) | |
1148 flyspell-casechars-cache)))) | |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
1149 |
22611 | 1150 ;*---------------------------------------------------------------------*/ |
1151 ;* flyspell-get-not-casechars-cache ... */ | |
1152 ;*---------------------------------------------------------------------*/ | |
1153 (defvar flyspell-not-casechars-cache nil) | |
1154 (defvar flyspell-ispell-not-casechars-cache nil) | |
1155 (make-variable-buffer-local 'flyspell-not-casechars-cache) | |
1156 (make-variable-buffer-local 'flyspell-ispell-not-casechars-cache) | |
1157 | |
1158 ;*---------------------------------------------------------------------*/ | |
1159 ;* flyspell-get-not-casechars ... */ | |
1160 ;*---------------------------------------------------------------------*/ | |
1161 (defun flyspell-get-not-casechars () | |
1162 "This function builds a string that is the regexp of non-word chars." | |
1163 (let ((ispell-not-casechars (ispell-get-not-casechars))) | |
1164 (cond | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1165 ((eq ispell-parser 'tex) |
22611 | 1166 (setq flyspell-ispell-not-casechars-cache ispell-not-casechars) |
1167 (setq flyspell-not-casechars-cache | |
1168 (concat (substring ispell-not-casechars | |
1169 0 | |
1170 (- (length ispell-not-casechars) 1)) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1171 "]")) |
22611 | 1172 flyspell-not-casechars-cache) |
1173 (t | |
1174 (setq flyspell-ispell-not-casechars-cache ispell-not-casechars) | |
1175 (setq flyspell-not-casechars-cache ispell-not-casechars) | |
1176 flyspell-not-casechars-cache)))) | |
1177 | |
1178 ;*---------------------------------------------------------------------*/ | |
1179 ;* flyspell-get-word ... */ | |
1180 ;*---------------------------------------------------------------------*/ | |
1181 (defun flyspell-get-word (following) | |
1182 "Return the word for spell-checking according to Ispell syntax. | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1183 If argument FOLLOWING is non-nil or if `ispell-following-word' |
22611 | 1184 is non-nil when called interactively, then the following word |
1185 \(rather than preceding\) is checked when the cursor is not over a word. | |
37008 | 1186 Optional second argument contains other chars that can be included in word |
22611 | 1187 many times. |
1188 | |
1189 Word syntax described by `ispell-dictionary-alist' (which see)." | |
1190 (let* ((flyspell-casechars (flyspell-get-casechars)) | |
1191 (flyspell-not-casechars (flyspell-get-not-casechars)) | |
1192 (ispell-otherchars (ispell-get-otherchars)) | |
1193 (ispell-many-otherchars-p (ispell-get-many-otherchars-p)) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1194 (word-regexp (if (string< "" ispell-otherchars) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1195 (concat flyspell-casechars |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1196 "+\\(" |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1197 ispell-otherchars |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1198 "?" |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1199 flyspell-casechars |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1200 "+\\)" |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1201 (if ispell-many-otherchars-p |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1202 "*" "?")) |
24943
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
1203 (concat flyspell-casechars "+"))) |
22611 | 1204 did-it-once |
1205 start end word) | |
1206 ;; find the word | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1207 (if (not (looking-at flyspell-casechars)) |
22611 | 1208 (if following |
1209 (re-search-forward flyspell-casechars (point-max) t) | |
1210 (re-search-backward flyspell-casechars (point-min) t))) | |
1211 ;; move to front of word | |
1212 (re-search-backward flyspell-not-casechars (point-min) 'start) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1213 (let ((pos nil)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1214 (if (string< "" ispell-otherchars) |
24943
59585a4135a6
(flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents:
24458
diff
changeset
|
1215 (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
|
1216 (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
|
1217 (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
|
1218 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
|
1219 (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
|
1220 (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
|
1221 (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
|
1222 (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
|
1223 (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
|
1224 (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
|
1225 (backward-char -1))))) |
22611 | 1226 ;; Now mark the word and save to string. |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1227 (if (eq (re-search-forward word-regexp (point-max) t) nil) |
22611 | 1228 nil |
1229 (progn | |
1230 (setq start (match-beginning 0) | |
1231 end (point) | |
36129
4c28e9406f50
(flyspell-get-word): Return string without
Dave Love <fx@gnu.org>
parents:
36120
diff
changeset
|
1232 word (buffer-substring-no-properties start end)) |
22611 | 1233 (list word start end))))) |
1234 | |
1235 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1236 ;* flyspell-small-region ... */ |
22611 | 1237 ;*---------------------------------------------------------------------*/ |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1238 (defun flyspell-small-region (beg end) |
22611 | 1239 "Flyspell text between BEG and END." |
1240 (save-excursion | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1241 (if (> beg end) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1242 (let ((old beg)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1243 (setq beg end) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1244 (setq end old))) |
22611 | 1245 (goto-char beg) |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1246 (let ((count 0)) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1247 (while (< (point) end) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1248 (if (and flyspell-issue-message-flag (= count 100)) |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1249 (progn |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1250 (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
|
1251 (* 100 (/ (float (- (point) beg)) (- end beg)))) |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1252 (setq count 0)) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1253 (setq count (+ 1 count))) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1254 (flyspell-word) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1255 (sit-for 0) |
22612
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1256 (let ((cur (point))) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1257 (forward-word 1) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1258 (if (and (< (point) end) (> (point) (+ cur 1))) |
6def3da74c7c
Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents:
22611
diff
changeset
|
1259 (backward-char 1))))) |
22611 | 1260 (backward-char 1) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1261 (if flyspell-issue-message-flag (message "Spell Checking completed.")) |
22611 | 1262 (flyspell-word))) |
1263 | |
1264 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1265 ;* flyspell-external-ispell-process ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1266 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1267 (defvar flyspell-external-ispell-process '() |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
1268 "The external Flyspell Ispell process.") |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1269 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1270 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1271 ;* flyspell-external-ispell-buffer ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1272 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1273 (defvar flyspell-external-ispell-buffer '()) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1274 (defvar flyspell-large-region-buffer '()) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1275 (defvar flyspell-large-region-beg (point-min)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1276 (defvar flyspell-large-region-end (point-max)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1277 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1278 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1279 ;* flyspell-external-point-words ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1280 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1281 (defun flyspell-external-point-words () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1282 (let ((buffer flyspell-external-ispell-buffer)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1283 (set-buffer buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1284 (beginning-of-buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1285 (let ((size (- flyspell-large-region-end flyspell-large-region-beg)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1286 (start flyspell-large-region-beg)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1287 ;; now we are done with ispell, we have to find the word in |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1288 ;; the initial buffer |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1289 (while (< (point) (- (point-max) 1)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1290 ;; we have to fetch the incorrect word |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1291 (if (re-search-forward "\\([^\n]+\\)\n" (point-max) t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1292 (let ((word (match-string 1))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1293 (goto-char (match-end 0)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1294 (set-buffer flyspell-large-region-buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1295 (goto-char flyspell-large-region-beg) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1296 (if flyspell-issue-message-flag |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1297 (message "Spell Checking...%d%% [%s]" |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1298 (* 100 (/ (float (- (point) start)) size)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1299 word)) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1300 (if (search-forward word flyspell-large-region-end t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1301 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1302 (setq flyspell-large-region-beg (point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1303 (goto-char (- (point) 1)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1304 (flyspell-word))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1305 (set-buffer buffer)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1306 (goto-char (point-max))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1307 ;; we are done |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1308 (if flyspell-issue-message-flag (message "Spell Checking completed.")) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1309 ;; ok, we are done with pointing out incorrect words, we just |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1310 ;; have to kill the temporary buffer |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1311 (kill-buffer flyspell-external-ispell-buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1312 (setq flyspell-external-ispell-buffer nil))) |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
1313 |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1314 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1315 ;* flyspell-large-region ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1316 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1317 (defun flyspell-large-region (beg end) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1318 (let* ((curbuf (current-buffer)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1319 (buffer (get-buffer-create "*flyspell-region*"))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1320 (setq flyspell-external-ispell-buffer buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1321 (setq flyspell-large-region-buffer curbuf) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1322 (setq flyspell-large-region-beg beg) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1323 (setq flyspell-large-region-end end) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1324 (set-buffer buffer) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1325 (erase-buffer) |
37008 | 1326 ;; this is done, we can start checking... |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1327 (if flyspell-issue-message-flag (message "Checking region...")) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1328 (set-buffer curbuf) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1329 (let ((c (apply 'call-process-region beg |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1330 end |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1331 ispell-program-name |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1332 nil |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1333 buffer |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1334 nil |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1335 "-l" |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1336 (let (args) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1337 ;; Local dictionary becomes the global dictionary in use. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1338 (if ispell-local-dictionary |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1339 (setq ispell-dictionary ispell-local-dictionary)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1340 (setq args (ispell-get-ispell-args)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1341 (if ispell-dictionary ; use specified dictionary |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1342 (setq args |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1343 (append (list "-d" ispell-dictionary) args))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1344 (if ispell-personal-dictionary ; use specified pers dict |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1345 (setq args |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1346 (append args |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1347 (list "-p" |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1348 (expand-file-name |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1349 ispell-personal-dictionary))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1350 (setq args (append args ispell-extra-args)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1351 args)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1352 (if (= c 0) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1353 (flyspell-external-point-words) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1354 (error "Can't check region..."))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1355 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1356 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1357 ;* flyspell-region ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1358 ;* ------------------------------------------------------------- */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1359 ;* Because `ispell -a' is too slow, it is not possible to use */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1360 ;* it on large region. Then, when ispell is invoked on a large */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1361 ;* text region, a new `ispell -l' process is spawned. The */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1362 ;* pointed out words are then searched in the region a checked with */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1363 ;* regular flyspell means. */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1364 ;*---------------------------------------------------------------------*/ |
36120
927cbaaa27f8
(flyspell-region, flyspell-buffer):
Gerd Moellmann <gerd@gnu.org>
parents:
35617
diff
changeset
|
1365 ;;;###autoload |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1366 (defun flyspell-region (beg end) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1367 "Flyspell text between BEG and END." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1368 (interactive "r") |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1369 (if (= beg end) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1370 () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1371 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1372 (if (> beg end) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1373 (let ((old beg)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1374 (setq beg end) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1375 (setq end old))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1376 (if (> (- end beg) flyspell-large-region) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1377 (flyspell-large-region beg end) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1378 (flyspell-small-region beg end))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1379 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1380 ;*---------------------------------------------------------------------*/ |
22611 | 1381 ;* flyspell-buffer ... */ |
1382 ;*---------------------------------------------------------------------*/ | |
36120
927cbaaa27f8
(flyspell-region, flyspell-buffer):
Gerd Moellmann <gerd@gnu.org>
parents:
35617
diff
changeset
|
1383 ;;;###autoload |
22611 | 1384 (defun flyspell-buffer () |
1385 "Flyspell whole buffer." | |
1386 (interactive) | |
1387 (flyspell-region (point-min) (point-max))) | |
1388 | |
1389 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1390 ;* old next error position ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1391 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1392 (defvar flyspell-old-buffer-error nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1393 (defvar flyspell-old-pos-error nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1394 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1395 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1396 ;* flyspell-goto-next-error ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1397 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1398 (defun flyspell-goto-next-error () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1399 "Go to the next previously detected error. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1400 In general FLYSPELL-GOTO-NEXT-ERROR must be used after |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1401 FLYSPELL-BUFFER." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1402 (interactive) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1403 (let ((pos (point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1404 (max (point-max))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1405 (if (and (eq (current-buffer) flyspell-old-buffer-error) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1406 (eq pos flyspell-old-pos-error)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1407 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1408 (if (= flyspell-old-pos-error max) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1409 ;; goto beginning of buffer |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1410 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1411 (message "Restarting from beginning of buffer") |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1412 (goto-char (point-min))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1413 (forward-word 1)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1414 (setq pos (point)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1415 ;; seek the next error |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1416 (while (and (< pos max) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1417 (let ((ovs (overlays-at pos)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1418 (r '())) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1419 (while (and (not r) (consp ovs)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1420 (if (flyspell-overlay-p (car ovs)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1421 (setq r t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1422 (setq ovs (cdr ovs)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1423 (not r))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1424 (setq pos (1+ pos))) |
37008 | 1425 ;; save the current location for next invocation |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1426 (setq flyspell-old-pos-error pos) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1427 (setq flyspell-old-buffer-error (current-buffer)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1428 (goto-char pos) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1429 (if (= pos max) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1430 (message "No more miss-spelled word!")))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1431 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1432 ;*---------------------------------------------------------------------*/ |
22611 | 1433 ;* flyspell-overlay-p ... */ |
1434 ;*---------------------------------------------------------------------*/ | |
1435 (defun flyspell-overlay-p (o) | |
1436 "A predicate that return true iff O is an overlay used by flyspell." | |
1437 (and (overlayp o) (overlay-get o 'flyspell-overlay))) | |
1438 | |
1439 ;*---------------------------------------------------------------------*/ | |
1440 ;* flyspell-delete-all-overlays ... */ | |
1441 ;* ------------------------------------------------------------- */ | |
1442 ;* Remove all the overlays introduced by flyspell. */ | |
1443 ;*---------------------------------------------------------------------*/ | |
1444 (defun flyspell-delete-all-overlays () | |
1445 "Delete all the overlays used by flyspell." | |
1446 (let ((l (overlays-in (point-min) (point-max)))) | |
1447 (while (consp l) | |
1448 (progn | |
1449 (if (flyspell-overlay-p (car l)) | |
1450 (delete-overlay (car l))) | |
1451 (setq l (cdr l)))))) | |
1452 | |
1453 ;*---------------------------------------------------------------------*/ | |
1454 ;* flyspell-unhighlight-at ... */ | |
1455 ;*---------------------------------------------------------------------*/ | |
1456 (defun flyspell-unhighlight-at (pos) | |
1457 "Remove the flyspell overlay that are located at POS." | |
1458 (if flyspell-persistent-highlight | |
1459 (let ((overlays (overlays-at pos))) | |
1460 (while (consp overlays) | |
1461 (if (flyspell-overlay-p (car overlays)) | |
1462 (delete-overlay (car overlays))) | |
1463 (setq overlays (cdr overlays)))) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1464 (if (flyspell-overlay-p flyspell-overlay) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1465 (delete-overlay flyspell-overlay)))) |
22611 | 1466 |
1467 ;*---------------------------------------------------------------------*/ | |
1468 ;* flyspell-properties-at-p ... */ | |
1469 ;* ------------------------------------------------------------- */ | |
1470 ;* Is there an highlight properties at position pos? */ | |
1471 ;*---------------------------------------------------------------------*/ | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
1472 (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
|
1473 "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
|
1474 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
|
1475 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
|
1476 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
|
1477 (let ((prop (text-properties-at pos)) |
22611 | 1478 (keep t)) |
1479 (while (and keep (consp prop)) | |
1480 (if (and (eq (car prop) 'local-map) (consp (cdr prop))) | |
1481 (setq prop (cdr (cdr prop))) | |
1482 (setq keep nil))) | |
1483 (consp prop))) | |
1484 | |
1485 ;*---------------------------------------------------------------------*/ | |
1486 ;* make-flyspell-overlay ... */ | |
1487 ;*---------------------------------------------------------------------*/ | |
1488 (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
|
1489 "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
|
1490 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
|
1491 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
|
1492 for the overlay." |
24076
6236e60302e2
(make-flyspell-overlay): fix front stickiness.
Richard M. Stallman <rms@gnu.org>
parents:
23943
diff
changeset
|
1493 (let ((flyspell-overlay (make-overlay beg end nil t nil))) |
22611 | 1494 (overlay-put flyspell-overlay 'face face) |
1495 (overlay-put flyspell-overlay 'mouse-face mouse-face) | |
1496 (overlay-put flyspell-overlay 'flyspell-overlay t) | |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1497 (overlay-put flyspell-overlay 'evaporate t) |
23943
7555c77bc4f0
If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents:
23788
diff
changeset
|
1498 (if flyspell-use-local-map |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1499 (overlay-put flyspell-overlay |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1500 flyspell-overlay-keymap-property-name |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1501 flyspell-mouse-map)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1502 (when (eq face 'flyspell-incorrect-face) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1503 (and (stringp flyspell-before-incorrect-word-string) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1504 (overlay-put flyspell-overlay 'before-string |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1505 flyspell-before-incorrect-word-string)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1506 (and (stringp flyspell-after-incorrect-word-string) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1507 (overlay-put flyspell-overlay 'after-string |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1508 flyspell-after-incorrect-word-string))) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1509 flyspell-overlay)) |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
1510 |
22611 | 1511 ;*---------------------------------------------------------------------*/ |
1512 ;* flyspell-highlight-incorrect-region ... */ | |
1513 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1514 (defun flyspell-highlight-incorrect-region (beg end poss) |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
1515 "Set up an overlay on a misspelled word, in the buffer from BEG to END." |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1516 (unless (run-hook-with-args-until-success |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1517 'flyspell-incorrect-hook beg end poss) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1518 (if (or flyspell-highlight-properties (not (flyspell-properties-at-p beg))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1519 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1520 ;; we cleanup current overlay at the same position |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1521 (if (and (not flyspell-persistent-highlight) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1522 (overlayp flyspell-overlay)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1523 (delete-overlay flyspell-overlay) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1524 (let ((overlays (overlays-at beg))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1525 (while (consp overlays) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1526 (if (flyspell-overlay-p (car overlays)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1527 (delete-overlay (car overlays))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1528 (setq overlays (cdr overlays))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1529 ;; now we can use a new overlay |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1530 (setq flyspell-overlay |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1531 (make-flyspell-overlay beg end |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
1532 'flyspell-incorrect-face |
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
1533 'highlight)))))) |
22611 | 1534 |
1535 ;*---------------------------------------------------------------------*/ | |
1536 ;* flyspell-highlight-duplicate-region ... */ | |
1537 ;*---------------------------------------------------------------------*/ | |
1538 (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
|
1539 "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
|
1540 (if (or flyspell-highlight-properties (not (flyspell-properties-at-p beg))) |
22611 | 1541 (progn |
1542 ;; we cleanup current overlay at the same position | |
1543 (if (and (not flyspell-persistent-highlight) | |
1544 (overlayp flyspell-overlay)) | |
1545 (delete-overlay flyspell-overlay) | |
1546 (let ((overlays (overlays-at beg))) | |
1547 (while (consp overlays) | |
1548 (if (flyspell-overlay-p (car overlays)) | |
1549 (delete-overlay (car overlays))) | |
1550 (setq overlays (cdr overlays))))) | |
1551 ;; now we can use a new overlay | |
1552 (setq flyspell-overlay | |
1553 (make-flyspell-overlay beg end | |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1554 'flyspell-duplicate-face |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1555 'highlight))))) |
22611 | 1556 |
1557 ;*---------------------------------------------------------------------*/ | |
1558 ;* flyspell-auto-correct-cache ... */ | |
1559 ;*---------------------------------------------------------------------*/ | |
1560 (defvar flyspell-auto-correct-pos nil) | |
1561 (defvar flyspell-auto-correct-region nil) | |
1562 (defvar flyspell-auto-correct-ring nil) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1563 (defvar flyspell-auto-correct-word nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1564 (make-variable-buffer-local 'flyspell-auto-correct-pos) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1565 (make-variable-buffer-local 'flyspell-auto-correct-region) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1566 (make-variable-buffer-local 'flyspell-auto-correct-ring) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1567 (make-variable-buffer-local 'flyspell-auto-correct-word) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1568 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1569 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1570 ;* flyspell-check-previous-highlighted-word ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1571 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1572 (defun flyspell-check-previous-highlighted-word (&optional arg) |
37008 | 1573 "Correct the closer misspelled word. |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1574 This function scans a mis-spelled word before the cursor. If it finds one |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1575 it proposes replacement for that word. With prefix arg, count that many |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1576 misspelled words backwards." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1577 (interactive) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1578 (let ((pos1 (point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1579 (pos (point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1580 (arg (if (or (not (numberp arg)) (< arg 1)) 1 arg)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1581 ov ovs) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1582 (if (catch 'exit |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1583 (while (and (setq pos (previous-overlay-change pos)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1584 (not (= pos pos1))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1585 (setq pos1 pos) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1586 (if (> pos (point-min)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1587 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1588 (setq ovs (overlays-at (1- pos))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1589 (while (consp ovs) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1590 (setq ov (car ovs)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1591 (setq ovs (cdr ovs)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1592 (if (and (overlay-get ov 'flyspell-overlay) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1593 (= 0 (setq arg (1- arg)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1594 (throw 'exit t))))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1595 (save-excursion |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1596 (goto-char pos) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1597 (ispell-word)) |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
1598 (error "No word to correct before point")))) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1599 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1600 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1601 ;* flyspell-display-next-corrections ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1602 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1603 (defun flyspell-display-next-corrections (corrections) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1604 (let ((string "Corrections:") |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1605 (l corrections) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1606 (pos '())) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1607 (while (< (length string) 80) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1608 (if (equal (car l) flyspell-auto-correct-word) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1609 (setq pos (cons (+ 1 (length string)) pos))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1610 (setq string (concat string " " (car l))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1611 (setq l (cdr l))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1612 (while (consp pos) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1613 (let ((num (car pos))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1614 (put-text-property num |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1615 (+ num (length flyspell-auto-correct-word)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1616 'face |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1617 'flyspell-incorrect-face |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1618 string)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1619 (setq pos (cdr pos))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1620 (if (fboundp 'display-message) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1621 (display-message 'no-log string) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1622 (message string)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1623 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1624 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1625 ;* flyspell-abbrev-table ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1626 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1627 (defun flyspell-abbrev-table () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1628 (if flyspell-use-global-abbrev-table-p |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1629 global-abbrev-table |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1630 local-abbrev-table)) |
22611 | 1631 |
1632 ;*---------------------------------------------------------------------*/ | |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1633 ;* flyspell-define-abbrev ... */ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1634 ;*---------------------------------------------------------------------*/ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1635 (defun flyspell-define-abbrev (name expansion) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1636 (let ((table (flyspell-abbrev-table))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1637 (when table |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1638 (define-abbrev table name expansion)))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1639 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1640 ;*---------------------------------------------------------------------*/ |
22611 | 1641 ;* flyspell-auto-correct-word ... */ |
1642 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1643 (defun flyspell-auto-correct-word () |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1644 "Correct the current word. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1645 This command proposes various successive corrections for the current word." |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1646 (interactive) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1647 (let ((pos (point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1648 (old-max (point-max))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1649 ;; use the correct dictionary |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1650 (flyspell-accept-buffer-local-defs) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1651 (if (and (eq flyspell-auto-correct-pos pos) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1652 (consp flyspell-auto-correct-region)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1653 ;; we have already been using the function at the same location |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1654 (let* ((start (car flyspell-auto-correct-region)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1655 (len (cdr flyspell-auto-correct-region))) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1656 (flyspell-unhighlight-at start) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1657 (delete-region start (+ start len)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1658 (setq flyspell-auto-correct-ring (cdr flyspell-auto-correct-ring)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1659 (let* ((word (car flyspell-auto-correct-ring)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1660 (len (length word))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1661 (rplacd flyspell-auto-correct-region len) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1662 (goto-char start) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1663 (if flyspell-abbrev-p |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1664 (if (flyspell-already-abbrevp (flyspell-abbrev-table) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1665 flyspell-auto-correct-word) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1666 (flyspell-change-abbrev (flyspell-abbrev-table) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1667 flyspell-auto-correct-word |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1668 word) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1669 (flyspell-define-abbrev flyspell-auto-correct-word word))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1670 (funcall flyspell-insert-function word) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1671 (flyspell-word) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1672 (flyspell-display-next-corrections flyspell-auto-correct-ring)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1673 (flyspell-ajust-cursor-point pos (point) old-max) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1674 (setq flyspell-auto-correct-pos (point))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1675 ;; fetch the word to be checked |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1676 (let ((word (flyspell-get-word nil)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1677 start end poss) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1678 ;; destructure return word info list. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1679 (setq start (car (cdr word)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1680 end (car (cdr (cdr word))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1681 word (car word)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1682 (setq flyspell-auto-correct-word word) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1683 ;; now check spelling of word. |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1684 (process-send-string ispell-process "%\n") ;put in verbose mode |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1685 (process-send-string ispell-process (concat "^" word "\n")) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1686 ;; wait until ispell has processed word |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1687 (while (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1688 (accept-process-output ispell-process) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1689 (not (string= "" (car ispell-filter))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1690 (setq ispell-filter (cdr ispell-filter)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1691 (if (consp ispell-filter) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1692 (setq poss (ispell-parse-output (car ispell-filter)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1693 (cond ((or (eq poss t) (stringp poss)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1694 ;; don't correct word |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1695 t) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1696 ((null poss) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1697 ;; ispell error |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1698 (error "Ispell: error in Ispell process")) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1699 (t |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1700 ;; the word is incorrect, we have to propose a replacement |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1701 (let ((replacements (if flyspell-sort-corrections |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1702 (sort (car (cdr (cdr poss))) 'string<) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1703 (car (cdr (cdr poss)))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1704 (setq flyspell-auto-correct-region nil) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1705 (if (consp replacements) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1706 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1707 (let ((replace (car replacements))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1708 (let ((new-word replace)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1709 (if (not (equal new-word (car poss))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1710 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1711 ;; the save the current replacements |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1712 (setq flyspell-auto-correct-region |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1713 (cons start (length new-word))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1714 (let ((l replacements)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1715 (while (consp (cdr l)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1716 (setq l (cdr l))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1717 (rplacd l (cons (car poss) replacements))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1718 (setq flyspell-auto-correct-ring |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1719 replacements) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1720 (flyspell-unhighlight-at start) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1721 (delete-region start end) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1722 (funcall flyspell-insert-function new-word) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1723 (if flyspell-abbrev-p |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1724 (if (flyspell-already-abbrevp |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1725 (flyspell-abbrev-table) word) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1726 (flyspell-change-abbrev |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1727 (flyspell-abbrev-table) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1728 word |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1729 new-word) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1730 (flyspell-define-abbrev word new-word))) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1731 (flyspell-word) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1732 (flyspell-display-next-corrections |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1733 (cons new-word flyspell-auto-correct-ring)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1734 (flyspell-ajust-cursor-point pos |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1735 (point) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1736 old-max)))))))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1737 (setq flyspell-auto-correct-pos (point)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1738 (ispell-pdict-save t))))) |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
1739 |
22611 | 1740 ;*---------------------------------------------------------------------*/ |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1741 ;* flyspell-auto-correct-previous-pos ... */ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1742 ;*---------------------------------------------------------------------*/ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1743 (defvar flyspell-auto-correct-previous-pos nil |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1744 "Holds the start of the first incorrect word before point.") |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1745 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1746 ;*---------------------------------------------------------------------*/ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1747 ;* flyspell-auto-correct-previous-hook ... */ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1748 ;*---------------------------------------------------------------------*/ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1749 (defun flyspell-auto-correct-previous-hook () |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1750 "Hook to track successive calls to `flyspell-auto-correct-previous-word'. |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1751 Sets flyspell-auto-correct-previous-pos to nil" |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1752 (interactive) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1753 (remove-hook 'pre-command-hook (function flyspell-auto-correct-previous-hook) t) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1754 (unless (eq this-command (function flyspell-auto-correct-previous-word)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1755 (setq flyspell-auto-correct-previous-pos nil))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1756 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1757 ;*---------------------------------------------------------------------*/ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1758 ;* flyspell-auto-correct-previous-word ... */ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1759 ;*---------------------------------------------------------------------*/ |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1760 (defun flyspell-auto-correct-previous-word (position) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1761 "*Auto correct the first mispelled word that occurs before point." |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1762 (interactive "d") |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1763 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1764 (add-hook 'pre-command-hook |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1765 (function flyspell-auto-correct-previous-hook) t t) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1766 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1767 (save-excursion |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1768 (unless flyspell-auto-correct-previous-pos |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1769 ;; only reset if a new overlay exists |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1770 (setq flyspell-auto-correct-previous-pos nil) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1771 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1772 (let ((overlay-list (overlays-in (point-min) position)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1773 (new-overlay 'dummy-value)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1774 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1775 ;; search for previous (new) flyspell overlay |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1776 (while (and new-overlay |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1777 (or (not (flyspell-overlay-p new-overlay)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1778 ;; check if its face has changed |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1779 (not (eq (get-char-property |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1780 (overlay-start new-overlay) 'face) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1781 'flyspell-incorrect-face)))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1782 (setq new-overlay (car-safe overlay-list)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1783 (setq overlay-list (cdr-safe overlay-list))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1784 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1785 ;; if nothing new exits new-overlay should be nil |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1786 (if new-overlay;; the length of the word may change so go to the start |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1787 (setq flyspell-auto-correct-previous-pos |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1788 (overlay-start new-overlay))))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1789 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1790 (when flyspell-auto-correct-previous-pos |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1791 (save-excursion |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1792 (goto-char flyspell-auto-correct-previous-pos) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1793 (let ((ispell-following-word t));; point is at start |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1794 (if (numberp flyspell-auto-correct-previous-pos) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1795 (goto-char flyspell-auto-correct-previous-pos)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1796 (flyspell-auto-correct-word)) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1797 ;; the point may have moved so reset this |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1798 (setq flyspell-auto-correct-previous-pos (point)))))) |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1799 |
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1800 ;*---------------------------------------------------------------------*/ |
22611 | 1801 ;* flyspell-correct-word ... */ |
1802 ;*---------------------------------------------------------------------*/ | |
1803 (defun flyspell-correct-word (event) | |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
1804 "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
|
1805 The word checked is the word at the mouse position." |
22611 | 1806 (interactive "e") |
1807 ;; use the correct dictionary | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1808 (flyspell-accept-buffer-local-defs) |
22611 | 1809 ;; retain cursor location (I don't know why but save-excursion here fails). |
1810 (let ((save (point))) | |
1811 (mouse-set-point event) | |
1812 (let ((cursor-location (point)) | |
1813 (word (flyspell-get-word nil)) | |
1814 start end poss replace) | |
1815 ;; destructure return word info list. | |
1816 (setq start (car (cdr word)) | |
1817 end (car (cdr (cdr word))) | |
1818 word (car word)) | |
1819 ;; now check spelling of word. | |
1820 (process-send-string ispell-process "%\n") ;put in verbose mode | |
1821 (process-send-string ispell-process (concat "^" word "\n")) | |
1822 ;; wait until ispell has processed word | |
1823 (while (progn | |
1824 (accept-process-output ispell-process) | |
1825 (not (string= "" (car ispell-filter))))) | |
1826 (setq ispell-filter (cdr ispell-filter)) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1827 (if (consp ispell-filter) |
22611 | 1828 (setq poss (ispell-parse-output (car ispell-filter)))) |
1829 (cond ((or (eq poss t) (stringp poss)) | |
1830 ;; don't correct word | |
1831 t) | |
1832 ((null poss) | |
1833 ;; ispell error | |
1834 (error "Ispell: error in Ispell process")) | |
1835 ((string-match "GNU" (emacs-version)) | |
1836 ;; 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
|
1837 (setq replace (flyspell-emacs-popup event poss word)) |
22611 | 1838 (cond ((eq replace 'ignore) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1839 (goto-char save) |
22611 | 1840 nil) |
1841 ((eq replace 'save) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1842 (goto-char save) |
22611 | 1843 (process-send-string ispell-process (concat "*" word "\n")) |
1844 (flyspell-unhighlight-at cursor-location) | |
1845 (setq ispell-pdict-modified-p '(t))) | |
1846 ((or (eq replace 'buffer) (eq replace 'session)) | |
1847 (process-send-string ispell-process (concat "@" word "\n")) | |
1848 (if (null ispell-pdict-modified-p) | |
1849 (setq ispell-pdict-modified-p | |
1850 (list ispell-pdict-modified-p))) | |
1851 (flyspell-unhighlight-at cursor-location) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1852 (goto-char save) |
22611 | 1853 (if (eq replace 'buffer) |
1854 (ispell-add-per-file-word-list word))) | |
1855 (replace | |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1856 (flyspell-unhighlight-at cursor-location) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1857 (let ((new-word (if (atom replace) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1858 replace |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1859 (car replace))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1860 (cursor-location (+ (- (length word) (- end start)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1861 cursor-location))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1862 (if (not (equal new-word (car poss))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1863 (let ((old-max (point-max))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1864 (delete-region start end) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1865 (funcall flyspell-insert-function new-word) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1866 (if flyspell-abbrev-p |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1867 (flyspell-define-abbrev word new-word)) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1868 (flyspell-ajust-cursor-point save |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1869 cursor-location |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1870 old-max))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1871 (t |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1872 (goto-char save) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1873 nil))) |
27787
d40d47971e6b
(flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents:
24943
diff
changeset
|
1874 ((eq flyspell-emacs 'xemacs) |
22611 | 1875 (flyspell-xemacs-popup |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1876 event poss word cursor-location start end save) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1877 (goto-char save))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1878 (ispell-pdict-save t)))) |
22611 | 1879 |
1880 ;*---------------------------------------------------------------------*/ | |
1881 ;* flyspell-xemacs-correct ... */ | |
1882 ;*---------------------------------------------------------------------*/ | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1883 (defun flyspell-xemacs-correct (replace poss word cursor-location start end save) |
22611 | 1884 "The xemacs popup menu callback." |
1885 (cond ((eq replace 'ignore) | |
1886 nil) | |
1887 ((eq replace 'save) | |
1888 (process-send-string ispell-process (concat "*" word "\n")) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1889 (process-send-string ispell-process "#\n") |
22611 | 1890 (flyspell-unhighlight-at cursor-location) |
1891 (setq ispell-pdict-modified-p '(t))) | |
1892 ((or (eq replace 'buffer) (eq replace 'session)) | |
1893 (process-send-string ispell-process (concat "@" word "\n")) | |
1894 (flyspell-unhighlight-at cursor-location) | |
1895 (if (null ispell-pdict-modified-p) | |
1896 (setq ispell-pdict-modified-p | |
1897 (list ispell-pdict-modified-p))) | |
1898 (if (eq replace 'buffer) | |
1899 (ispell-add-per-file-word-list word))) | |
1900 (replace | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1901 (let ((old-max (point-max)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1902 (new-word (if (atom replace) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1903 replace |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1904 (car replace))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1905 (cursor-location (+ (- (length word) (- end start)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1906 cursor-location))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1907 (if (not (equal new-word (car poss))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1908 (progn |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1909 (delete-region start end) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1910 (goto-char start) |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1911 (funcall flyspell-insert-function new-word) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1912 (if flyspell-abbrev-p |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1913 (flyspell-define-abbrev word new-word)))) |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1914 (flyspell-ajust-cursor-point save cursor-location old-max))))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1915 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1916 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1917 ;* flyspell-ajust-cursor-point ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1918 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1919 (defun flyspell-ajust-cursor-point (save cursor-location old-max) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1920 (if (>= save cursor-location) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1921 (let ((new-pos (+ save (- (point-max) old-max)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1922 (goto-char (cond |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1923 ((< new-pos (point-min)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1924 (point-min)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1925 ((> new-pos (point-max)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1926 (point-max)) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1927 (t new-pos)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1928 (goto-char save))) |
22611 | 1929 |
1930 ;*---------------------------------------------------------------------*/ | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
1931 ;* flyspell-emacs-popup ... */ |
22611 | 1932 ;*---------------------------------------------------------------------*/ |
22844
1104a715c324
(flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents:
22648
diff
changeset
|
1933 (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
|
1934 "The Emacs popup menu." |
22611 | 1935 (if (not event) |
1936 (let* ((mouse-pos (mouse-position)) | |
1937 (mouse-pos (if (nth 1 mouse-pos) | |
1938 mouse-pos | |
1939 (set-mouse-position (car mouse-pos) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1940 (/ (frame-width) 2) 2) |
22611 | 1941 (unfocus-frame) |
1942 (mouse-position)))) | |
1943 (setq event (list (list (car (cdr mouse-pos)) | |
1944 (1+ (cdr (cdr mouse-pos)))) | |
1945 (car mouse-pos))))) | |
1946 (let* ((corrects (if flyspell-sort-corrections | |
1947 (sort (car (cdr (cdr poss))) 'string<) | |
1948 (car (cdr (cdr poss))))) | |
1949 (cor-menu (if (consp corrects) | |
1950 (mapcar (lambda (correct) | |
1951 (list correct correct)) | |
1952 corrects) | |
1953 '())) | |
1954 (affix (car (cdr (cdr (cdr poss))))) | |
1955 (base-menu (let ((save (if (consp affix) | |
1956 (list | |
1957 (list (concat "Save affix: " (car affix)) | |
1958 'save) | |
43064
aad0b1eb2142
(flyspell-issue-message-flag): New user option.
Pavel Janík <Pavel@Janik.cz>
parents:
43016
diff
changeset
|
1959 '("Accept (session)" session) |
22611 | 1960 '("Accept (buffer)" buffer)) |
1961 '(("Save word" save) | |
1962 ("Accept (session)" session) | |
1963 ("Accept (buffer)" buffer))))) | |
1964 (if (consp cor-menu) | |
1965 (append cor-menu (cons "" save)) | |
1966 save))) | |
1967 (menu (cons "flyspell correction menu" base-menu))) | |
1968 (car (x-popup-menu event | |
1969 (list (format "%s [%s]" word (or ispell-local-dictionary | |
1970 ispell-dictionary)) | |
1971 menu))))) | |
1972 | |
1973 ;*---------------------------------------------------------------------*/ | |
22891
780c3ef895d7
(flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents:
22844
diff
changeset
|
1974 ;* flyspell-xemacs-popup ... */ |
22611 | 1975 ;*---------------------------------------------------------------------*/ |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1976 (defun flyspell-xemacs-popup (event poss word cursor-location start end save) |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
1977 "The XEmacs popup menu." |
22611 | 1978 (let* ((corrects (if flyspell-sort-corrections |
1979 (sort (car (cdr (cdr poss))) 'string<) | |
1980 (car (cdr (cdr poss))))) | |
1981 (cor-menu (if (consp corrects) | |
1982 (mapcar (lambda (correct) | |
1983 (vector correct | |
1984 (list 'flyspell-xemacs-correct | |
1985 correct | |
1986 (list 'quote poss) | |
1987 word | |
1988 cursor-location | |
1989 start | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1990 end |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
1991 save) |
22611 | 1992 t)) |
1993 corrects) | |
1994 '())) | |
1995 (affix (car (cdr (cdr (cdr poss))))) | |
1996 (menu (let ((save (if (consp affix) | |
1997 (vector | |
1998 (concat "Save affix: " (car affix)) | |
1999 (list 'flyspell-xemacs-correct | |
2000 ''save | |
2001 (list 'quote poss) | |
2002 word | |
2003 cursor-location | |
2004 start | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2005 end |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2006 save) |
22611 | 2007 t) |
2008 (vector | |
2009 "Save word" | |
2010 (list 'flyspell-xemacs-correct | |
2011 ''save | |
2012 (list 'quote poss) | |
2013 word | |
2014 cursor-location | |
2015 start | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2016 end |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2017 save) |
22611 | 2018 t))) |
2019 (session (vector "Accept (session)" | |
2020 (list 'flyspell-xemacs-correct | |
2021 ''session | |
2022 (list 'quote poss) | |
2023 word | |
2024 cursor-location | |
2025 start | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2026 end |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2027 save) |
22611 | 2028 t)) |
2029 (buffer (vector "Accept (buffer)" | |
2030 (list 'flyspell-xemacs-correct | |
2031 ''buffer | |
2032 (list 'quote poss) | |
2033 word | |
2034 cursor-location | |
2035 start | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2036 end |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2037 save) |
22611 | 2038 t))) |
2039 (if (consp cor-menu) | |
2040 (append cor-menu (list "-" save session buffer)) | |
2041 (list save session buffer))))) | |
2042 (popup-menu (cons (format "%s [%s]" word (or ispell-local-dictionary | |
2043 ispell-dictionary)) | |
2044 menu)))) | |
2045 | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2046 ;*---------------------------------------------------------------------*/ |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
2047 ;* Some example functions for real autocorrecting */ |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2048 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2049 (defun flyspell-maybe-correct-transposition (beg end poss) |
37008 | 2050 "Check replacements for transposed characters. |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2051 |
37008 | 2052 If the text between BEG and END is equal to a correction suggested by |
2053 Ispell, after transposing two adjacent characters, correct the text, | |
2054 and return t. | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2055 |
37008 | 2056 The third arg POSS is either the symbol 'doublon' or a list of |
2057 possible corrections as returned by 'ispell-parse-output'. | |
22611 | 2058 |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2059 This function is meant to be added to 'flyspell-incorrect-hook'." |
35617
da38a879b6fe
Doc fixes. Add :version to new options.
Dave Love <fx@gnu.org>
parents:
35338
diff
changeset
|
2060 (when (consp poss) |
37008 | 2061 (let ((temp-buffer (get-buffer-create " *flyspell-temp*")) |
2062 found) | |
2063 (save-excursion | |
2064 (copy-to-buffer temp-buffer beg end) | |
2065 (set-buffer temp-buffer) | |
2066 (goto-char (1+ (point-min))) | |
2067 (while (and (not (eobp)) (not found)) | |
2068 (transpose-chars 1) | |
2069 (if (member (buffer-string) (nth 2 poss)) | |
2070 (setq found (point)) | |
2071 (transpose-chars -1) | |
2072 (forward-char)))) | |
2073 (when found | |
37006
2fa95954d8de
Backed out changes made by John Wiegley 2000-10-28.
Gerd Moellmann <gerd@gnu.org>
parents:
36569
diff
changeset
|
2074 (save-excursion |
37008 | 2075 (goto-char (+ beg found -1)) |
2076 (transpose-chars -1) | |
2077 t))))) | |
2078 | |
2079 (defun flyspell-maybe-correct-doubling (beg end poss) | |
2080 "Check replacements for doubled characters. | |
2081 | |
2082 If the text between BEG and END is equal to a correction suggested by | |
2083 Ispell, after removing a pair of doubled characters, correct the text, | |
2084 and return t. | |
2085 | |
2086 The third arg POSS is either the symbol 'doublon' or a list of | |
2087 possible corrections as returned by 'ispell-parse-output'. | |
2088 | |
2089 This function is meant to be added to 'flyspell-incorrect-hook'." | |
2090 (when (consp poss) | |
2091 (let ((temp-buffer (get-buffer-create " *flyspell-temp*")) | |
2092 found) | |
2093 (save-excursion | |
2094 (copy-to-buffer temp-buffer beg end) | |
2095 (set-buffer temp-buffer) | |
2096 (goto-char (1+ (point-min))) | |
2097 (while (and (not (eobp)) (not found)) | |
2098 (when (char-equal (char-after) (char-before)) | |
2099 (delete-char 1) | |
2100 (if (member (buffer-string) (nth 2 poss)) | |
2101 (setq found (point)) | |
2102 (insert-char (char-before) 1))) | |
2103 (forward-char))) | |
2104 (when found | |
2105 (save-excursion | |
2106 (goto-char (+ beg found -1)) | |
2107 (delete-char 1) | |
2108 t))))) | |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2109 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2110 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2111 ;* flyspell-already-abbrevp ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2112 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2113 (defun flyspell-already-abbrevp (table word) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2114 (let ((sym (abbrev-symbol word table))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2115 (and sym (symbolp sym)))) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2116 |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2117 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2118 ;* flyspell-change-abbrev ... */ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2119 ;*---------------------------------------------------------------------*/ |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2120 (defun flyspell-change-abbrev (table old new) |
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2121 (set (abbrev-symbol old table) new)) |
43016
ee78d55b45f4
Minor formatting fixes in preparation of merging new version.
Pavel Janík <Pavel@Janik.cz>
parents:
42684
diff
changeset
|
2122 |
30428
b7b96f09059d
Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents:
27787
diff
changeset
|
2123 (provide 'flyspell) |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37008
diff
changeset
|
2124 |
22611 | 2125 ;;; flyspell.el ends here |